public async Task <ActionResult <AccountCollectionModel> > AccountsAsync(int accountingNumber, DateTimeOffset?statusDate = null) { IGetAccountCollectionQuery query = new GetAccountCollectionQuery { AccountingNumber = accountingNumber, StatusDate = statusDate?.LocalDateTime.Date ?? DateTime.Today }; IAccountCollection accountCollection = await _queryBus.QueryAsync <IGetAccountCollectionQuery, IAccountCollection>(query); AccountCollectionModel accountCollectionModel = _accountingModelConverter.Convert <IAccountCollection, AccountCollectionModel>(accountCollection); return(new OkObjectResult(accountCollectionModel)); }
public async Task AccountsAsync_WhenCalled_ReturnsOkObjectResultWhereValueIsAccountCollectionModelContainingAllAccounts() { IList <IAccount> accounts = _fixture.CreateMany <IAccount>(_random.Next(5, 10)).ToList(); IAccountCollection accountCollection = _fixture.BuildAccountCollectionMock(accountCollection: accounts).Object; Controller sut = CreateSut(accountCollection); OkObjectResult result = (OkObjectResult)(await sut.AccountsAsync(_fixture.Create <int>())).Result; AccountCollectionModel accountCollectionModel = (AccountCollectionModel)result.Value; Assert.That(accountCollectionModel, Is.Not.Null); Assert.That(accountCollectionModel.Count, Is.EqualTo(accounts.Count)); Assert.That(accountCollectionModel.All(accountModel => accounts.SingleOrDefault(account => string.CompareOrdinal(accountModel.AccountNumber, account.AccountNumber) == 0) != null), Is.True); }