public void GetZipCodesCount_CallsDataStore() { var dataStoreMock = new Mock <IDataStore>(MockBehavior.Loose); var locationServiceMock = new Mock <ILocationService>(MockBehavior.Loose); var repository = new ZipCodesRepository( dataStoreMock.Object, locationServiceMock.Object ); // act var result = repository.GetZipCodesCount(0); // assert dataStoreMock.Verify(mock => mock.Count(It.IsAny <Expression <Func <ZipCodeModel, bool> > >()), Times.Once()); }
public void GetZipCodesCount_ReturnsCorrectData() { // arrange var dataStoreMock = new Mock <IDataStore>(MockBehavior.Loose); dataStoreMock.Setup(mock => mock.Count(It.IsAny <Expression <Func <ZipCodeModel, bool> > >())) .Returns(3); var locationServiceMock = new Mock <ILocationService>(MockBehavior.Loose); var repository = new ZipCodesRepository( dataStoreMock.Object, locationServiceMock.Object ); // act var result = repository.GetZipCodesCount(0); // assert Assert.AreEqual(3, result); }