public void ShouldBindIfFullyBoundOrErrorIfNot(Type targetType, Type testType, Type implementingType = null) { // similar test to above, but this checks the interaction between SupportsType and Bind - // in that some types are supported, but, when bound, will yield an exception because the mapping // cannot be fully bound. Output.WriteLine($"Testing target bound for type { targetType } supports { implementingType ?? testType }..."); // Arrange var target = new GenericConstructorTarget(targetType); var mapping = target.MapType(testType); // Assert (with some 'Act' thrown in too :$) Assert.True(mapping.Success); var context = GetCompileContext(target, targetType: testType); if (mapping.IsFullyBound) { var boundTarget = target.Bind(context); Assert.NotNull(boundTarget); } else { //not specifying the type of exception we want - only that it should throw one. Assert.ThrowsAny <Exception>(() => target.Bind(context)); } }
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)); }