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

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

            Assert.That(result, Is.SameAs(_validatorMockContext.ValidatorMock.Object));
        }
        public void Validate_WhenCommonRepositoryIsNull_ThrowsArgumentNullException()
        {
            ICreateBudgetAccountCommand sut = CreateSut();

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

            Assert.That(result.ParamName, Is.EqualTo("commonRepository"));
        }
        public async Task ExecuteAsync_WhenCalled_AssertCreateBudgetAccountAsyncWasCalledOnAccountingRepository()
        {
            CommandHandler sut = CreateSut();

            IBudgetAccount budgetAccount = _fixture.BuildBudgetAccountMock().Object;
            ICreateBudgetAccountCommand command = CreateCommand(budgetAccount);
            await sut.ExecuteAsync(command);

            _accountingRepositoryMock.Verify(m => m.CreateBudgetAccountAsync(It.Is<IBudgetAccount>(value => value == budgetAccount)), Times.Once);
        }
        public void Validate_WhenCalled_AssertShouldBeUnknownValueWasCalledOnObjectValidatorWithAccountNumber()
        {
            string accountNumber            = _fixture.Create <string>().ToUpper();
            ICreateBudgetAccountCommand sut = CreateSut(accountNumber);

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

            _validatorMockContext.ObjectValidatorMock.Verify(m => m.ShouldBeUnknownValue(
                                                                 It.Is <string>(value => string.CompareOrdinal(value, accountNumber) == 0),
                                                                 It.IsNotNull <Func <string, Task <bool> > >(),
                                                                 It.Is <Type>(type => type == sut.GetType()),
                                                                 It.Is <string>(field => string.CompareOrdinal(field, "AccountNumber") == 0),
                                                                 It.Is <bool>(allowNull => allowNull == false)),
                                                             Times.Once);
        }