public async Task GetPrestationById_Return_Not_Found() { #region Arrange var dbContext = DbContextMocker.GetElegantGlamourDbContext(nameof(GetPrestationById_Return_Not_Found)); var config = new MapperConfiguration(cfg => { cfg.AddProfile(new MappingProfile()); }); var mapper = new Mapper(config); var mockUnitOfWork = new UnitOfWork(dbContext); var mockPrestationService = new PrestationService(mockUnitOfWork); var mockLogger = Mock.Of <ILogger <PrestationsController> >(); var controller = new PrestationsController(mockPrestationService, mapper, mockLogger); var id = 300; #endregion #region Act var apiException = await Assert.ThrowsAsync <ApiException>(() => controller.GetPrestationById(id)); dbContext.Dispose(); #endregion #region Assert Assert.Equal(404, apiException.StatusCode); #endregion }
public async Task GetPrestationById_Return_Ok() { #region Arrange var dbContext = DbContextMocker.GetElegantGlamourDbContext(nameof(GetPrestationById_Return_Ok)); var config = new MapperConfiguration(cfg => { cfg.AddProfile(new MappingProfile()); }); var mapper = new Mapper(config); var mockUnitOfWork = new UnitOfWork(dbContext); var mockPrestationService = new PrestationService(mockUnitOfWork); var mockLogger = Mock.Of <ILogger <PrestationsController> >(); var controller = new PrestationsController(mockPrestationService, mapper, mockLogger); var id = 1; #endregion #region Act var response = await controller.GetPrestationById(id); dbContext.Dispose(); #endregion #region Assert Assert.IsType <GetPrestationDto>(response); #endregion }