public DatabaseFixture() { var options = new DbContextOptionsBuilder <NewsDbContext>() .UseInMemoryDatabase(databaseName: "NewsDB") .Options; dbcontext = new NewsDbContext(options); dbcontext.Articles.Add(new Article { Id = 1, Author = "author1", Comments = "comments1", Content = "content1", Description = "description1", PublishedAt = "11-11-2011", Title = "title1", Url = "url1", UrlToImage = "UrlToImage1" }); dbcontext.Articles.Add(new Article { Id = 2, Author = "author2", Comments = "comments2", Content = "content2", Description = "description2", PublishedAt = "11-11-2011", Title = "title2", Url = "url2", UrlToImage = "UrlToImage2" }); dbcontext.Articles.Add(new Article { Id = 3, Author = "author3", Comments = "comments3", Content = "content3", Description = "description3", PublishedAt = "11-11-2011", Title = "title13", Url = "url3", UrlToImage = "UrlToImage3" }); dbcontext.SaveChanges(); }
public DatabaseFixture() { var options = new DbContextOptionsBuilder <NewsDbContext>() .UseInMemoryDatabase(databaseName: "NewsDB") .Options; dbContext = new NewsDbContext(options); dbContext.News.Add(new News { Id = 1, Author = "ANI", Title = "news 1 title", Description = "news 1 description", PublishedAt = DateTime.Now, Url = "https://example.com/news1", UrlToImage = "https://example.com/news1image.jpg" }); dbContext.News.Add(new News { Id = 2, Author = "TOI", Title = "news 2 title", Description = "news 2 description", PublishedAt = DateTime.Now, Url = "https://example.com/news2", UrlToImage = "https://example.com/news2image.jpg" }); dbContext.News.Add(new News { Id = 3, Author = "TheHindu", Title = "news 3 title", Description = "news 3 description", PublishedAt = DateTime.Now, Url = "https://example.com/news3", UrlToImage = "https://example.com/news3image.jpg" }); dbContext.News.Add(new News { Id = 4, Author = "MoneyControl", Title = "news 4 title", Description = "news 4 description", PublishedAt = DateTime.Now, Url = "https://example.com/news4", UrlToImage = "https://example.com/news4image.jpg" }); dbContext.SaveChanges(); }
public DatabaseFixture() { var options = new DbContextOptionsBuilder <NewsDbContext>() .UseInMemoryDatabase(databaseName: "NewsDB") .Options; dbContext = new NewsDbContext(options); dbContext.News.Add(new News { NewsId = 1, Author = "Jafer", Title = "Facebook", Category = "Technoloy", Description = "desc", Id = 11, PublishedAt = DateTime.Now, Url = "https://newsdb.org", UrlToImage = "https://newsdb.org" }); dbContext.News.Add(new News { NewsId = 2, Author = "Jafer", Title = "WhatsUp", Category = "Technoloy", Description = "desc", Id = 22, PublishedAt = DateTime.Now, Url = "https://newsdb.org", UrlToImage = "https://newsdb.org" }); dbContext.News.Add(new News { NewsId = 3, Author = "Jafer", Title = "Twitter", Category = "Technoloy", Description = "desc", Id = 33, PublishedAt = DateTime.Now, Url = "https://newsdb.org", UrlToImage = "https://newsdb.org" }); dbContext.News.Add(new News { NewsId = 4, Author = "Jafer", Title = "Ola", Category = "general", Description = "desc", Id = 44, PublishedAt = DateTime.Now, Url = "https://newsdb.org", UrlToImage = "https://newsdb.org" }); dbContext.SaveChanges(); }
public NewsRepository(INewsDbContext context) { _context = context; }
public NewsRepository(INewsDbContext dbContext) { DbContext = dbContext; }
public CachedNewsRepository(INewsDbContext dbContext, INewsCacheService cacheService) : base(dbContext) { CacheService = cacheService; }
public NewsData(INewsDbContext context) { this.context = context; this.repositories = new Dictionary<Type, object>(); }
/// <summary> /// Initializes a new instance of the <see cref="NewsRepository"/> class. /// </summary> /// <param name="db">The database.</param> public NewsRepository(NewsDbContext db, ServiceProvider provider) { this.db = db; this.provider = provider; db.Database.Migrate(); }
public GenericRepository(INewsDbContext context) { this.context = context; }
public void Dispose() { NewsList = null; dbContext = null; }
public void Dispose() { AllNews = null; dbContext = null; }
public void Dispose() { Articles = null; dbcontext = null; }