public void GetBookingsInLocationAtDateTime() { var bookings = BookingGenerator.CreateList(); bookings[1].BookingDateTime = bookings[2].BookingDateTime; bookings[1].Facility = bookings[2].Facility; bookings[1].FacilityId = bookings[2].FacilityId; var booking2Expected = bookings[2]; List <Booking> expected = new List <Booking>(); expected.Add(bookings[1]); expected.Add(bookings[2]); using (var context = new booking_facilitiesContext(contextOptions)) { context.Database.EnsureCreated(); context.Booking.AddRange(bookings); context.SaveChanges(); var repository = new BookingRepository(context); var call = repository.GetBookingsInLocationAtDateTime(booking2Expected.BookingDateTime, booking2Expected.Facility.VenueId, booking2Expected.Facility.SportId).ToList(); Assert.Equal(expected, call); } }
public void Index_ContainsCorrectModel() { //implement var expectedResources = BookingGenerator.CreateList(); Assert.Equal(1, 2); }
public async void UpdateBlock_ShowsCorrectView() { bookingRepository.Setup(r => r.GetByIdAsync(1)).ReturnsAsync(BookingGenerator.CreateBlock()); var result = await Controller.EditBlockFacility(1); Assert.IsType <ViewResult>(result); var viewResult = result as ViewResult; Assert.Null(viewResult.ViewName); }
public void GetBooking_ReturnsAllBookings() { var bookings = BookingGenerator.CreateList(5); bookingRepository.Setup(r => r.GetAllAsync()); var result = controller.GetBooking(); //implement Assert.Equal(1, 2); }
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 UpdateBlock_ContainsCorrectModel() { var expectedResource = BookingGenerator.CreateBlock(); bookingRepository.Setup(r => r.GetByIdAsync(1)).ReturnsAsync(expectedResource); var viewResult = await Controller.EditBlockFacility(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(); }
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(); }
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()); } }
public async void GetAllAsync_ReturnsAllFromContext() { var expectedBookings = BookingGenerator.CreateList(); using (var context = new booking_facilitiesContext(contextOptions)) { context.Database.EnsureCreated(); context.Booking.AddRange(expectedBookings); context.SaveChanges(); Assert.Equal(expectedBookings.Count, await context.Booking.CountAsync()); var repository = new BookingRepository(context); var resources = repository.GetAllAsync(); Assert.IsAssignableFrom <IQueryable <Booking> >(resources); Assert.Equal(expectedBookings, resources); } }
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 async void GetByIdAsync_ReturnsCorrectItems() { var bookings = BookingGenerator.CreateList(5); var expected = bookings[2]; using (var context = new booking_facilitiesContext(contextOptions)) { context.Database.EnsureCreated(); context.Booking.AddRange(bookings); await context.SaveChangesAsync(); Assert.True(true); Assert.Equal(bookings.Count, await context.Booking.CountAsync()); var repository = new BookingRepository(context); var booking = await repository.GetByIdAsync(expected.BookingId); Assert.IsType <Booking>(booking); Assert.Equal(expected, booking); } }
public void Delete_ShowsCorrectView() { bookingRepository.Setup(r => r.GetByIdAsync(1)).ReturnsAsync(BookingGenerator.Create()); //implement Assert.Null(1); }