Ejemplo n.º 1
0
        public async Task Shoud_Return_404_When_Book_Does_Not_Exist()
        {
            var bookingsBusiness = Substitute.For <IBookingsBusiness>();

            bookingsBusiness.DeleteABookingAsync(1).Returns(Task.FromResult <Booking>(null));
            var           roomsBusiness      = Substitute.For <IRoomsBusiness>();
            var           bookingsController = new BookingsController(bookingsBusiness, roomsBusiness);
            IActionResult response           = await bookingsController.DeleteABookAsync(1);

            Assert.IsInstanceOf(typeof(NotFoundResult), response);
            var objectResult = (NotFoundResult)response;

            Assert.AreEqual(404, objectResult.StatusCode);
        }
Ejemplo n.º 2
0
        public async Task Shoud_Delete_A_Book()
        {
            //var fixture = new Fixture();
            var booking = fixture.Build <Booking>()
                          .With(b => b.Id, 1)
                          .Create();
            var bookingsBusiness = Substitute.For <IBookingsBusiness>();

            bookingsBusiness.DeleteABookingAsync(1).Returns(booking);
            var roomsBusiness = Substitute.For <IRoomsBusiness>();

            roomsBusiness.GetRoomsAsync().Returns(new List <Room> {
                booking.Room
            });
            var           bookingsController = new BookingsController(bookingsBusiness, roomsBusiness);
            IActionResult response           = await bookingsController.DeleteABookAsync(1);

            Assert.IsInstanceOf(typeof(OkResult), response);
            var objectResult = (OkResult)response;

            Assert.AreEqual(200, objectResult.StatusCode);
        }