Пример #1
0
        public void Test_Validate_BookingModel_Fail()
        {
            // This test method will need to be updated on January 1st, 2021, becasue the BookingModel class checks
            // to make sure that the check in date is not earlier than "today's date"
            BookingModel booking = new BookingModel()
            {
                EntityId      = 0,
                AccountId     = 0,
                LodgingId     = 0,
                Guests        = null,
                Rentals       = null,
                CheckIn       = new DateTime(2020, 12, 1),
                CheckOut      = new DateTime(2021, 12, 2),
                BookingNumber = Guid.NewGuid()
            };
            var validationContext = new ValidationContext(booking);

            Assert.NotEmpty(booking.Validate(validationContext));

            booking.Guests    = new List <GuestModel>();
            validationContext = new ValidationContext(booking);
            Assert.NotEmpty(booking.Validate(validationContext));

            booking.Rentals   = new List <RentalModel>();
            validationContext = new ValidationContext(booking);
            Assert.NotEmpty(booking.Validate(validationContext));

            booking.CheckIn   = new System.DateTime(2021, 12, 2);
            validationContext = new ValidationContext(booking);
            Assert.NotEmpty(booking.Validate(validationContext));
        }
        public void Test_Validate_BookingModel(BookingModel booking)
        {
            var validationContext = new ValidationContext(booking);

            Assert.Empty(booking.Validate(validationContext));
        }