Beispiel #1
0
        public void ValidateReferenceTypeToBeOfType()
        {
            // Given
            var validator = new ReferenceTypeValidator <object>(42);

            // When
            validator.BeOfType <Int32>();

            // Then
            Assert.True(true);
        }
Beispiel #2
0
        public void ValidateReferenceTypeToBeNull()
        {
            // Given
            var validator = new ReferenceTypeValidator <object>(null);

            // When
            validator.BeNull();

            // Then
            Assert.True(true);
        }
Beispiel #3
0
        public void ValidateReferenceTypeToBeOfTypeViolated()
        {
            // Given
            var validator = new ReferenceTypeValidator <object>(42);

            // When
            var exception = Assert.Throws <XunitException>(() => validator.BeOfType <String>());

            // Then
            Assert.NotNull(exception);
            var rn = Environment.NewLine;

            Assert.Equal(
                $"{rn}validator{rn}is \"Int32\"{rn}but was expected to be of type \"String\"",
                exception.UserMessage);
        }
Beispiel #4
0
        public void ValidateReferenceTypeToBeNullWithReasonViolated()
        {
            // Given
            var validator = new ReferenceTypeValidator <object>(new object());

            // When
            var exception = Assert.Throws <XunitException>(() => validator.BeNull("that's the bottom line"));

            // Then
            Assert.NotNull(exception);
            var rn = Environment.NewLine;

            Assert.Equal(
                $"{rn}validator{rn}is \"System.Object\"{rn}but was expected to be null{rn}because that's the bottom line",
                exception.UserMessage);
        }