public async void Update_ShowsCorrectView()
        {
            bookingRepository.Setup(r => r.GetByIdAsync(1)).ReturnsAsync(BookingGenerator.Create());
            var result = await Controller.Edit(1);

            Assert.IsType <ViewResult>(result);
            var viewResult = result as ViewResult;

            Assert.Null(viewResult.ViewName);
        }
        public void PostBooking_CreatesBooking()
        {
            var      booking  = BookingGenerator.Create();
            Facility facility = FacilityGenerator.Create();

            booking.FacilityId = facility.FacilityId;
            bookingRepository.Setup(b => b.GetByIdAsync(booking.BookingId)).ReturnsAsync(booking).Verifiable();

            //implement
            Assert.Equal(1, 2);
        }
        public async void Update_ContainsCorrectModel()
        {
            var expectedResource = BookingGenerator.Create();

            bookingRepository.Setup(r => r.GetByIdAsync(1)).ReturnsAsync(expectedResource);

            var viewResult = await Controller.Edit(1) as ViewResult;

            Assert.IsType <Booking>(viewResult.Model);

            var resources = viewResult.Model as Booking;

            Assert.Equal(expectedResource, resources);
        }
        public async void DeleteConfirmed_DeleteBooking()
        {
            var booking = BookingGenerator.Create();

            var result = await Controller.DeleteConfirmed(booking.BookingId);

            Assert.IsType <RedirectToActionResult>(result);

            var redirectedResult = result as RedirectToActionResult;

            Assert.Equal("Index", redirectedResult.ActionName);

            bookingRepository.Verify();
        }
예제 #5
0
        public async void AddAsync_AddAsyncToConext()
        {
            var booking = BookingGenerator.Create();

            using (var context = new booking_facilitiesContext(contextOptions))
            {
                context.Database.EnsureCreated();
                var repository = new BookingRepository(context);
                await repository.AddAsync(booking);

                Assert.Equal(1, await context.Booking.CountAsync());
                Assert.Equal(booking, await context.Booking.SingleAsync());
            }
        }
        public async void GetBooking_ReturnsBooking()
        {
            var booking = BookingGenerator.Create();

            bookingRepository.Setup(r => r.GetByIdAsync(booking.BookingId)).ReturnsAsync(booking).Verifiable();
            var result = await controller.GetBooking(booking.BookingId);

            Assert.IsType <OkObjectResult>(result);
            var content = result as OkObjectResult;

            Assert.IsType <Booking>(content.Value);
            Assert.Equal(booking, content.Value);
            bookingRepository.Verify();
            bookingRepository.VerifyNoOtherCalls();
        }
예제 #7
0
        public async void DeleteAsync_DeleteFromContext()
        {
            var booking = BookingGenerator.Create();

            using (var context = new booking_facilitiesContext(contextOptions))
            {
                var repository = new BookingRepository(context);
                context.Database.EnsureCreated();
                context.Booking.Add(booking);
                context.SaveChanges();
                Assert.Equal(1, await context.Booking.CountAsync());

                await repository.DeleteAsync(booking);

                Assert.Equal(0, await context.Booking.CountAsync());
            }
        }
예제 #8
0
        public async void UpdateAsync_UpdatesInContext()
        {
            var booking = BookingGenerator.Create();

            using (var context = new booking_facilitiesContext(contextOptions))
            {
                context.Database.EnsureCreated();
                context.Booking.Add(booking);
                context.SaveChanges();
                var repository = new BookingRepository(context);
                var newBooking = await repository.GetByIdAsync(booking.BookingId);

                newBooking.IsBlock = true;

                await repository.UpdateAsync(newBooking);

                Assert.Equal(1, await context.Booking.CountAsync());
                Assert.Equal(newBooking, await context.Booking.SingleAsync());
            }
        }
 public void Delete_ShowsCorrectView()
 {
     bookingRepository.Setup(r => r.GetByIdAsync(1)).ReturnsAsync(BookingGenerator.Create());
     //implement
     Assert.Null(1);
 }