コード例 #1
0
        public void CanRegisterMultipleTypeMappings()
        {
            TestableRootCompositionContainer root = new TestableRootCompositionContainer();

            root.RegisterTypeMapping<IFoo, Foo>();
            root.RegisterTypeMapping<IBar, Bar>();

            Assert.AreEqual(typeof (Bar), root.GetMappedType<IBar>());
            Assert.AreEqual(typeof (Foo), root.GetMappedType<IFoo>());
        }
コード例 #2
0
        public void CanRegisterTypeMappingViaTypeObjects()
        {
            TestableRootCompositionContainer root = new TestableRootCompositionContainer();
            root.RegisterTypeMapping(typeof (IFoo), typeof (Foo));

            Type mappedType = root.GetMappedType(typeof (IFoo));

            Assert.AreEqual(typeof (Foo), mappedType);
        }
コード例 #3
0
        public void CanRegisterTypeMappingOnRootContainer()
        {
            TestableRootCompositionContainer root = new TestableRootCompositionContainer();

            root.RegisterTypeMapping<IFoo, Foo>();

            Type mappedType = root.GetMappedType<IFoo>();

            Assert.AreEqual(typeof (Foo), mappedType);
        }
コード例 #4
0
        public void RequestingTypeMappingForUnmappedTypeReturnsRequestedType()
        {
            TestableRootCompositionContainer root = new TestableRootCompositionContainer();

            Type mappedType = root.GetMappedType<Foo>();

            Assert.AreEqual(typeof (Foo), mappedType);
        }
コード例 #5
0
        public void ChildContainersCanOverrideParentTypeMapping()
        {
            TestableRootCompositionContainer parent = new TestableRootCompositionContainer();
            CompositionContainer child = parent.Containers.AddNew<CompositionContainer>();

            parent.RegisterTypeMapping<IFoo, Foo>();
            child.RegisterTypeMapping<IFoo, Foo2>();

            Assert.AreEqual(typeof (Foo), parent.GetMappedType<IFoo>());
            Assert.AreEqual(typeof (Foo2), child.GetMappedType<IFoo>());
        }