コード例 #1
0
        public void TestNoResult()
        {
            var  types           = new[] { typeof(int) };
            Type abstractionType = typeof(long);
            var  collection      = new ImplementationTypesCollection(new TestConfiguration(types), helper);

            helper.ExpectIsIgnoredImplementation(types[0], false);
            helper.ExpectTryGetImplementation(abstractionType, types[0], null);

            helper.ExpectIsIgnoredImplementation(abstractionType, true);
            CollectionAssert.IsEmpty(collection.GetImplementationTypes(abstractionType));
        }
コード例 #2
0
        public void TestNoResult()
        {
            var types           = new[] { typeof(int) };
            var abstractionType = typeof(long);

            helperMock.Setup(x => x.IsIgnoredImplementation(types[0])).Returns(false);
            helperMock.Setup(x => x.TryGetImplementation(abstractionType, types[0], It.IsAny <Func <Type, IEnumerable <Type> > >())).Returns((Type)null);
            helperMock.Setup(x => x.IsIgnoredImplementation(abstractionType)).Returns(true);

            var collection = new ImplementationTypesCollection(types, helperMock.Object);

            CollectionAssert.IsEmpty(collection.GetImplementationTypes(abstractionType));
        }
コード例 #3
0
        public void TestGetGenericInConfig()
        {
            var types           = new[] { typeof(I1 <>) };
            var abstractionType = typeof(I1 <int>);
            var typeImpl        = abstractionType;

            helperMock.Setup(x => x.IsIgnoredImplementation(types[0])).Returns(false);
            helperMock.Setup(x => x.TryGetImplementation(abstractionType, types[0], It.IsAny <Func <Type, IEnumerable <Type> > >())).Returns(typeImpl);

            var collection = new ImplementationTypesCollection(types, helperMock.Object);

            CollectionAssert.AreEquivalent(new[] { typeImpl }, collection.GetImplementationTypes(abstractionType));
        }
コード例 #4
0
        public void TestGetGenericInCofig()
        {
            var  types           = new[] { typeof(I1 <>) };
            Type abstractionType = typeof(I1 <int>);
            Type typeImpl        = abstractionType;
            var  collection      = new ImplementationTypesCollection(new TestConfiguration(types), helper);

            helper.ExpectIsIgnoredImplementation(types[0], false);
            helper.ExpectTryGetImplementation(abstractionType, types[0], typeImpl);

            CollectionAssert.AreEquivalent(new[] { typeImpl },
                                           collection.GetImplementationTypes(abstractionType));
        }
コード例 #5
0
        public void TestGet()
        {
            var  types           = new[] { typeof(int), typeof(long) };
            Type abstractionType = typeof(long);
            Type typeImpl        = typeof(long);
            var  collection      = new ImplementationTypesCollection(new TestConfiguration(types), helper);

            helper.ExpectIsIgnoredImplementation(types[0], false);
            helper.ExpectTryGetImplementation(abstractionType, types[0], null);

            helper.ExpectIsIgnoredImplementation(types[1], false);
            helper.ExpectTryGetImplementation(abstractionType, types[1], typeImpl);

            CollectionAssert.AreEquivalent(new[] { typeImpl },
                                           collection.GetImplementationTypes(abstractionType));
        }
コード例 #6
0
        public void TestGetGeneric()
        {
            var  types           = new[] { typeof(int) };
            Type abstractionType = typeof(I1 <int>);
            Type typeImpl        = typeof(Guid);
            var  collection      = new ImplementationTypesCollection(new TestConfiguration(types), helper);

            helper.ExpectIsIgnoredImplementation(types[0], false);
            helper.ExpectTryGetImplementation(abstractionType, types[0], null);

            Type definition = abstractionType.GetGenericTypeDefinition();

            helper.ExpectIsIgnoredImplementation(definition, false);
            helper.ExpectTryGetImplementation(abstractionType, definition, typeImpl);

            CollectionAssert.AreEquivalent(new[] { typeImpl },
                                           collection.GetImplementationTypes(abstractionType));
        }