Exemplo n.º 1
0
        public void ValidateReferenceTypeNotToBeOfType()
        {
            // Given
            var validator = new ReferenceTypeInverseValidator <object>(42);

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

            // Then
            Assert.True(true);
        }
Exemplo n.º 2
0
        public void ValidateReferenceTypeNotToBeNull()
        {
            // Given
            var validator = new ReferenceTypeInverseValidator <object>(new object());

            // When
            validator.BeNull();

            // Then
            Assert.True(true);
        }
Exemplo n.º 3
0
        public void ValidateReferenceTypeNotToBeOfTypeViolated()
        {
            // Given
            var validator = new ReferenceTypeInverseValidator <object>(42);

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

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

            Assert.Equal(
                $"{rn}validator{rn}is \"Int32\"{rn}but was expected not to be of that type",
                exception.UserMessage);
        }
Exemplo n.º 4
0
        public void ValidateReferenceTypeNotToBeNullWithReasonViolated()
        {
            // Given
            var validator = new ReferenceTypeInverseValidator <object>(null);

            // 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 null{rn}but was expected not to be null{rn}because that's the bottom line",
                exception.UserMessage);
        }