public void RegisterT_RegistersMutator() { // arrange var factory = new MutatorFactory(); var mutatorInfo = new { Prop1 = "foo" }; var asJson = JsonConvert.SerializeObject(mutatorInfo); var jObj = JsonConvert.DeserializeObject <JObject>(asJson); // act factory.Register <TestMutator>("test"); // assert var mutator = factory.GetMutator("test", jObj); Assert.Equal("xx-foo", mutator("xx")); }
public void GetMutator_Flyweight_ReusesMutator() { // arrange var factory = new MutatorFactory(); factory.Register <TestMutator>("test"); var mutatorInfo = new { Prop1 = "foo" }; var asJson = JsonConvert.SerializeObject(mutatorInfo); var jObj = JsonConvert.DeserializeObject <JObject>(asJson); // act var mutator = factory.GetMutator("test", jObj); var mutator2 = factory.GetMutator("test", jObj); // assert Assert.Equal(mutator2, mutator); }