public async Task GetFlatFullInformation_EmptyId_Warning() { var flatRepoMoq = new Mock <IFlatRepository>(); var controller = new FlatService(flatRepoMoq.Object); var actualResponse = await controller.GetFlatFullInformation(0); Assert.Equal(ResponseStatuses.Warning, actualResponse.Status); }
public async Task <ServiceResponse <FlatFullInformationViewModel> > GetFlatDetails(int id) { try { return(await _flatService.GetFlatFullInformation(id)); } catch (Exception e) { _logger.LogError(e, $"exception in GetFlatDetails, called with id = {id}"); return(ServiceResponse <FlatFullInformationViewModel> .Exception("An error occured during get-flat-details request")); } }
public async Task GetFlatFullInformation_ShouldThrowException() { var flatRepoMoq = new Mock <IFlatRepository>(); flatRepoMoq .Setup(m => m.GetFullFlatInformation(12345)) .Returns(Task.FromResult(new Flat { House = null })); var controller = new FlatService(flatRepoMoq.Object); await Assert.ThrowsAnyAsync <Exception>(async() => await controller.GetFlatFullInformation(12345)); }
public async Task GetFlatFullInformation_NonEmptyIdentifier_OkResponse(int id) { var flatRepoMoq = new Mock <IFlatRepository>(); flatRepoMoq .Setup(m => m.GetFullFlatInformation(id)) .Returns(Task.FromResult(new Flat { House = new House { }, Region = new Region { }, District = new District { }, })); var controller = new FlatService(flatRepoMoq.Object); var actualResponse = await controller.GetFlatFullInformation(id); Assert.Equal(ResponseStatuses.Ok, actualResponse.Status); }