コード例 #1
0
        public void Validate_WhenCalled_ReturnsValidator()
        {
            IContactAccountDataCommand sut = CreateSut();

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

            Assert.That(result, Is.SameAs(_validatorMockContext.ValidatorMock.Object));
        }
コード例 #2
0
        public void Validate_WhenCalled_AssertShouldHaveMaxLengthWasCalledOnStringValidatorForMailAddress()
        {
            string mailAddress             = _fixture.Create <string>();
            IContactAccountDataCommand sut = CreateSut(mailAddress);

            sut.Validate(_validatorMockContext.ValidatorMock.Object, _accountingRepositoryMock.Object, _commonRepositoryMock.Object);

            _validatorMockContext.StringValidatorMock.Verify(m => m.ShouldHaveMaxLength(
                                                                 It.Is <string>(value => string.CompareOrdinal(value, mailAddress) == 0),
                                                                 It.Is <int>(value => value == 256),
                                                                 It.Is <Type>(value => value == sut.GetType()),
                                                                 It.Is <string>(value => string.CompareOrdinal(value, "MailAddress") == 0),
                                                                 It.Is <bool>(value => value)),
                                                             Times.Once);
        }
コード例 #3
0
        public void Validate_WhenCalled_AssertShouldBeKnownValueWasCalledOnObjectValidatorWithPaymentTermNumber()
        {
            int paymentTermNumber          = _fixture.Create <int>();
            IContactAccountDataCommand sut = CreateSut(paymentTermNumber: paymentTermNumber);

            sut.Validate(_validatorMockContext.ValidatorMock.Object, _accountingRepositoryMock.Object, _commonRepositoryMock.Object);

            _validatorMockContext.ObjectValidatorMock.Verify(m => m.ShouldBeKnownValue(
                                                                 It.Is <int>(value => value == paymentTermNumber),
                                                                 It.IsNotNull <Func <int, Task <bool> > >(),
                                                                 It.Is <Type>(type => type == sut.GetType()),
                                                                 It.Is <string>(field => String.CompareOrdinal(field, "PaymentTermNumber") == 0),
                                                                 It.Is <bool>(allowNull => allowNull == false)),
                                                             Times.Once());
        }
コード例 #4
0
        public void Validate_WhenCalled_AssertShouldBeBetweenWasCalledOnIntegerValidatorWithPaymentTermNumber()
        {
            int paymentTermNumber          = _fixture.Create <int>();
            IContactAccountDataCommand sut = CreateSut(paymentTermNumber: paymentTermNumber);

            sut.Validate(_validatorMockContext.ValidatorMock.Object, _accountingRepositoryMock.Object, _commonRepositoryMock.Object);

            _validatorMockContext.IntegerValidatorMock.Verify(m => m.ShouldBeBetween(
                                                                  It.Is <int>(value => value == paymentTermNumber),
                                                                  It.Is <int>(minValue => minValue == 1),
                                                                  It.Is <int>(maxValue => maxValue == 99),
                                                                  It.Is <Type>(type => type == sut.GetType()),
                                                                  It.Is <string>(field => String.CompareOrdinal(field, "PaymentTermNumber") == 0)),
                                                              Times.Once());
        }
コード例 #5
0
        public void Validate_WhenCalled_AssertShouldMatchPatternWasCalledOnStringValidatorForSecondaryPhone()
        {
            string secondaryPhone          = _fixture.Create <string>();
            IContactAccountDataCommand sut = CreateSut(secondaryPhone: secondaryPhone);

            sut.Validate(_validatorMockContext.ValidatorMock.Object, _accountingRepositoryMock.Object, _commonRepositoryMock.Object);

            _validatorMockContext.StringValidatorMock.Verify(m => m.ShouldMatchPattern(
                                                                 It.Is <string>(value => string.CompareOrdinal(value, secondaryPhone) == 0),
                                                                 It.Is <Regex>(value => string.CompareOrdinal(value.ToString(), RegexTestHelper.PhoneNumberRegexPattern) == 0),
                                                                 It.Is <Type>(value => value == sut.GetType()),
                                                                 It.Is <string>(value => string.CompareOrdinal(value, "SecondaryPhone") == 0),
                                                                 It.Is <bool>(value => value)),
                                                             Times.Once);
        }
コード例 #6
0
        public void Validate_WhenCalled_AssertShouldHaveMinLengthWasCalledOnStringValidatorForSecondaryPhone()
        {
            string secondaryPhone          = _fixture.Create <string>();
            IContactAccountDataCommand sut = CreateSut(secondaryPhone: secondaryPhone);

            sut.Validate(_validatorMockContext.ValidatorMock.Object, _accountingRepositoryMock.Object, _commonRepositoryMock.Object);

            _validatorMockContext.StringValidatorMock.Verify(m => m.ShouldHaveMinLength(
                                                                 It.Is <string>(value => string.CompareOrdinal(value, secondaryPhone) == 0),
                                                                 It.Is <int>(value => value == 1),
                                                                 It.Is <Type>(value => value == sut.GetType()),
                                                                 It.Is <string>(value => string.CompareOrdinal(value, "SecondaryPhone") == 0),
                                                                 It.Is <bool>(value => value)),
                                                             Times.Once);
        }
コード例 #7
0
        public void Validate_WhenCommonRepositoryIsNull_ThrowsArgumentNullException()
        {
            IContactAccountDataCommand sut = CreateSut();

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

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