Esempio n. 1
0
        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 SaveCalledOnce()
        {
            //Arrange
            var myDbRepository = new Mock <IDbRepository <Storeable> >();

            var storeable = new Storeable {
                Description = "i1", Id = 1, StoreId = 1
            };

            myDbRepository.Setup(x => x.Save(storeable)).Verifiable();
            BusinessLogicService <Storeable> myBusinessLogicService = new BusinessLogicService <Storeable>(myDbRepository.Object);


            myBusinessLogicService.Save(storeable);

            myDbRepository.Verify(x => x.Save(storeable), Times.Once());
        }