public async Task GetAvgGwpAsync_success() { // Arrange var controller = new CountryGwpController(this.countryGwpService); GwpAvgRequest request = new GwpAvgRequest { Country = "ae", LineOfBusiness = new List <string>() }; request.LineOfBusiness.Add("transport"); request.LineOfBusiness.Add("freight"); request.LineOfBusiness.Add("property"); var result = new Dictionary <string, double>(); foreach (var item in request.LineOfBusiness) { result.Add(item, 1.0); } this.mockRepo.Setup(x => x.GetGwpAvgAsync(It.IsAny <GwpAvgRequest>())).ReturnsAsync(result); // Act var response = await controller.GetAvgGwpAsync(request).ConfigureAwait(false); //Assert Assert.IsNotNull(response); Assert.AreEqual(response.Count, result.Count); }
public async Task <Dictionary <string, double> > GetGwpAvgAsync(GwpAvgRequest request) { var op = new Dictionary <string, double>(); var data = dbContext.CountryGwpItems.Where(x => x.Country == request.Country); foreach (var lob in request.LineOfBusiness) { op.Add(lob, data.Where(x => x.LineOfBusiness == lob).Select(x => (x.Y2008 + x.Y2009 + x.Y2010 + x.Y2011 + x.Y2012 + x.Y2013 + x.Y2014 + x.Y2015) / 8).FirstOrDefault()); } return(op); }
public async Task <Dictionary <string, double> > GetAvgGwpAsync([FromBody] GwpAvgRequest request) { return(await this.countryGwpService.GetGwpAvgAsync(request).ConfigureAwait(false)); }
public async Task <Dictionary <string, double> > GetGwpAvgAsync(GwpAvgRequest request) { return(await this.repo.GetGwpAvgAsync(request).ConfigureAwait(false)); }