public void ShouldNotSupportGenericWhichViolatesConstraints() { // Arrange var target = new GenericConstructorTarget(typeof(ConstrainedGeneric <>)); // Assert Assert.False(target.SupportsType(typeof(IGeneric <string>))); }
public void ShouldNotSupportType(Type targetType, Type testType) { Output.WriteLine($"Testing target for type { targetType } DOES NOT support { testType }"); // Arrange var target = new GenericConstructorTarget(targetType); //also make sure we get an exception if we try to bind directly var context = GetCompileContext(target, targetType: testType); // Assert Assert.False(target.SupportsType(testType)); Assert.ThrowsAny <Exception>(() => target.Bind(context)); }
public void ShouldSupportTypeIfMappingIsSuccessful(Type targetType, Type testType, Type implementingType = null) { Output.WriteLine($"Testing target for type { targetType } supports { testType }..."); // Arrange var target = new GenericConstructorTarget(targetType); // Act var mapping = target.MapType(testType); // Assert Assert.True(mapping.Success); Assert.Equal(implementingType ?? testType, mapping.Type); Assert.True(target.SupportsType(testType)); }