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"); } }
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(); }