public void GetAll_via_context() { var expectedContactsQueryable = MockHelper.ContactTestCollection; var mockContactTestCollection = MockHelper.CreateMockDbSet(expectedContactsQueryable); var contactServiceMock = new Mock <IContactService>(); contactServiceMock.Setup(c => c.GetAll()).Returns(mockContactTestCollection.Object); var actualContacts = contactServiceMock.Object.GetAll().ToList(); var expectedContacts = expectedContactsQueryable.ToList(); Assert.IsTrue(actualContacts.Count == expectedContacts.Count); CollectionAssert.AreEqual(actualContacts, expectedContacts); }