コード例 #1
0
        public void ValidateStringEndWithValue()
        {
            // Given
            var validator = new StringValidator("string");

            // When
            validator.EndWith("ing");

            // Then
            Assert.True(true);
        }
コード例 #2
0
        public void ValidateNullStringEndWithNullViolated()
        {
            // Given
            var validator = new StringValidator(null);

            // When
            var exception = Assert.Throws <XunitException>(() => validator.EndWith(null));

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

            Assert.Equal(
                $"{rn}validator{rn}is \"\"{rn}but was expected to end with \"\"",
                exception.UserMessage);
        }
コード例 #3
0
        public void ValidateStringEndWithValueViolated()
        {
            // Given
            var validator = new StringValidator("string");

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

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

            Assert.Equal(
                $"{rn}validator{rn}is \"string\"{rn}but was expected to end with \"other\"{rn}because that's the bottom line",
                exception.UserMessage);
        }