public void Validate_WhenCalled_AssertShouldNotBeNullOrWhiteSpaceWasCalledOnStringValidator() { string countryCode = _fixture.Create <string>(); ICountryIdentificationCommand sut = CreateSut(countryCode); sut.Validate(_validatorMockContext.ValidatorMock.Object, _contactRepositoryMock.Object); _validatorMockContext.StringValidatorMock.Verify(m => m.ShouldNotBeNullOrWhiteSpace( It.Is <string>(value => string.CompareOrdinal(value, countryCode.ToUpper()) == 0), It.Is <Type>(type => type == sut.GetType()), It.Is <string>(field => string.CompareOrdinal(field, "CountryCode") == 0)), Times.Once()); }
public void Validate_WhenCalled_AssertShouldHaveMinLengthWasCalledOnStringValidatorForCity() { string city = _fixture.Create <string>(); ICountryIdentificationCommand sut = CreateSut(city: city); sut.Validate(_validatorMockContext.ValidatorMock.Object, _contactRepositoryMock.Object); _validatorMockContext.StringValidatorMock.Verify(m => m.ShouldHaveMinLength( It.Is <string>(value => string.CompareOrdinal(value, city) == 0), It.Is <int>(value => value == 1), It.Is <Type>(type => type == sut.GetType()), It.Is <string>(field => string.CompareOrdinal(field, "City") == 0), It.Is <bool>(value => value == false)), Times.Once()); }
public void Validate_WhenCalled_AssertShouldMatchPatternWasCalledOnStringValidator() { string countryCode = _fixture.Create <string>(); ICountryIdentificationCommand sut = CreateSut(countryCode); sut.Validate(_validatorMockContext.ValidatorMock.Object, _contactRepositoryMock.Object); _validatorMockContext.StringValidatorMock.Verify(m => m.ShouldMatchPattern( It.Is <string>(value => string.CompareOrdinal(value, countryCode.ToUpper()) == 0), It.Is <Regex>(value => value != null && string.CompareOrdinal(value.ToString(), RegexTestHelper.CountryCodeRegexPattern) == 0), It.Is <Type>(type => type == sut.GetType()), It.Is <string>(field => string.CompareOrdinal(field, "CountryCode") == 0), It.Is <bool>(value => value == false)), Times.Once()); }