public void GetDiaryNotesByBusinessBetweenDatesForInvalidDatesThrowsException() { // Arrange DateTime startDate = new DateTime(2012, 1, 5, 0, 0, 0, DateTimeKind.Utc); DateTime endDate = new DateTime(2012, 1, 2, 0, 0, 0, DateTimeKind.Utc); long businessId = 3; var diaryNoteDao = new Mock<IDiaryNoteDao>(); var diaryDataRetrievalMgr = new DiaryDataRetrievalManager { DiaryNoteDao = diaryNoteDao.Object }; // act CheckForEviivoException<ValidationException>(() => diaryDataRetrievalMgr.GetCloseoutsByBusinessBetweenDates(businessId, startDate, endDate), "Wrong dates did not throw correct error code.", "SRVEX30002"); // assert diaryNoteDao.Verify( c => c.GetBetweenDates(It.IsAny<long>(), It.IsAny<DateTime>(), It.IsAny<DateTime>()), Times.Never()); }
public void GetCloseoutsByBusinessBetweenDatesValidDatesReturnsCloseouts() { // Arrange // Parameters for the invoke var startDate = new DateTime(2012, 1, 1, 0, 0, 0, DateTimeKind.Utc); var endDate = new DateTime(2012, 1, 5, 0, 0, 0, DateTimeKind.Utc); long businessId = 1; var closeoutDao = new Mock<ICloseoutDao>(); var diaryDataRetrievalMgr = new DiaryDataRetrievalManager { CloseoutDao = closeoutDao.Object }; // Create a list with 2 entries var closeouts = new List<Closeout> { new Closeout { Id = 12345 }, new Closeout { Id = 54321 } }; closeoutDao.Setup(x => x.GetBetweenDates(businessId, startDate, endDate)).Returns(closeouts); // Act var resultCloseouts = diaryDataRetrievalMgr.GetCloseoutsByBusinessBetweenDates(businessId, startDate, endDate); // Assert // Check expectations tests Assert.AreEqual(closeouts.Count, resultCloseouts.Count, "Check that correct number of Checkouts are returned."); closeoutDao.Verify(c => c.GetBetweenDates(businessId, startDate, endDate), Times.Once); }