Ejemplo n.º 1
0
        public void Validate_WhenCalled_ReturnsValidator()
        {
            IAccountIdentificationCommand sut = CreateSut();

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

            Assert.That(result, Is.SameAs(_validatorMockContext.ValidatorMock.Object));
        }
Ejemplo n.º 2
0
        public void Validate_WhenCalled_AssertShouldNotBeNullOrWhiteSpaceWasCalledOnStringValidatorWithAccountNumber()
        {
            string accountNumber = _fixture.Create <string>().ToUpper();
            IAccountIdentificationCommand sut = CreateSut(accountNumber: accountNumber);

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

            _validatorMockContext.StringValidatorMock.Verify(m => m.ShouldNotBeNullOrWhiteSpace(
                                                                 It.Is <string>(value => value == accountNumber),
                                                                 It.Is <Type>(type => type == sut.GetType()),
                                                                 It.Is <string>(field => string.CompareOrdinal(field, "AccountNumber") == 0)),
                                                             Times.Once);
        }
Ejemplo n.º 3
0
        public void Validate_WhenCalled_AssertShouldBeKnownValueWasCalledOnObjectValidatorWithAccountingNumber()
        {
            int accountingNumber = _fixture.Create <int>();
            IAccountIdentificationCommand sut = CreateSut(accountingNumber);

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

            _validatorMockContext.ObjectValidatorMock.Verify(m => m.ShouldBeKnownValue(
                                                                 It.Is <int>(value => value == accountingNumber),
                                                                 It.IsNotNull <Func <int, Task <bool> > >(),
                                                                 It.Is <Type>(type => type == sut.GetType()),
                                                                 It.Is <string>(field => string.CompareOrdinal(field, "AccountingNumber") == 0),
                                                                 It.Is <bool>(allowNull => allowNull == false)),
                                                             Times.Once);
        }
Ejemplo n.º 4
0
        public void Validate_WhenCalled_AssertShouldMatchPatternWasCalledOnStringValidatorWithAccountNumber()
        {
            string accountNumber = _fixture.Create <string>().ToUpper();
            IAccountIdentificationCommand sut = CreateSut(accountNumber: accountNumber);

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

            _validatorMockContext.StringValidatorMock.Verify(m => m.ShouldMatchPattern(
                                                                 It.Is <string>(value => value == accountNumber),
                                                                 It.Is <Regex>(pattern => string.CompareOrdinal(pattern.ToString(), RegexTestHelper.AccountNumberPattern) == 0),
                                                                 It.Is <Type>(type => type == sut.GetType()),
                                                                 It.Is <string>(field => string.CompareOrdinal(field, "AccountNumber") == 0),
                                                                 It.Is <bool>(allowNull => allowNull == false)),
                                                             Times.Once);
        }
Ejemplo n.º 5
0
        public void Validate_WhenCalled_AssertShouldHaveMaxLengthWasCalledOnStringValidatorWithAccountNumber()
        {
            string accountNumber = _fixture.Create <string>().ToUpper();
            IAccountIdentificationCommand sut = CreateSut(accountNumber: accountNumber);

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

            _validatorMockContext.StringValidatorMock.Verify(m => m.ShouldHaveMaxLength(
                                                                 It.Is <string>(value => value == accountNumber),
                                                                 It.Is <int>(maxLength => maxLength == 16),
                                                                 It.Is <Type>(type => type == sut.GetType()),
                                                                 It.Is <string>(field => string.CompareOrdinal(field, "AccountNumber") == 0),
                                                                 It.Is <bool>(allowNull => allowNull == false)),
                                                             Times.Once);
        }
Ejemplo n.º 6
0
        public void Validate_WhenCommonRepositoryIsNull_ThrowsArgumentNullException()
        {
            IAccountIdentificationCommand sut = CreateSut();

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

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