コード例 #1
0
        public void ShouldNotSupportGenericWhichViolatesConstraints()
        {
            // Arrange
            var target = new GenericConstructorTarget(typeof(ConstrainedGeneric <>));

            // Assert
            Assert.False(target.SupportsType(typeof(IGeneric <string>)));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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));
        }