public void AddingHotelRoomToHotel() { var UoW = new Mock <UnitOfWork>(); UoW.Object.DeleteDB(); var HotelLogic = new HotelLogic(UoW.Object); var UserLogic = new UserLogic(UoW.Object); UserLogic.AddUser(new Logic.DTOs.UserDTO("Sasha", Logic.DTOs.UserType.Manager, "Veklych", "Login", "Password")); UserLogic.Login("Login", "Password"); HotelLogic.AddHotel(new Logic.DTOs.HotelDTO("Verkhovina", 3, "Khust, Zhayvoronkova 44/2")); HotelLogic.AddHotelRoom(HotelLogic.GetAllHotels().ToList()[0].Id, new Logic.DTOs.HotelRoomDTO(1, 3, 250)); Assert.That(UoW.Object.HotelsRooms.GetAll().Count() == 1); Assert.That(HotelLogic.GetAllHotels().ToList()[0].Rooms.Count() == 1); Assert.That(HotelLogic.GetAllHotels().ToList()[0].Rooms[0].Hotel.Id == HotelLogic.GetAllHotels().ToList()[0].Id); Assert.That(HotelLogic.GetAllHotels().ToList()[0].Rooms[0].Number == 1); Assert.That(HotelLogic.GetAllHotels().ToList()[0].Rooms[0].SleepingPlaces == 3); Assert.That(HotelLogic.GetAllHotels().ToList()[0].Rooms[0].Price == 250); }
public void AddingHotelRoomToHotel() { var UoW = new Mock <UnitOfWork>(); UoW.Object.DeleteDB(); var HotelLogic = new HotelLogic(UoW.Object); var UserLogic = new UserLogic(UoW.Object); UserLogic.AddUser(new Logic.DTOs.UserDTO("Dimon", Logic.DTOs.UserType.Manager, "Cherneckii", "Login", "Password")); UserLogic.Login("Login", "Password"); HotelLogic.AddHotel(new Logic.DTOs.HotelDTO("auiwhe", 3, "auiwhe--, petuch 44/2")); HotelLogic.AddHotelRoom(HotelLogic.GetAllHotels().ToList()[0].Id, new Logic.DTOs.HotelRoomDTO(1, 3, 250)); Assert.That(UoW.Object.HotelsRooms.GetAll().Count() == 1); Assert.That(HotelLogic.GetAllHotels().ToList()[0].Rooms.Count() == 1); Assert.That(HotelLogic.GetAllHotels().ToList()[0].Rooms[0].Hotel.Id == HotelLogic.GetAllHotels().ToList()[0].Id); Assert.That(HotelLogic.GetAllHotels().ToList()[0].Rooms[0].Number == 1); Assert.That(HotelLogic.GetAllHotels().ToList()[0].Rooms[0].SleepingPlaces == 3); Assert.That(HotelLogic.GetAllHotels().ToList()[0].Rooms[0].Price == 250); }
public void ReservingRoom() { var UoW = new Mock <UnitOfWork>(); UoW.Object.DeleteDB(); var UserLogic = new UserLogic(UoW.Object); var HotelLogic = new HotelLogic(UoW.Object); UserLogic.AddUser(new Logic.DTOs.UserDTO("Sasha", Logic.DTOs.UserType.Manager, "Veklych", "Login", "Password")); UserLogic.Login("Login", "Password"); HotelLogic.AddHotel(new Logic.DTOs.HotelDTO("Verkhovina", 3, "Khust, Zhayvoronkova 44/2")); HotelLogic.AddHotelRoom(HotelLogic.GetAllHotels().ToList()[0].Id, new Logic.DTOs.HotelRoomDTO(1, 3, 250)); Assert.That(UoW.Object.HotelsRooms.GetAll().Count() == 1); Assert.That(HotelLogic.GetAllHotels().ToList()[0].Rooms.Count() == 1); UserLogic.ReserveRoom(1, 1, 1, DateTimeOffset.Parse("21.12.2018"), DateTimeOffset.Parse("25.12.2018")); var User = UserLogic.GetAllUsers().First(u => u.Id == 1); Assert.That(User.HotelRoomReservations.Count == 1); Assert.That(User.HotelRoomReservations[0].HotelAddress == "Khust, Zhayvoronkova 44/2"); Assert.That(User.HotelRoomReservations[0].HotelName == "Verkhovina"); Assert.That(User.HotelRoomReservations[0].HotelRoomNumber == 1); Assert.That(User.HotelRoomReservations[0].HotelRoomPrice == 250); Assert.That(User.HotelRoomReservations[0].HotelRoomSleepingPlaces == 3); Assert.That(User.HotelRoomReservations[0].HotelStars == 3); Assert.That(User.HotelRoomReservations[0].ClientName == "Sasha"); Assert.That(User.HotelRoomReservations[0].ClientSurname == "Veklych"); Assert.That(User.HotelRoomReservations[0].ArrivalDate.CompareTo(DateTimeOffset.Parse("21.12.2018")) == 0); Assert.That(User.HotelRoomReservations[0].DepartureDate.CompareTo(DateTimeOffset.Parse("25.12.2018")) == 0); Assert.That(HotelLogic.GetAllHotels().First(h => h.Id == 1).Rooms.First(r => r.Id == 1).BookedDays.Contains(DateTimeOffset.Parse("21.12.2018"))); Assert.That(HotelLogic.GetAllHotels().First(h => h.Id == 1).Rooms.First(r => r.Id == 1).BookedDays.Contains(DateTimeOffset.Parse("22.12.2018"))); Assert.That(HotelLogic.GetAllHotels().First(h => h.Id == 1).Rooms.First(r => r.Id == 1).BookedDays.Contains(DateTimeOffset.Parse("23.12.2018"))); Assert.That(HotelLogic.GetAllHotels().First(h => h.Id == 1).Rooms.First(r => r.Id == 1).BookedDays.Contains(DateTimeOffset.Parse("24.12.2018"))); Assert.That(!HotelLogic.GetAllHotels().First(h => h.Id == 1).Rooms.First(r => r.Id == 1).BookedDays.Contains(DateTimeOffset.Parse("25.12.2018"))); Assert.Throws <AlreadyBookedItemException>(delegate { UserLogic.ReserveRoom(1, 1, 1, DateTimeOffset.Parse("23.12.2018"), DateTimeOffset.Parse("24.12.2018")); }); UserLogic.ReserveRoom(1, 1, 1, DateTimeOffset.Parse("25.12.2018"), DateTimeOffset.Parse("28.12.2018")); User = UserLogic.GetAllUsers().First(u => u.Id == 1); Assert.That(User.HotelRoomReservations.Count == 2); Assert.That(User.HotelRoomReservations[1].HotelAddress == "Khust, Zhayvoronkova 44/2"); Assert.That(User.HotelRoomReservations[1].HotelName == "Verkhovina"); Assert.That(User.HotelRoomReservations[1].HotelRoomNumber == 1); Assert.That(User.HotelRoomReservations[1].HotelRoomPrice == 250); Assert.That(User.HotelRoomReservations[1].HotelRoomSleepingPlaces == 3); Assert.That(User.HotelRoomReservations[1].HotelStars == 3); Assert.That(User.HotelRoomReservations[1].ClientName == "Sasha"); Assert.That(User.HotelRoomReservations[1].ClientSurname == "Veklych"); Assert.That(User.HotelRoomReservations[1].ArrivalDate.CompareTo(DateTimeOffset.Parse("25.12.2018")) == 0); Assert.That(User.HotelRoomReservations[1].DepartureDate.CompareTo(DateTimeOffset.Parse("28.12.2018")) == 0); Assert.That(HotelLogic.GetAllHotels().First(h => h.Id == 1).Rooms.First(r => r.Id == 1).BookedDays.Contains(DateTimeOffset.Parse("27.12.2018"))); Assert.That(HotelLogic.GetAllHotels().First(h => h.Id == 1).Rooms.First(r => r.Id == 1).BookedDays.Contains(DateTimeOffset.Parse("26.12.2018"))); Assert.That(HotelLogic.GetAllHotels().First(h => h.Id == 1).Rooms.First(r => r.Id == 1).BookedDays.Contains(DateTimeOffset.Parse("25.12.2018"))); Assert.Throws <AlreadyBookedItemException>(delegate { UserLogic.ReserveRoom(1, 1, 1, DateTimeOffset.Parse("19.12.2018"), DateTimeOffset.Parse("30.12.2018")); }); }