public async Task AndThereAreNoPreviousTransactionThenTheUrlIsNotSet() { var hashedAccountId = "ABC123"; var year = 2017; var month = 3; var transactionsResponse = new GetEmployerAccountTransactionsResponse { Data = new AggregationData { TransactionLines = new List <TransactionLine> { TransactionLineObjectMother.Create() } }, AccountHasPreviousTransactions = false }; _mediator.Setup(x => x.SendAsync(It.Is <GetEmployerAccountTransactionsQuery>(q => q.HashedAccountId == hashedAccountId && q.Year == year && q.Month == month))).ReturnsAsync(transactionsResponse); var response = await _controller.GetTransactions(hashedAccountId, year, month); Assert.IsNotNull(response); Assert.IsInstanceOf <OkNegotiatedContentResult <TransactionsViewModel> >(response); var model = response as OkNegotiatedContentResult <TransactionsViewModel>; model?.Content.Should().NotBeNull(); model?.Content.PreviousMonthUri.Should().BeNullOrEmpty(); _urlHelper.Verify(x => x.Route("GetTransactions", It.IsAny <object>()), Times.Never); }
public async Task AndThereArePreviousTransactionsThenTheLinkIsCorrect() { var hashedAccountId = "ABC123"; var year = 2017; var month = 1; var transactionsResponse = new GetEmployerAccountTransactionsResponse { Data = new AggregationData { TransactionLines = new List <TransactionLine> { TransactionLineObjectMother.Create() } }, AccountHasPreviousTransactions = true, Year = year, Month = month }; _mediator.Setup(x => x.SendAsync(It.Is <GetEmployerAccountTransactionsQuery>(q => q.HashedAccountId == hashedAccountId && q.Year == year && q.Month == month))).ReturnsAsync(transactionsResponse); var expectedUri = "someuri"; _urlHelper.Setup(x => x.Route("GetTransactions", It.Is <object>(o => o.IsEquivalentTo(new { hashedAccountId, year = year - 1, month = 12 })))).Returns(expectedUri); var response = await _controller.GetTransactions(hashedAccountId, year, month); var model = response as OkNegotiatedContentResult <TransactionsViewModel>; model?.Content.PreviousMonthUri.Should().Be(expectedUri); }
public async Task ThenTheTransactionsAreReturned() { var hashedAccountId = "ABC123"; var year = 2017; var month = 3; var transactionsResponse = new GetEmployerAccountTransactionsResponse { Data = new AggregationData { TransactionLines = new List <TransactionLine> { TransactionLineObjectMother.Create() } }, AccountHasPreviousTransactions = false }; _mediator.Setup(x => x.SendAsync(It.Is <GetEmployerAccountTransactionsQuery>(q => q.HashedAccountId == hashedAccountId && q.Year == year && q.Month == month))).ReturnsAsync(transactionsResponse); var response = await _controller.GetTransactions(hashedAccountId, year, month); Assert.IsNotNull(response); Assert.IsInstanceOf <OkNegotiatedContentResult <TransactionsViewModel> >(response); var model = response as OkNegotiatedContentResult <TransactionsViewModel>; model?.Content.Should().NotBeNull(); model?.Content.ShouldAllBeEquivalentTo(transactionsResponse.Data.TransactionLines, options => options.Excluding(x => x.ResourceUri)); }