public void InitializeTests() { this.dbContext = MockDbContext.GetDbContext(); var mapper = MockAutoMapper.GetMapper(); this.service = new AdminVideosService(dbContext, mapper); }
public void InitializeTests() { this.dbContext = MockDbContext.GetDbContext(); var mapper = MockAutoMapper.GetMapper(); this.townsService = new TownsService(dbContext, mapper); this.companiesService = new CompaniesService(dbContext, mapper, townsService); }
public async Task Should_Return_NotFound_If_Basket_Doesnt_Exists() { using (var context = await MockDbContext.GetDbContext()) { controller = new BasketsController(context); var actionResult = await controller.DeleteItemAsync(15); Assert.Equal((int)HttpStatusCode.NotFound, (actionResult as NotFoundResult).StatusCode); } }
public async Task Should_Delete_Basket_And_Related_Bookings() { using (var context = await MockDbContext.GetDbContext()) { controller = new BasketsController(context); var actionResult = await controller.DeleteItemAsync(2); var basketBookings = context.Set <Booking>().Where(x => x.BasketID == 2 && x.DeletedAt == null).ToList(); Assert.Equal((int)HttpStatusCode.NoContent, (actionResult as NoContentResult).StatusCode); Assert.Empty(basketBookings); } }
public async Task Should_Update_Basket() { using (var context = await MockDbContext.GetDbContext()) { controller = new BasketsController(context); var basketMock = context.Find <Basket.API.Models.Basket>(1); basketMock.State = BasketStates.SENT; var actionResult = await controller.PutItemAsync(basketMock, 1) as NoContentResult; Assert.Equal((int)HttpStatusCode.NoContent, actionResult.StatusCode); } }
public async Task Should_Update_Bookings_When_Basket_Validated() { using (var context = await MockDbContext.GetDbContext()) { controller = new BasketsController(context); var basketMock = context.Find <Basket.API.Models.Basket>(2); basketMock.State = BasketStates.VALIDATED; var actionResult = await controller.PutItemAsync(basketMock, 2); var basketBookings = context.Set <Booking>().Where(x => x.BasketID == basketMock.Id && x.DeletedAt == null).ToList(); Assert.Empty(basketBookings); } }
public async Task Should_Not_Create_Basket_If_It_Does_Exists() { using (var context = await MockDbContext.GetDbContext()) { controller = new BasketsController(context); var basketMock = new Basket.API.Models.Basket { User = 3 }; var actionResult = await controller.PostItemAsync(basketMock) as ObjectResult; Assert.Equal((int)HttpStatusCode.BadRequest, (actionResult as ObjectResult).StatusCode); } }
public async Task Should_Not_Create_If_Basket_Does_Not_Exists() { using (var context = await MockDbContext.GetDbContext()) { controller = new BookingsController(context); var bookingMock = new Booking() { BasketID = 4 }; var actionResult = await controller.PostItemAsync(bookingMock); Assert.Equal((int)HttpStatusCode.BadRequest, (actionResult as ObjectResult).StatusCode); } }
public async Task Should_Not_Create_If_Mail_Null() { using (var context = await MockDbContext.GetDbContext()) { controller = new AuthControllerMock(_configuration, context); var userMock = new Authentification.API.Models.User { Password = "******" }; var actionResult = await controller.Logon(userMock); Assert.IsType <BadRequestResult>(actionResult); } }
public void Setup() { _db = MockDbContext.GetDbContext(); var httpContext = new DefaultHttpContext(); _controller = new CustomersController(_db) { ControllerContext = new ControllerContext() { HttpContext = httpContext, } }; }
public async Task Should_Create_User() { using (var context = await MockDbContext.GetDbContext()) { controller = new AuthControllerMock(_configuration, context); var userMock = new Authentification.API.Models.User { Mail = "*****@*****.**", Password = "******", }; var actionResult = await controller.Logon(userMock); Assert.IsType <OkObjectResult>(actionResult); } }
public async Task Should_Create_Booking() { using (var context = await MockDbContext.GetDbContext()) { controller = new BookingsController(context); var bookingMock = new Booking { Id = 4, ProductID = 4, BasketID = 1 }; var actionResult = await controller.PostItemAsync(bookingMock); Assert.Equal((int)HttpStatusCode.Created, (actionResult as ObjectResult).StatusCode); } }
public async Task Should_Create_Basket_If_It_Does_Not_Exists() { using (var context = await MockDbContext.GetDbContext()) { controller = new BasketsController(context); var basketMock = new Basket.API.Models.Basket { User = 10 }; var actionResult = await controller.PostItemAsync(basketMock); var returnedObject = (actionResult as ObjectResult).Value as Basket.API.Models.Basket; Assert.Equal(201, (actionResult as ObjectResult).StatusCode); Assert.Equal(4, returnedObject.Id); Assert.Equal(10, returnedObject.User); Assert.Equal(BasketStates.PENDING, returnedObject.State); } }
public async Task Should_Not_Create_If_Booking_Already_Exists() { using (var context = await MockDbContext.GetDbContext()) { controller = new BookingsController(context); var dateNow = DateTime.Now; var booking = context.Set <Booking>().FirstOrDefault(x => x.Id == 1); booking.BookingDate = dateNow; context.Update(booking); await context.SaveChangesAsync(); var bookingMock = new Booking { Id = 1, BookingDate = dateNow, ProductID = 1 }; var actionResult = await controller.PostItemAsync(bookingMock); Assert.Equal((int)HttpStatusCode.BadRequest, (actionResult as ObjectResult).StatusCode); } }
public void InitializeTests() { this.dbContext = MockDbContext.GetDbContext(); }
public void InitializeTests() { this.dbContext = MockDbContext.GetDbContext(); this.mapper = MockAutoMapper.GetAutoMapper(); }
public void Setup() { _db = MockDbContext.GetDbContext(); _controllerP = new PizzasController(_db); _controllerC = new CustomersController(_db); }
public void Initialize() { this.dbContext = MockDbContext.GetDbContext(); this.genreService = new ModeratorGenreService(this.dbContext, MockAutoMapper.GetMapper()); }
public void TestsSetup() { this.DbContext = MockDbContext.GetDbContext(); this.Mapper = MockAutoMapper.GetMapper(); }
public void Setup() { _context = MockDbContext.GetDbContext(); _controller = new CustomersController(_context); }
public void Setup() { _db = MockDbContext.GetDbContext(); _controller = new CustomerController(_db); }