Beispiel #1
0
        public async void TestForDeleteTeamArticle()
        {
            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            teamArticle    = new TeamArticle()
                {
                    ArticleID = Guid.NewGuid(),
                    Title     = "free hotdogs",
                    Body      = "come today to get your hotdogs!",
                    Date      = DateTime.Now,
                    IsPinned  = true,
                    IsVisible = true,
                    TeamID    = Guid.NewGuid()
                };
                r.TeamArticles.Add(teamArticle);
                await r.CommitSave();

                Assert.NotEmpty(context.TeamArticles);

                await newsController.DeleteTeamArticle(teamArticle.ArticleID);

                Assert.Null(context.TeamArticles.Find(teamArticle.ArticleID));
            }
        }