public async Task BudgetAccountAsync_WhenBudgetAccountWasReturnedFromQueryBus_ReturnsActionResultWhereResultIsOkObjectResult()
        {
            Controller sut = CreateSut();

            ActionResult <BudgetAccountModel> result = await sut.BudgetAccountAsync(_fixture.Create <int>(), _fixture.Create <string>());

            Assert.That(result.Result, Is.TypeOf <OkObjectResult>());
        }
        public async Task BudgetAccountAsync_WhenBudgetAccountWasReturnedFromQueryBus_ReturnsOkObjectResultWhereValueIsBudgetAccountModel()
        {
            Controller sut = CreateSut();

            OkObjectResult result = (OkObjectResult)(await sut.BudgetAccountAsync(_fixture.Create <int>(), _fixture.Create <string>())).Result;

            Assert.That(result.Value, Is.TypeOf <BudgetAccountModel>());
        }
        public async Task BudgetAccountAsync_WhenBudgetAccountWasReturnedFromQueryBus_ReturnsNotNull()
        {
            Controller sut = CreateSut();

            ActionResult <BudgetAccountModel> result = await sut.BudgetAccountAsync(_fixture.Create <int>(), _fixture.Create <string>());

            Assert.That(result, Is.Not.Null);
        }
        public async Task BudgetAccountAsync_WhenCalledWithoutStatusDate_AssertQueryAsyncWasCalledOnQueryBus()
        {
            Controller sut = CreateSut();

            int    accountingNumber = _fixture.Create <int>();
            string accountNumber    = _fixture.Create <string>();
            await sut.BudgetAccountAsync(accountingNumber, accountNumber);

            _queryBusMock.Verify(m => m.QueryAsync <IGetBudgetAccountQuery, IBudgetAccount>(It.Is <IGetBudgetAccountQuery>(value => value.AccountingNumber == accountingNumber && string.CompareOrdinal(value.AccountNumber, accountNumber.ToUpper()) == 0 && value.StatusDate == DateTime.Today)), Times.Once);
        }
        public async Task BudgetAccountAsync_WhenBudgetAccountWasReturnedFromQueryBus_ReturnsOkObjectResultWhereValueIsBudgetAccountModelMatchingBudgetAccountFromQueryBus()
        {
            string         accountNumber = _fixture.Create <string>();
            IBudgetAccount budgetAccount = _fixture.BuildBudgetAccountMock(accountNumber: accountNumber).Object;
            Controller     sut           = CreateSut(budgetAccount: budgetAccount);

            OkObjectResult result = (OkObjectResult)(await sut.BudgetAccountAsync(_fixture.Create <int>(), _fixture.Create <string>())).Result;

            BudgetAccountModel budgetAccountModel = (BudgetAccountModel)result.Value;

            Assert.That(budgetAccountModel, Is.Not.Null);
            Assert.That(budgetAccountModel.AccountNumber, Is.EqualTo(accountNumber));
        }
        public void BudgetAccountAsync_WhenAccountNumberIsEmpty_ThrowsIntranetValidationExceptionWhereErrorCodeIsEqualToValueCannotBeNullOrWhiteSpace()
        {
            Controller sut = CreateSut();

            IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.BudgetAccountAsync(_fixture.Create <int>(), string.Empty));

            Assert.That(result, Is.Not.Null);
            Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ValueCannotBeNullOrWhiteSpace));
        }
        public void BudgetAccountAsync_WhenAccountNumberIsEmpty_ThrowsIntranetValidationException()
        {
            Controller sut = CreateSut();

            Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.BudgetAccountAsync(_fixture.Create <int>(), string.Empty));
        }
        public void BudgetAccountAsync_WhenAccountNumberIsNull_ThrowsIntranetValidationExceptionWhereValidatingFieldIsEqualToAccountNumber()
        {
            Controller sut = CreateSut();

            IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.BudgetAccountAsync(_fixture.Create <int>(), null));

            Assert.That(result, Is.Not.Null);
            Assert.That(result.ValidatingField, Is.EqualTo("accountNumber"));
        }
        public void BudgetAccountAsync_WhenAccountNumberIsNull_ThrowsIntranetValidationExceptionWhereValidatingTypeIsTypeOfString()
        {
            Controller sut = CreateSut();

            IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.BudgetAccountAsync(_fixture.Create <int>(), null));

            Assert.That(result, Is.Not.Null);
            Assert.That(result.ValidatingType, Is.EqualTo(typeof(string)));
        }
        public void BudgetAccountAsync_WhenBudgetAccountWasNotReturnedFromQueryBus_ThrowsIntranetValidationExceptionWhereValidatingFieldIsEqualToAccountNumber()
        {
            Controller sut = CreateSut(false);

            IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.BudgetAccountAsync(_fixture.Create <int>(), _fixture.Create <string>()));

            Assert.That(result, Is.Not.Null);
            Assert.That(result.ValidatingField, Is.EqualTo("accountNumber"));
        }
        public void BudgetAccountAsync_WhenBudgetAccountWasNotReturnedFromQueryBus_ThrowsIntranetValidationExceptionWhereErrorCodeIsEqualToValueShouldBeKnown()
        {
            Controller sut = CreateSut(false);

            IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.BudgetAccountAsync(_fixture.Create <int>(), _fixture.Create <string>()));

            Assert.That(result, Is.Not.Null);
            Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ValueShouldBeKnown));
        }
        public void BudgetAccountAsync_WhenBudgetAccountWasNotReturnedFromQueryBus_ThrowsIntranetValidationException()
        {
            Controller sut = CreateSut(false);

            Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.BudgetAccountAsync(_fixture.Create <int>(), _fixture.Create <string>()));
        }