public void ReadAll_AddressRecord_ExpectedAllAddressRecords() { mockDataContext.Setup((item) => item.Context).Returns(mockAddressBook.Object); var addressRepository = new DataRepository.AddressRepository(mockLogger.Object, mockDatabaseSettings.Object, mockDataContext.Object); mockAddressBook.Setup((item) => item.SaveChanges()).Returns(1); mockAddressBook.Setup((item) => item.Contacts).Returns(mockedContactDBSet.Object); mockAddressBook.Setup((item) => item.AddressList).Returns(mockedAddressDBSet.Object); Assert.True(addressRepository.ReadAll().FirstOrDefault().Id == 1); }
public void ReadAll_AddressRecord_ExpectedEmptyResult() { mockDataContext.Setup((item) => item.Context).Returns(mockAddressBook.Object); var addressRepository = new DataRepository.AddressRepository(mockLogger.Object, mockDatabaseSettings.Object, mockDataContext.Object); var mockedAddressNoResultDBSet = GetQueryableMockDbSet <DataModel.Address>((new DataModel.Address[] { }).ToList()); mockAddressBook.Setup((item) => item.SaveChanges()).Returns(1); mockAddressBook.Setup((item) => item.Contacts).Returns(mockedContactDBSet.Object); mockAddressBook.Setup((item) => item.AddressList).Returns(mockedAddressNoResultDBSet.Object); Assert.IsEmpty(addressRepository.ReadAll()); }