public void Validate_WhenCalled_ReturnsValidator()
        {
            ICountryIdentificationCommand sut = CreateSut();

            IValidator result = sut.Validate(_validatorMockContext.ValidatorMock.Object, _contactRepositoryMock.Object);

            Assert.That(result, Is.EqualTo(_validatorMockContext.ValidatorMock.Object));
        }
        public void Validate_WhenCalled_AssertShouldNotBeNullOrWhiteSpaceWasCalledOnStringValidatorForCity()
        {
            string city = _fixture.Create <string>();
            ICountryIdentificationCommand sut = CreateSut(city: city);

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

            _validatorMockContext.StringValidatorMock.Verify(m => m.ShouldNotBeNullOrWhiteSpace(
                                                                 It.Is <string>(value => string.CompareOrdinal(value, city) == 0),
                                                                 It.Is <Type>(type => type == sut.GetType()),
                                                                 It.Is <string>(field => string.CompareOrdinal(field, "City") == 0)),
                                                             Times.Once());
        }
        public void Validate_WhenCalled_AssertShouldHaveMaxLengthWasCalledOnStringValidatorForState()
        {
            string state = _fixture.Create <string>();
            ICountryIdentificationCommand sut = CreateSut(state: state);

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

            _validatorMockContext.StringValidatorMock.Verify(m => m.ShouldHaveMaxLength(
                                                                 It.Is <string>(value => string.CompareOrdinal(value, state) == 0),
                                                                 It.Is <int>(value => value == 256),
                                                                 It.Is <Type>(type => type == sut.GetType()),
                                                                 It.Is <string>(field => string.CompareOrdinal(field, "State") == 0),
                                                                 It.Is <bool>(value => value)),
                                                             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());
        }
        public void Validate_WhenContactRepositoryIsNull_ThrowsArgumentNullException()
        {
            ICountryIdentificationCommand sut = CreateSut();

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.Validate(_validatorMockContext.ValidatorMock.Object, null));

            Assert.That(result.ParamName, Is.EqualTo("contactRepository"));
        }