public void Task_GetAppointmentById_MatchResult() { //Arrange var eppointmentId = 1; var eppointmentOrganizerId = 1; IQueryable <Appointment> eppointmentList = new List <Appointment>() { new Appointment() { OrganizerId = eppointmentOrganizerId, Id = eppointmentId } }.AsQueryable(); AppointmentRepositoryMock.Setup(m => m.GetById(eppointmentId)).Returns(eppointmentList.FirstOrDefault(s => s.Id == eppointmentId)).Verifiable(); //Act var actual = AppointmentsBusinessManager.GetById(eppointmentId); //Assert Assert.IsInstanceOfType(actual, typeof(Appointment)); //passes Assert.AreEqual(eppointmentId, actual.Id); //assert that actual result was as expected Assert.AreEqual(eppointmentOrganizerId, actual.OrganizerId); //assert that actual result was as expected }
public void Task_GetNotFoundAppointmentById_Return_Null() { //Arrange var eppointmentId = 1; var notFoundAppointmentId = 2; var expected = 1; IQueryable <Appointment> eppointmentList = new List <Appointment>() { new Appointment() { OrganizerId = expected, Id = eppointmentId } }.AsQueryable(); AppointmentRepositoryMock.Setup(m => m.GetById(notFoundAppointmentId)).Returns(eppointmentList.FirstOrDefault(s => s.Id == notFoundAppointmentId)).Verifiable(); //Act var actual = AppointmentsBusinessManager.GetById(notFoundAppointmentId); //Assert AppointmentRepositoryMock.Verify(); //verify that GetByID was called based on setup. Assert.IsNull(actual); //assert that a result was returned }