private void EnsureDbDeleted()
 {
     using (var dbContext = new StubDbContext(DbOptions))
     {
         dbContext.Database.EnsureDeleted();
     }
 }
Exemple #2
0
        public StubDbContext Build()
        {
            using (var context = new StubDbContext(_dbOptions))
            {
                context.StubDbModels.AddRange(_models);
                _models.Clear();
                context.SaveChanges();
            }

            return(new StubDbContext(_dbOptions));
        }
        public async System.Threading.Tasks.Task GetCategoriesAsync_NotInCache_GetCategoriesFromDatabase()
        {
            //Arrange
            NorthwindDbContext stubNorthwindDBContext = StubDbContext.GetContextWithData();
            FakeCache          fakeCache    = new FakeCache(false);
            MockLogger         mockLogger   = new MockLogger();
            NorthwindDAL       northwindDAL = new NorthwindDAL(stubNorthwindDBContext, fakeCache, mockLogger);

            //Act
            IList <Category> Categories = await northwindDAL.GetCategoriesAsync();

            //Assert
            Assert.IsTrue(mockLogger.DidLog("##Start## GetCategories from database."));
        }
        public async System.Threading.Tasks.Task GetCategoriesAsync_InCache_GetCategoriesFromCacheAsync()
        {
            //Arrange
            NorthwindDbContext stubNorthwindDBContext = StubDbContext.GetContextWithData();
            FakeCache          fakeCache = new FakeCache(true);
            //fakeCache.Set("", "categories");
            MockLogger mockLogger = new MockLogger();

            NorthwindDAL northwindDAL = new NorthwindDAL(stubNorthwindDBContext, fakeCache, mockLogger);

            //Act
            IList <Category> Categories = await northwindDAL.GetCategoriesAsync();

            //Assert
            //Assert.IsNotNull(Categories);
            Assert.IsTrue(mockLogger.DidLog("##Start## GetCategories from cache."));
        }