Esempio n. 1
0
        public void Validate_WhenCalled_AssertShouldHaveMaxLengthWasCalledOnStringValidator()
        {
            string postalCode = _fixture.Create <string>();
            IPostalCodeIdentificationQuery sut = CreateSut(postalCode);

            sut.Validate(_validatorMockContext.ValidatorMock.Object, _contactRepositoryMock.Object);

            _validatorMockContext.StringValidatorMock.Verify(m => m.ShouldHaveMaxLength(
                                                                 It.Is <string>(value => string.CompareOrdinal(value, postalCode) == 0),
                                                                 It.Is <int>(value => value == 16),
                                                                 It.Is <Type>(type => type == sut.GetType()),
                                                                 It.Is <string>(field => string.CompareOrdinal(field, "PostalCode") == 0),
                                                                 It.Is <bool>(value => value == false)),
                                                             Times.Once());
        }
Esempio n. 2
0
        public void Validate_WhenCalled_AssertShouldMatchPatternWasCalledOnStringValidator()
        {
            string postalCode = _fixture.Create <string>();
            IPostalCodeIdentificationQuery sut = CreateSut(postalCode);

            sut.Validate(_validatorMockContext.ValidatorMock.Object, _contactRepositoryMock.Object);

            _validatorMockContext.StringValidatorMock.Verify(m => m.ShouldMatchPattern(
                                                                 It.Is <string>(value => string.CompareOrdinal(value, postalCode) == 0),
                                                                 It.Is <Regex>(value => value != null && string.CompareOrdinal(value.ToString(), RegexTestHelper.PostalCodeRegexPattern) == 0),
                                                                 It.Is <Type>(type => type == sut.GetType()),
                                                                 It.Is <string>(field => string.CompareOrdinal(field, "PostalCode") == 0),
                                                                 It.Is <bool>(value => value == false)),
                                                             Times.Once());
        }