public void All_ReturnsItems_FromCache() { //Arrange CacheRepository <Storeable> myCacheRepository = new CacheRepository <Storeable>(new List <Storeable>()); BusinessLogicService <Storeable> myBusinessLogicService = new BusinessLogicService <Storeable>(myCacheRepository); var storeable = new Storeable { Description = "i1", Id = 1, StoreId = 1 }; myBusinessLogicService.Save((Storeable)Convert.ChangeType(storeable, typeof(Storeable))); var resultItems = myBusinessLogicService.All(); Assert.IsNotNull(resultItems); //Assert.AreEqual(1, resultItems.Count()); }
public void All_ReturnsItems() { //Arrange var myDbRepositoryMock = new Mock <IDbRepository <Storeable> >(); var storeable = new Storeable { Description = "i1", Id = 1, StoreId = 1 }; List <Storeable> list = new List <Storeable>(); list.Add(storeable); myDbRepositoryMock.Setup(x => x.All()).Returns(() => new List <Storeable>(list)); BusinessLogicService <Storeable> myBusinessLogicService = new BusinessLogicService <Storeable>(myDbRepositoryMock.Object); var returned = myBusinessLogicService.All(); Assert.AreEqual(1, returned.Count()); }