Example #1
0
            public void When_unrelated_to_open_generic_type_and_asserting_not_assignable_it_should_succeed()
            {
                // Arrange
                var someObject = new DummyImplementingClass();

                // Act / Assert
                someObject.Should().NotBeAssignableTo(typeof(System.Collections.Generic.IList <>), "because we want to test the failure {0}", "message");
            }
Example #2
0
            public void When_an_implemented_interface_type_instance_it_should_succeed()
            {
                // Arrange
                var someObject = new DummyImplementingClass();

                // Act / Assert
                someObject.Should().BeAssignableTo(typeof(IDisposable));
            }
Example #3
0
            public void When_an_unrelated_type_instance_and_asserting_not_assignable_it_should_succeed()
            {
                // Arrange
                var someObject = new DummyImplementingClass();

                // Act / Assert
                someObject.Should().NotBeAssignableTo(typeof(DateTime), "because we want to test the failure {0}", "message");
            }
Example #4
0
            public void When_an_unrelated_type_and_asserting_not_assignable_it_should_succeed()
            {
                // Arrange
                var someObject = new DummyImplementingClass();

                // Act / Assert
                someObject.Should().NotBeAssignableTo <DateTime>();
            }
Example #5
0
            public void When_its_base_type_instance_it_should_succeed()
            {
                // Arrange
                var someObject = new DummyImplementingClass();

                // Act / Assert
                someObject.Should().BeAssignableTo(typeof(DummyBaseClass));
            }
Example #6
0
            public void When_its_own_type_it_should_succeed()
            {
                // Arrange
                var someObject = new DummyImplementingClass();

                // Act / Assert
                someObject.Should().BeAssignableTo <DummyImplementingClass>();
            }
Example #7
0
            public void When_an_implemented_interface_type_instance_and_asserting_not_assignable_it_should_fail_with_a_useful_message()
            {
                // Arrange
                var    someObject = new DummyImplementingClass();
                Action act        = () => someObject.Should().NotBeAssignableTo(typeof(IDisposable), "because we want to test the failure {0}", "message");

                // Act / Assert
                act.Should().Throw <XunitException>()
                .WithMessage($"*not be assignable to {typeof(IDisposable)}*failure message*{typeof(DummyImplementingClass)} is*");
            }
Example #8
0
            public void When_unrelated_to_open_generic_type_it_should_fail_with_a_descriptive_message()
            {
                // Arrange
                var    someObject = new DummyImplementingClass();
                Action act        = () => someObject.Should().BeAssignableTo(typeof(System.Collections.Generic.IList <>), "because we want to test the failure {0}", "message");

                // Act / Assert
                act.Should().Throw <XunitException>()
                .WithMessage($"*assignable to {typeof(System.Collections.Generic.IList<>)}*failure message*{typeof(DummyImplementingClass)} is not*");
            }
Example #9
0
            public void When_an_unrelated_type_it_should_fail_with_a_descriptive_message()
            {
                // Arrange
                var    someObject = new DummyImplementingClass();
                Action act        = () => someObject.Should().BeAssignableTo <DateTime>("because we want to test the failure {0}", "message");

                // Act / Assert
                act.Should().Throw <XunitException>()
                .WithMessage($"*assignable to {typeof(DateTime)}*failure message*{typeof(DummyImplementingClass)} is not*");
            }
Example #10
0
            public void When_object_type_is_a_subclass_of_the_expected_type_it_should_fail()
            {
                // Arrange
                var someObject = new DummyImplementingClass();

                // Act
                Action act = () => someObject.Should().BeOfType <DummyBaseClass>();

                // Assert
                act.Should().Throw <XunitException>().WithMessage(
                    "Expected type to be FluentAssertions*DummyBaseClass, but found FluentAssertions*DummyImplementingClass.");
            }