public void NotEmpty_PropertyIsEmpty_Fails() { // Arrange var testClass = new VerificationTestClass { StringProperty = string.Empty }; StringVerifier <VerificationTestClass> sut = CreateStringVerifier(testClass); // Act & Assert Assert.Throws <Exception>(() => sut.NotEmpty()); }
public void Regex_PropertyDoesntMatchPattern_Fails() { // Arrange var testClass = new VerificationTestClass { StringProperty = "blabla" }; StringVerifier <VerificationTestClass> sut = CreateStringVerifier(testClass); // Act & Assert Assert.Throws <Exception>(() => sut.Regex(@"\d+")); }
public void Max_PropertyHigherThanMax_Fails() { // Arrange var testClass = new VerificationTestClass { IntProperty = 5 }; IntVerifier <VerificationTestClass> sut = CreateIntVerifier(testClass); // Act & Assert Assert.Throws <Exception>(() => sut.Max(1)); }
public void Min_PropertyLowerThanMin_Fails() { // Arrange var testClass = new VerificationTestClass { IntProperty = -1 }; IntVerifier <VerificationTestClass> sut = CreateIntVerifier(testClass); // Act & Assert Assert.Throws <Exception>(() => sut.Min(0)); }
public void Regex_PropertyMatchesPattern_Passes() { // Arrange var testClass = new VerificationTestClass { StringProperty = "123" }; StringVerifier <VerificationTestClass> sut = CreateStringVerifier(testClass); // Act Exception exception = Record.Exception(() => sut.Regex(@"\d+")); // Assert Assert.Null(exception); }
public void NotEmpty_PropertyIsNull_Passes() { // Arrange var testClass = new VerificationTestClass { StringProperty = null }; StringVerifier <VerificationTestClass> sut = CreateStringVerifier(testClass); // Act Exception exception = Record.Exception(() => sut.NotEmpty()); // Assert Assert.Null(exception); }
public void Max_PropertyLowerThanMax_Passes() { // Arrange var testClass = new VerificationTestClass { IntProperty = 5 }; IntVerifier <VerificationTestClass> sut = CreateIntVerifier(testClass); // Act Exception exception = Record.Exception(() => sut.Max(10)); // Assert Assert.Null(exception); }
private static StringVerifier <VerificationTestClass> CreateStringVerifier(VerificationTestClass instance) { return(new StringVerifier <VerificationTestClass>(instance, x => x.StringProperty)); }
private static IntVerifier <VerificationTestClass> CreateIntVerifier(VerificationTestClass instance) { return(new IntVerifier <VerificationTestClass>(instance, x => x.IntProperty)); }