Exemple #1
0
        public async Task Delete_Prestation_Error_Prestation_Id_Does_Not_Exist()
        {
            #region Arrange
            var dbContext = DbContextMocker.GetElegantGlamourDbContext(nameof(Delete_Prestation_Error_Prestation_Id_Does_Not_Exist));
            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);
            #endregion

            int idPrestation = 1500;

            #region Act
            var apiException = await Assert.ThrowsAsync <ApiException>(() => controller.DeletePrestation(idPrestation));

            dbContext.Dispose();
            #endregion

            #region Assert
            Assert.Equal(404, apiException.StatusCode);
            Assert.Contains(ErrorMessage.Err_Prestation_Id_Does_Not_Exist, apiException.Message);

            #endregion
        }
Exemple #2
0
        public async Task Delete_Prestation_Return_Ok()
        {
            #region Arrange
            var dbContext = DbContextMocker.GetElegantGlamourDbContext(nameof(Delete_Prestation_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);
            #endregion

            int idPrestation = 1;

            #region Act
            var response = await controller.DeletePrestation(idPrestation);

            dbContext.Dispose();
            #endregion

            #region Assert
            Assert.IsType <ApiResponse>(response);
            Assert.Equal(200, response.StatusCode);
            #endregion
        }