Created
February 12, 2011 22:34
-
-
Save thecodejunkie/824201 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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