Skip to content

Instantly share code, notes, and snippets.

View sharpjs's full-sized avatar
💾
Flipping bits, taking bytes

Jeff Sharp sharpjs

💾
Flipping bits, taking bytes
View GitHub Profile
@sharpjs
sharpjs / AssemblyInfo.cs
Created May 14, 2014 22:24
Example Per-Project AssemblyInfo.cs
using System.Reflection;
using System.Security;
// General Information
[assembly: AssemblyTitle ("My Utility")]
[assembly: AssemblyDescription ("A neat program that does a few useful things.")]
// Security
//
// All code is transparent.
@sharpjs
sharpjs / ControllerTestExtensions.cs
Created September 18, 2013 14:27
Mocking controller context in ASP.NET MVC
using System;
using System.Collections;
using System.Security.Principal;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Moq;
namespace SharpJS.Web.Testing
{
@sharpjs
sharpjs / IUrlToken.cs
Created September 17, 2013 15:08
Convert objects to/from encrypted URL tokens.
using System.IO;
namespace SharpJS.Web
{
public interface IUrlToken
{
void WriteTo (BinaryWriter writer);
void ReadFrom (BinaryReader reader);
}
}
@sharpjs
sharpjs / FakeDbContext.cs
Last active November 15, 2016 15:16
How to fake a DbSet<T> for Entity Framework (EF5 as of this writing)
namespace SharpJS.Data.Entity.Testing
{
public abstract class FakeDbContext
{
protected FakeDbContext() { }
public abstract void SaveChanges ();
public abstract void Dispose ();
}
}
@sharpjs
sharpjs / SaveEntityFrameworkProxyAssembly.cs
Created January 30, 2013 22:30
Make Entity Framework save the dynamic proxy assembly it uses
private void SaveEntityFrameworkProxyAssembly(params Type[] types)
{
var factoryType = typeof(ObjectContext).Assembly.GetType(
"System.Data.Objects.Internal.EntityProxyFactory",
throwOnError: true);
var privateStaticFlags
= BindingFlags.Static
| BindingFlags.NonPublic;