Skip to content

Instantly share code, notes, and snippets.

@thecodejunkie
Created February 12, 2011 22:34
Show Gist options
  • Save thecodejunkie/824201 to your computer and use it in GitHub Desktop.
Save thecodejunkie/824201 to your computer and use it in GitHub Desktop.
var asm = new FakeAssembly(x => {
x.AddResource("foo", "bar");
x.AddResource("bar", "foo");
});
public class FakeAssembly : Assembly
{
private readonly NameValueCollection resources = new NameValueCollection();
public FakeAssembly()
{
}
public FakeAssembly(Action<FakeAssemblyConfigurator> closure)
{
var configurator =
new FakeAssemblyConfigurator(this);
closure.Invoke(configurator);
}
public override string[] GetManifestResourceNames()
{
return this.resources.AllKeys;
}
public class FakeAssemblyConfigurator
{
private readonly FakeAssembly assembly;
public FakeAssemblyConfigurator(FakeAssembly assembly)
{
this.assembly = assembly;
}
public FakeAssemblyConfigurator AddResource(string name, string value)
{
this.assembly.resources.Add(name, value);
return this;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment