Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
        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();
            }
        }