public async Task <ActionResult <BudgetAccountCollectionModel> > BudgetAccountsAsync(int accountingNumber, DateTimeOffset?statusDate = null) { IGetBudgetAccountCollectionQuery query = new GetBudgetAccountCollectionQuery { AccountingNumber = accountingNumber, StatusDate = statusDate?.LocalDateTime.Date ?? DateTime.Today }; IBudgetAccountCollection budgetAccountCollection = await _queryBus.QueryAsync <IGetBudgetAccountCollectionQuery, IBudgetAccountCollection>(query); BudgetAccountCollectionModel budgetAccountCollectionModel = _accountingModelConverter.Convert <IBudgetAccountCollection, BudgetAccountCollectionModel>(budgetAccountCollection); return(new OkObjectResult(budgetAccountCollectionModel)); }
public async Task BudgetAccountsAsync_WhenCalled_ReturnsOkObjectResultWhereValueIsBudgetAccountCollectionModelContainingAllBudgetAccounts() { IList <IBudgetAccount> budgetAccounts = _fixture.CreateMany <IBudgetAccount>(_random.Next(5, 10)).ToList(); IBudgetAccountCollection budgetAccountCollection = _fixture.BuildBudgetAccountCollectionMock(budgetAccountCollection: budgetAccounts).Object; Controller sut = CreateSut(budgetAccountCollection); OkObjectResult result = (OkObjectResult)(await sut.BudgetAccountsAsync(_fixture.Create <int>())).Result; BudgetAccountCollectionModel budgetAccountCollectionModel = (BudgetAccountCollectionModel)result.Value; Assert.That(budgetAccountCollectionModel, Is.Not.Null); Assert.That(budgetAccountCollectionModel.Count, Is.EqualTo(budgetAccounts.Count)); Assert.That(budgetAccountCollectionModel.All(budgetAccountModel => budgetAccounts.SingleOrDefault(budgetAccount => string.CompareOrdinal(budgetAccountModel.AccountNumber, budgetAccount.AccountNumber) == 0) != null), Is.True); }