public void TestInitialize()
 {
     BookingStateCreateModel = new BookingStateCreateModel()
     {
         Id          = 1,
         State       = "Creada",
         Description = "A description",
     };
 }
Exemple #2
0
        public void PostBookingStateInvalidModelReturnsError400()
        {
            const int BOOKING_ID = 2;
            var       bookingStateCreateModel = new BookingStateCreateModel
            {
                Id          = BOOKING_ID,
                State       = null,
                Description = "Description"
            };
            var bookingController = new BookingController(BookingLogicMock.Object, BookingStateLogicMock.Object, LodgingReviewLogicMock.Object);
            var result            = bookingController.PostState(BOOKING_ID, bookingStateCreateModel) as BadRequestObjectResult;

            Assert.AreEqual(result.StatusCode, 400);
        }
        public IActionResult PostState(int id, BookingStateCreateModel bookingStateCreateModel)
        {
            bookingStateCreateModel.Id = id;
            
            IActionResult result;
            if (bookingStateCreateModel.HasErrors())
            {
                result = BadRequest(new ErrorModel(bookingStateCreateModel.Errors()));
            }
            else
            {
                var bookingState = BookingStateLogic.Create(bookingStateCreateModel.ToEntity());
                result = Created("GetBookingState", new BookingStateBasicInfoModel(bookingState));
            }

            return result;
        }
Exemple #4
0
        public void PostStateReturnsValidBookingHas201StatusCode()
        {
            const int BOOKING_ID = 2;
            var       bookingStateCreateModel = new BookingStateCreateModel()
            {
                Id          = BOOKING_ID,
                State       = "Creada",
                Description = "Description"
            };
            var bookingState = bookingStateCreateModel.ToEntity();

            BookingStateLogicMock.Setup(m => m.Create(It.IsAny <BookingState>())).Returns(bookingState);

            var bookingController = new BookingController(BookingLogicMock.Object,
                                                          BookingStateLogicMock.Object,
                                                          LodgingReviewLogicMock.Object);
            var result = bookingController.PostState(BOOKING_ID, bookingStateCreateModel) as CreatedResult;

            BookingStateLogicMock.VerifyAll();
            Assert.AreEqual(result.StatusCode, 201);
        }