public void GetRefoodUsersPaged_Success_Test() { // Arrange string searchTerm = ""; int pageIndex = 0; int pageSize = 10; // list IList <R_RefoodUser> list = new List <R_RefoodUser>(); for (int i = 1; i <= pageSize; i++) { list.Add(SampleRefoodUser(i)); } // create mock for repository var mock = new Mock <IRefoodUserRepository>(); mock.Setup(s => s.GetRefoodUsers(Moq.It.IsAny <string>(), Moq.It.IsAny <int>(), Moq.It.IsAny <int>())).Returns(list); // service RefoodUserService refoodUserService = new RefoodUserService(); RefoodUserService.Repository = mock.Object; // Act var resultList = refoodUserService.GetRefoodUsers(searchTerm, pageIndex, pageSize); RefoodUserDTO result = resultList.FirstOrDefault(); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.RefoodUserId); Assert.AreEqual(10, resultList.Count); }
public void GetRefoodUsers_Success_Test() { // Arrange R_RefoodUser refoodUser = SampleRefoodUser(1); IList <R_RefoodUser> list = new List <R_RefoodUser>(); list.Add(refoodUser); // create mock for repository var mock = new Mock <IRefoodUserRepository>(); mock.Setup(s => s.GetRefoodUsers()).Returns(list); // service RefoodUserService refoodUserService = new RefoodUserService(); RefoodUserService.Repository = mock.Object; // Act var resultList = refoodUserService.GetRefoodUsers(); RefoodUserDTO result = resultList.FirstOrDefault(); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.RefoodUserId); }