public void GetAll_RetrieveAllConferencesInDb_AllConferences() { var conferences = new List <Conference>() { new Conference() { DisplayName = "Eva's conference", StartDate = DateTime.UtcNow, EndDate = DateTime.UtcNow }, new Conference() { DisplayName = "Grant's conference", StartDate = DateTime.UtcNow, EndDate = DateTime.UtcNow, } }; var mockConferenceService = new Mock <IConferenceService>(); mockConferenceService.Setup(m => m.GetAll()).Returns(conferences); var conferenceController = new ConferenceController(mockConferenceService.Object); var result = conferenceController.GetAllConferences().Value; Assert.AreEqual(conferences.Count, result.Count()); foreach (var conf in conferences) { Assert.IsTrue(result.Contains(conf)); } mockConferenceService.Verify(cs => cs.GetAll(), Times.Once()); }
public void GetAll_NothingInDb_EmptyResult() { var mockConferenceService = new Mock <IConferenceService>(); mockConferenceService.Setup(c => c.GetAll()).Returns(new List <Conference>()); var conferenceController = new ConferenceController(mockConferenceService.Object); var result = conferenceController.GetAllConferences().Value; Assert.AreEqual(0, result.Count()); mockConferenceService.Verify(cs => cs.GetAll(), Times.Once()); }