public void ListPatientsBySurnameAndCityTest() { var patients = new List <Patient>() { new Patient() { Id = 1, PhoneNumber = "12456343", Name = "John", Surname = "Smith", Address = new Address { City = "Warsaw" }, PESELNumber = "11111111111" }, new Patient() { Id = 2, PhoneNumber = "87984564", Name = "Pete", Surname = "Luck", Address = new Address { City = "Poznań" }, PESELNumber = "22222222222" } }.AsQueryable(); var mockSet = new Mock <DbSet <Patient> >(); mockSet.As <IQueryable <Patient> >().Setup(m => m.Provider).Returns(patients.Provider); mockSet.As <IQueryable <Patient> >().Setup(m => m.Expression).Returns(patients.Expression); mockSet.As <IQueryable <Patient> >().Setup(m => m.ElementType).Returns(patients.ElementType); mockSet.As <IQueryable <Patient> >().Setup(m => m.GetEnumerator()).Returns(patients.GetEnumerator()); var mockContext = new Mock <SurgeryModelContainer>(); mockContext.Setup(c => c.Patients).Returns(mockSet.Object); var service = new DBModels(mockContext.Object); var patientsAll = service.ListPatientsByNameSurnameAndCity("John", "Smith", "Warsaw", 0, 10); Assert.AreEqual(1, patientsAll.Count); Assert.AreEqual("John", patientsAll[0].Name); }