public void InitializeTests()
        {
            this.dbContext = MockDbContext.GetDbContext();
            var mapper = MockAutoMapper.GetMapper();

            this.service = new AdminVideosService(dbContext, mapper);
        }
Example #2
0
        public void InitializeTests()
        {
            this.dbContext = MockDbContext.GetDbContext();
            var mapper = MockAutoMapper.GetMapper();

            this.townsService     = new TownsService(dbContext, mapper);
            this.companiesService = new CompaniesService(dbContext, mapper, townsService);
        }
Example #3
0
        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);
            }
        }
Example #4
0
        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);
            }
        }
Example #5
0
        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);
            }
        }
Example #6
0
        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);
            }
        }
Example #7
0
        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);
            }
        }
Example #8
0
        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);
            }
        }
Example #9
0
        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);
            }
        }
Example #10
0
        public void Setup()
        {
            _db = MockDbContext.GetDbContext();


            var httpContext = new DefaultHttpContext();

            _controller = new CustomersController(_db)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = httpContext,
                }
            };
        }
Example #11
0
        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);
            }
        }
Example #12
0
        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);
            }
        }
Example #13
0
        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);
            }
        }
Example #14
0
        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);
            }
        }
Example #15
0
 public void InitializeTests()
 {
     this.dbContext = MockDbContext.GetDbContext();
 }
 public void InitializeTests()
 {
     this.dbContext = MockDbContext.GetDbContext();
     this.mapper    = MockAutoMapper.GetAutoMapper();
 }
Example #17
0
 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());
 }
Example #19
0
 public void TestsSetup()
 {
     this.DbContext = MockDbContext.GetDbContext();
     this.Mapper    = MockAutoMapper.GetMapper();
 }
Example #20
0
 public void Setup()
 {
     _context    = MockDbContext.GetDbContext();
     _controller = new CustomersController(_context);
 }
Example #21
0
 public void Setup()
 {
     _db         = MockDbContext.GetDbContext();
     _controller = new CustomerController(_db);
 }