public async Task <ServiceResponse <IEnumerable <FlatSummaryViewModel> > > GetAllFlatsSummary() { try { return(await _flatService.GetAllFlatsSummary()); } catch (Exception e) { _logger.LogError(e, "exception in GetAllFlatsSummary"); return(ServiceResponse <IEnumerable <FlatSummaryViewModel> > .Exception("An error occured during all-flats-summary request")); } }
public async Task GetAllFlatsSummary_ShouldReturnOk() { var flatRepoMoq = new Mock <IFlatRepository>(); flatRepoMoq .Setup(m => m.GetAllFlatsWithHouseInfo()) .Returns(Task.FromResult <IEnumerable <Flat> > ( new List <Flat> { new Flat { House = new House(), } } )); var controller = new FlatService(flatRepoMoq.Object); var response = await controller.GetAllFlatsSummary(); Assert.Equal(ResponseStatuses.Ok, response.Status); }