public void NestedResolveMustUseMapFromOuterScope(MapSource sourceType) { using (GivenAMap(sourceType, MapWith.DerivedA)) { INamedClass instance = null; using (GivenAMap(sourceType, MapWith.DerivedB)) { instance = WhenInstanceIsResolved(sourceType); ThenTheInstanceMustBe(instance, MapWith.DerivedA); } instance = WhenInstanceIsResolved(sourceType); ThenTheInstanceMustBe(instance, MapWith.DerivedA); } }
public void IsolatedMapsMustNotAffectEachOther(MapSource sourceType) { INamedClass instance = null; using (GivenAMap(source: sourceType, target: MapWith.DerivedA)) { instance = WhenInstanceIsResolved(sourceType); ThenTheInstanceMustBe(instance, MapWith.DerivedA); } using (GivenAMap(source: sourceType, target: MapWith.DerivedB)) { instance = WhenInstanceIsResolved(sourceType); ThenTheInstanceMustBe(instance, MapWith.DerivedB); } }
private void ThenTheInstanceMustBe(INamedClass instance, MapWith expected = MapWith.DerivedA) { Assert.IsNotNull(instance); switch (expected) { case MapWith.DerivedA: Assert.IsTrue(instance.GetType() == typeof(DerivedA)); break; case MapWith.DerivedB: Assert.IsTrue(instance.GetType() == typeof(DerivedB)); break; default: throw new NotImplementedException(); } }