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

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

            Assert.That(result, Is.SameAs(_validatorMockContext.ValidatorMock.Object));
        }
        public void Validate_WhenCalled_AssertShouldNotBeNullWasCalledOnObjectValidatorWithBudgetInfoCollection()
        {
            IBudgetInfoCommand[]      budgetInfoCommandCollection = _fixture.CreateMany <IBudgetInfoCommand>(_random.Next(5, 10)).ToArray();
            IBudgetAccountDataCommand sut = CreateSut(budgetInfoCommandCollection: budgetInfoCommandCollection);

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

            _validatorMockContext.ObjectValidatorMock.Verify(m => m.ShouldNotBeNull(
                                                                 It.Is <IEnumerable <IBudgetInfoCommand> >(value => value == budgetInfoCommandCollection),
                                                                 It.Is <Type>(type => type == sut.GetType()),
                                                                 It.Is <string>(field => string.CompareOrdinal(field, "BudgetInfoCollection") == 0)),
                                                             Times.Once());
        }
        public void Validate_WhenCalled_AssertShouldBeBetweenWasCalledOnIntegerValidatorWithBudgetAccountGroupNumber()
        {
            int budgetAccountGroupNumber  = _fixture.Create <int>();
            IBudgetAccountDataCommand sut = CreateSut(budgetAccountGroupNumber);

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

            _validatorMockContext.IntegerValidatorMock.Verify(m => m.ShouldBeBetween(
                                                                  It.Is <int>(value => value == budgetAccountGroupNumber),
                                                                  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, "BudgetAccountGroupNumber") == 0)),
                                                              Times.Once());
        }
        public void Validate_WhenCalled_AssertShouldBeKnownValueWasCalledOnObjectValidatorWithBudgetAccountGroupNumber()
        {
            int budgetAccountGroupNumber  = _fixture.Create <int>();
            IBudgetAccountDataCommand sut = CreateSut(budgetAccountGroupNumber);

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

            _validatorMockContext.ObjectValidatorMock.Verify(m => m.ShouldBeKnownValue(
                                                                 It.Is <int>(value => value == budgetAccountGroupNumber),
                                                                 It.IsNotNull <Func <int, Task <bool> > >(),
                                                                 It.Is <Type>(type => type == sut.GetType()),
                                                                 It.Is <string>(field => String.CompareOrdinal(field, "BudgetAccountGroupNumber") == 0),
                                                                 It.Is <bool>(allowNull => allowNull == false)),
                                                             Times.Once());
        }
        public void Validate_WhenCalled_AssertValidateWasCalledOnEachBudgetInfoCommandInBudgetInfoCollection()
        {
            Mock <IBudgetInfoCommand>[] budgetInfoCommandMockCollection =
            {
                CreateBudgetInfoCommandMock(),
                CreateBudgetInfoCommandMock(),
                CreateBudgetInfoCommandMock()
            };
            IBudgetAccountDataCommand sut = CreateSut(budgetInfoCommandCollection: budgetInfoCommandMockCollection.Select(budgetInfoCommandMock => budgetInfoCommandMock.Object).ToArray());

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

            foreach (Mock <IBudgetInfoCommand> budgetInfoCommandMock in budgetInfoCommandMockCollection)
            {
                budgetInfoCommandMock.Verify(m => m.Validate(It.Is <IValidator>(value => value == _validatorMockContext.ValidatorMock.Object)), Times.Once);
            }
        }
        public void Validate_WhenCommonRepositoryIsNull_ThrowsArgumentNullException()
        {
            IBudgetAccountDataCommand sut = CreateSut();

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

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