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)); }
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)); }
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)); }
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)); }
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)); }
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)); }