public void RunValidation(ExpectedValidationResult expectedValidationResult, String targetPropertyName, Object sut, String expectedMessage, Int32 expectedErrorsCount = 1) { // act var validationResult = _modelRulesInvoker.CheckAllValidationRulesForProperty(sut, targetPropertyName); // Assert if (expectedValidationResult == ExpectedValidationResult.Pass) { const Int32 ExpectedErrorsCount = 0; Assert.True(validationResult.IsValid, "Expect validation to pass."); Assert.True(ExpectedErrorsCount == validationResult.ValidationErrors.Count, "Unexpected number of validation errors."); } else { Assert.False(validationResult.IsValid, "Expect validation to fail."); Assert.True(expectedErrorsCount == validationResult.ValidationErrors.Count, "Unexpected number of validation errors."); Assert.True(expectedMessage == validationResult.ValidationErrors[0].Value.ErrorMessage, "Incorrect error message"); Assert.True(targetPropertyName == validationResult.ValidationErrors[0].Key, "Incorrect member name"); } }
public void WhenURLAndLocalHostPatternEnsureCorrectTestsResults(String targetValue, String expectedMessage, ExpectedValidationResult expectedValidationResult) { // arrange _sut.LocalHomePage = targetValue; const String TargetPropertyName = nameof(_sut.LocalHomePage); String ExpectedMessage = expectedMessage; // act assert base.RunValidation(expectedValidationResult, TargetPropertyName, _sut, ExpectedMessage); }
public void WhenCustomPatternEnsureCorrectTestsResults(String targetValue, String expectedMessage, ExpectedValidationResult expectedValidationResult) { // arrange _sut.UKBankSortCode = targetValue; const String TargetPropertyName = nameof(_sut.UKBankSortCode); String ExpectedMessage = expectedMessage; // act assert base.RunValidation(expectedValidationResult, TargetPropertyName, _sut, ExpectedMessage); }
public void WhenRuleSetIsProvidedEnsureCorrectTestsAreRun(String value, String ruleSet, String expectedMessage, ExpectedValidationResult expectedValidationResult) { // arrange _sut.ActiveRuleSet = ruleSet; _sut.LastName = value; const String TargetPropertyName = nameof(_sut.LastName); // act assert base.RunValidation(expectedValidationResult, TargetPropertyName, _sut, expectedMessage); }
public void WhenTargetIsSupposedToBeGreatThanEnsureCorrectTestsResults(Int32 targetValue, Int32 otherPropertyValue, String expectedMessage, ExpectedValidationResult expectedValidationResult) { // arrange _sut.Donation = targetValue; _sut.DonationConfirm = otherPropertyValue; const String TargetPropertyName = nameof(_sut.Donation); String ExpectedMessage = expectedMessage; // act assert base.RunValidation(expectedValidationResult, TargetPropertyName, _sut, ExpectedMessage); }
public void WhenTargetIsSupposedToBeNotEqualEnsureCorrectTestsResults(String targetValue, String otherPropertyValue, String expectedMessage, ExpectedValidationResult expectedValidationResult) { // arrange _sut.Password = targetValue; _sut.PasswordConfirm = otherPropertyValue; const String TargetPropertyName = nameof(_sut.Password); String ExpectedMessage = expectedMessage; // act assert base.RunValidation(expectedValidationResult, TargetPropertyName, _sut, ExpectedMessage); }
public void WhenValidatingVeryWeakPasswordEnsureCorrectTestsResults(String value, String expectedMessage, ExpectedValidationResult expectedValidationResult) { // arrange _sut.PasswordFour = value; const String TargetPropertyName = nameof(_sut.PasswordFour); String ExpectedMessage = expectedMessage; // act assert base.RunValidation(expectedValidationResult, TargetPropertyName, _sut, ExpectedMessage); }
public void StringValueMustEqualEnsureCorrectTestsResults(String targetValue, String expectedMessage, ExpectedValidationResult expectedValidationResult) { // arrange _sut.EmailConfirm = targetValue; const String TargetPropertyName = nameof(_sut.EmailConfirm); String ExpectedMessage = expectedMessage; // act assert base.RunValidation(expectedValidationResult, TargetPropertyName, _sut, ExpectedMessage); }
public void IntegerValueEnsureCorrectTestsResults(Int32 targetValue, String expectedMessage, ExpectedValidationResult expectedValidationResult) { // arrange _sut.Donation = targetValue; const String TargetPropertyName = nameof(_sut.Donation); String ExpectedMessage = expectedMessage; // act assert base.RunValidation(expectedValidationResult, TargetPropertyName, _sut, ExpectedMessage); }
public void DoubleValueEnsureCorrectTestsResults(Double targetValue, String expectedMessage, ExpectedValidationResult expectedValidationResult) { // arrange _sut.NewStock = targetValue; const String TargetPropertyName = nameof(_sut.NewStock); String ExpectedMessage = expectedMessage; // act assert base.RunValidation(expectedValidationResult, TargetPropertyName, _sut, ExpectedMessage); }
public void ConvertToTypeDecimalEnsureCorrectTestsResults(String targetValue, String expectedMessage, ExpectedValidationResult expectedValidationResult) { // arrange _sut.Cost = Convert.ToDecimal(targetValue); const String TargetPropertyName = nameof(_sut.Cost); String ExpectedMessage = expectedMessage; // act assert base.RunValidation(expectedValidationResult, TargetPropertyName, _sut, ExpectedMessage); }
public void WhenStateAbbreviationRequiredNoEnsureCorrectTestsResults(String targetValue, String expectedMessage, ExpectedValidationResult expectedValidationResult) { // arrange _sut.StateNotRequired = targetValue; const String TargetPropertyName = nameof(_sut.StateNotRequired); String ExpectedMessage = expectedMessage; // act assert base.RunValidation(expectedValidationResult, TargetPropertyName, _sut, ExpectedMessage); }
public void ConvertToTypeDateInclusiveEnsureCorrectTestsResults(String targetValue, String expectedMessage, ExpectedValidationResult expectedValidationResult) { // arrange if (targetValue == null) { _sut.HireDate = null; } else { _sut.HireDate = Convert.ToDateTime(targetValue); } const String TargetPropertyName = nameof(_sut.HireDate); String ExpectedMessage = expectedMessage; // act assert base.RunValidation(expectedValidationResult, TargetPropertyName, _sut, ExpectedMessage); }