public async Task GetTransferTargetsCallsGetHandlerAndReturnsListOfBidViewModelAsync() { //Arrange var accessToken = "ABC"; var initial = new List <BidViewModel> { new BidViewModel { Status = "Pending", BidPrice = 1300, Pending = true, TimeRemaining = 123, TradeId = "123" }, new BidViewModel { Status = "Pending", BidPrice = 1300, Pending = true, TimeRemaining = -1, TradeId = "123" } }; var expected = new List <BidViewModel> { new BidViewModel { Status = "Pending", BidPrice = 1300, Pending = true, TimeRemaining = 123, TradeId = "123" }, new BidViewModel { Status = "Pending", BidPrice = 1300, Pending = false, TimeRemaining = -1, TradeId = "123" } }; A.CallTo(() => _getRequestHandler.GetTransferTargets(accessToken)) .Returns(initial); A.CallTo(() => _modelBuilder.PopulateDefaultFieldsOfBidViews(initial)) .Returns(expected); //Act var actual = await _ApiGateway.GetTransferTargets(accessToken); //Assert A.CallTo(() => _getRequestHandler.GetTransferTargets(accessToken)).MustHaveHappenedOnceExactly(); A.CallTo(() => _modelBuilder.PopulateDefaultFieldsOfBidViews(initial)).MustHaveHappenedOnceExactly(); actual.Should().BeEquivalentTo(expected); }
public async Task <List <BidViewModel> > GetTransferTargets(string accessToken) { try { var targetsList = await _getRequestHandler.GetTransferTargets(accessToken); if (targetsList.Count == 0) { throw new Exception(); } var players = _modelBuilder.PopulateDefaultFieldsOfBidViews(targetsList); return(players); } catch (Exception) { return(new List <BidViewModel> { new BidViewModel { Status = "Expired", Pending = false, } }); } }
public void PopulateDefaultFieldsTakesListOfBidViewAndReturnsCorrectModel() { //Arrange var initial = new List <BidViewModel> { new BidViewModel { TimeRemaining = -1, Status = "Outbid", Pending = true }, new BidViewModel { TimeRemaining = 10, Status = "Winning", Pending = true } }; var expected = new List <BidViewModel> { new BidViewModel { TimeRemaining = -1, Status = "Outbid", Pending = false }, new BidViewModel { TimeRemaining = 10, Status = "Winning", Pending = true } }; //Act var actual = _bidViewModelBuilder.PopulateDefaultFieldsOfBidViews(initial); //Assert actual.Should().BeEquivalentTo(expected); }