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 ShouldNotSupportGenericWhichViolatesConstraints()
        {
            // Arrange
            var target = new GenericConstructorTarget(typeof(ConstrainedGeneric <>));

            // Assert
            Assert.False(target.SupportsType(typeof(IGeneric <string>)));
        }
        public void ShouldMapMultipleParametersThroughNonGenericBase()
        {
            var target = new GenericConstructorTarget(typeof(DoubleGeneric <,>));

            var result = target.MapType(typeof(ISingleGeneric <IDoubleGeneric <int, float> >));

            Assert.True(result.Success);
            Assert.True(result.IsFullyBound);

            Assert.Equal(typeof(DoubleGeneric <int, float>), result.Type);
        }
        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));
        }