public void ModifyNonExistingCloseOutThrowsValidationException() { // Arrange ICloseoutDao closeoutDao = MockRepository.GenerateMock<ICloseoutDao>(); closeoutManager = new CloseoutManager(); closeoutManager.CloseoutDao = closeoutDao; closeoutDao.Expect(c => c.GetByKey(1, 1)).Return(null); // CloseOut Record Closeout updatecloseOut = new Closeout() { Id = 1, BusinessId = 1, RoomId = 1, StartDate = new DateTime(2020, 5, 3, 0, 0, 0, DateTimeKind.Utc), EndDate = new DateTime(2020, 5, 4, 0, 0, 0, DateTimeKind.Utc), Description = "Updated", CloseoutReasonId = 1 }; closeoutDao.Stub(x => x.Modify(updatecloseOut)); try { //Act // Modify closeOut Record closeoutManager.Modify(updatecloseOut); Assert.Fail("And exception SRVEX30024 of type ValidationException should have been thrown"); } catch(ValidationException ex) { //Assert Assert.AreEqual("SRVEX30024", ex.Code, "The Validation exception SRVEX30024 is not returned"); } }
/// <summary> /// Fill up the diary with blocks in all the dates /// </summary> /// <param name="businessId">business</param> /// <param name="startDate">start date</param> /// <param name="endDate">end date</param> /// <param name="cultureCode">culture for room info</param> public static void FillDateRangeWithBlocks(long businessId, DateTime startDate, DateTime endDate, string cultureCode) { RoomInformationManager roomManager = new RoomInformationManager(); Model.Room.RoomInformation roomInfo = roomManager.GetRoomInformation(businessId, cultureCode); CloseoutManager closeoutManager = new CloseoutManager(); while (startDate.Date < endDate.Date) { foreach (Model.Room.RoomType rt in roomInfo.RoomTypes) { foreach (Model.Room.Room r in rt.Rooms) { try { closeoutManager.CreateCloseout(new Closeout { BusinessId = businessId, CloseoutReasonId = 1, StartDate = startDate, EndDate = startDate.AddDays(1), RoomId = r.Id, Description = "Load testing" }); } catch { // its ok, continue on, means there already was a block there } } } startDate = startDate.AddDays(1); } }
public void ModifyCloseoutWithCorrectInfoIsSuccessful() { // Arrange ICloseoutDao closeoutDao = MockRepository.GenerateMock<ICloseoutDao>(); closeoutManager = new CloseoutManager(); closeoutManager.CloseoutDao = closeoutDao; closeoutDao.Expect(c => c.GetByKey(1, 1)).Return(new Closeout() { Id=1, BusinessId = 1, RoomId = 1, StartDate = new DateTime(2020, 5, 1, 0, 0, 0, DateTimeKind.Utc), EndDate = new DateTime(2020, 5, 2, 0, 0, 0, DateTimeKind.Utc), CloseoutReasonId = 1 }); // CloseOut Record Closeout updatecloseOut = new Closeout() { Id = 1, BusinessId = 1, RoomId = 1, StartDate = new DateTime(2020, 5, 3, 0, 0, 0, DateTimeKind.Utc), EndDate = new DateTime(2020, 5, 4, 0, 0, 0, DateTimeKind.Utc), Description = "", CloseoutReasonId = 1 }; closeoutDao.Expect(x => x.Modify(updatecloseOut)); // Act // Modify closeOut Record closeoutManager.Modify(updatecloseOut); // Assert closeoutDao.VerifyAllExpectations(); }