public void Validate_WhenCalled_AssertShouldBeGreaterThanZeroWasCalledOnIntegerValidatorForSearchOptions() { bool searchWithinName = _fixture.Create <bool>(); bool searchWithinMailAddress = _fixture.Create <bool>(); bool searchWithinPrimaryPhone = _fixture.Create <bool>(); bool searchWithinSecondaryPhone = _fixture.Create <bool>(); bool searchWithinHomePhone = _fixture.Create <bool>(); bool searchWithinMobilePhone = _fixture.Create <bool>(); IGetMatchingContactCollectionQuery sut = CreateSut(searchWithinName: searchWithinName, searchWithinMailAddress: searchWithinMailAddress, searchWithinPrimaryPhone: searchWithinPrimaryPhone, searchWithinSecondaryPhone: searchWithinSecondaryPhone, searchWithinHomePhone: searchWithinHomePhone, searchWithinMobilePhone: searchWithinMobilePhone); sut.Validate(_validatorMockContext.ValidatorMock.Object); int searchOptions = (searchWithinName ? (int)SearchOptions.Name : 0) + (searchWithinMailAddress ? (int)SearchOptions.MailAddress : 0) + (searchWithinPrimaryPhone ? (int)SearchOptions.PrimaryPhone : 0) + (searchWithinSecondaryPhone ? (int)SearchOptions.SecondaryPhone : 0) + (searchWithinHomePhone ? (int)SearchOptions.HomePhone : 0) + (searchWithinMobilePhone ? (int)SearchOptions.MobilePhone : 0); _validatorMockContext.IntegerValidatorMock.Verify(m => m.ShouldBeGreaterThanZero( It.Is <int>(value => value == searchOptions), It.Is <Type>(value => value == sut.GetType()), It.Is <string>(value => string.CompareOrdinal(value, "SearchOptions") == 0)), Times.Once); }
public void Validate_WhenCalled_ReturnsValidator() { IGetMatchingContactCollectionQuery sut = CreateSut(); IValidator result = sut.Validate(_validatorMockContext.ValidatorMock.Object); Assert.That(result, Is.EqualTo(_validatorMockContext.ValidatorMock.Object)); }
public void Validate_WhenCalled_AssertShouldNotBeNullOrWhiteSpaceWasCalledOnStringValidatorForSearchFor() { string searchFor = _fixture.Create <string>(); IGetMatchingContactCollectionQuery sut = CreateSut(searchFor); sut.Validate(_validatorMockContext.ValidatorMock.Object); _validatorMockContext.StringValidatorMock.Verify(m => m.ShouldNotBeNullOrWhiteSpace( It.Is <string>(value => string.CompareOrdinal(value, searchFor) == 0), It.Is <Type>(value => value == sut.GetType()), It.Is <string>(value => string.CompareOrdinal(value, "SearchFor") == 0)), Times.Once); }
public void Validate_WhenValidatorIsNull_ThrowsArgumentNullException() { IGetMatchingContactCollectionQuery sut = CreateSut(); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.Validate(null)); Assert.That(result.ParamName, Is.EqualTo("validator")); }