Beispiel #1
0
        public async void TestForCreateLeagueArticle()
        {
            //for coverage
            var dbContext = new NewsContext();

            var options = new DbContextOptionsBuilder <NewsContext>()
                          .UseInMemoryDatabase(databaseName: "p3NewsService")
                          .Options;

            using (var context = new NewsContext(options))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                Repo           r                = new Repo(context, new NullLogger <Repo>());
                Logic          logic            = new Logic(r, new NullLogger <Repo>());
                NewsController newsController   = new NewsController(logic);
                var            leagueArticleDto = new LeagueArticleDto()
                {
                    ArticleID = Guid.NewGuid(),
                    Title     = "free hotdogs",
                    Content   = "come today to get your hotdogs!",
                    Date      = DateTime.Now,
                    IsPinned  = true,
                    IsVisible = true
                };

                await newsController.CreateLeagueArticle(leagueArticleDto);

                Assert.NotNull(context.LeagueArticles);
            }
        }