public void ValidateNullStringToBeNull() { // Given var validator = new StringValidator(null); // When validator.Be(null); // Then Assert.True(true); }
public void ValidateStringToBeValue() { // Given var validator = new StringValidator("string"); // When validator.Be("string"); // Then Assert.True(true); }
public void ValidateStringToBeCaseInsensitiveValue() { // Given var validator = new StringValidator("string"); // When validator.Be("STRING", ignoreCase: true); // Then Assert.True(true); }
public void OverrideMessageFormatterSuccess() { // Given // When TestConfiguration.SetMessageFormatterFor(nameof(TestConfigurationTest.OverrideMessageFormatterSuccess), new MockFormatter()); var validator = new StringValidator("foo"); // use a StringValidator here as one implementation of a ContextValidator var exception = Assert.Throws <XunitException>(() => validator.Be("bar")); // Then Assert.NotNull(exception); Assert.Equal("MockMessage", exception.Message); }
public void OverrideCallerContextSuccess() { // Given // When TestConfiguration.SetCallerContextFor(nameof(TestConfigurationTest.OverrideCallerContextSuccess), new MockContext()); var validator = new StringValidator("foo"); // use a StringValidator here as one implementation of a ContextValidator var exception = Assert.Throws <XunitException>(() => validator.Be("bar")); // Then Assert.NotNull(exception); var rn = Environment.NewLine; Assert.Equal($"{rn}MockContext{rn}is \"foo\"{rn}but was expected to be \"bar\"", exception.Message); }
public void ValidateStringToBeCaseSensitiveValueViolated() { // Given var validator = new StringValidator("string"); // When var exception = Assert.Throws <XunitException>(() => validator.Be("STRING")); // Then Assert.NotNull(exception); var rn = Environment.NewLine; Assert.Equal( $"{rn}validator{rn}is \"string\"{rn}but was expected to be \"STRING\"", exception.UserMessage); }
public void ValidateNullStringToBeValueViolated() { // Given var validator = new StringValidator(null); // When var exception = Assert.Throws <XunitException>(() => validator.Be("other")); // Then Assert.NotNull(exception); var rn = Environment.NewLine; Assert.Equal( $"{rn}validator{rn}is \"\"{rn}but was expected to be \"other\"", exception.UserMessage); }
public void ValidateStringToBeValueViolated() { // Given var validator = new StringValidator("string"); // When var exception = Assert.Throws <XunitException>(() => validator.Be("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 be \"other\"{rn}because that's the bottom line", exception.UserMessage); }