public async Task <ActionResult <PostingLineCollectionModel> > PostingLinesAsync(int accountingNumber, DateTimeOffset?statusDate = null, int?numberOfPostingLines = null) { IGetPostingLineCollectionQuery query = new GetPostingLineCollectionQuery { AccountingNumber = accountingNumber, StatusDate = statusDate?.LocalDateTime.Date ?? DateTime.Today, NumberOfPostingLines = numberOfPostingLines ?? 25 }; IPostingLineCollection postingLineCollection = await _queryBus.QueryAsync <IGetPostingLineCollectionQuery, IPostingLineCollection>(query); PostingLineCollectionModel postingLineCollectionModel = _accountingModelConverter.Convert <IPostingLineCollection, PostingLineCollectionModel>(postingLineCollection); return(new OkObjectResult(postingLineCollectionModel)); }
public async Task PostingLinesAsync_WhenCalled_ReturnsOkObjectResultWhereValueIsPostingLineCollectionModelContainingPostingLines() { IList <IPostingLine> postingLines = _fixture.CreateMany <IPostingLine>(_random.Next(5, 10)).ToList(); IPostingLineCollection postingLineCollection = _fixture.BuildPostingLineCollectionMock(postingLineCollection: postingLines).Object; Controller sut = CreateSut(postingLineCollection); OkObjectResult result = (OkObjectResult)(await sut.PostingLinesAsync(_fixture.Create <int>())).Result; PostingLineCollectionModel postingLineCollectionModel = (PostingLineCollectionModel)result.Value; Assert.That(postingLineCollectionModel, Is.Not.Null); Assert.That(postingLineCollectionModel.Count, Is.EqualTo(postingLines.Count)); Assert.That(postingLineCollectionModel.All(postingLineModel => postingLines.SingleOrDefault(postingLine => postingLineModel.Identifier == postingLine.Identifier) != null), Is.True); }