コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ThemeId,ArticleId")] ThemeArticle themeArticle)
        {
            if (id != themeArticle.ThemeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(themeArticle);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ThemeArticleExists(themeArticle.ThemeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ArticleId"] = new SelectList(_context.Article, "Id", "Name", themeArticle.ArticleId);
            ViewData["ThemeId"]   = new SelectList(_context.Theme, "Id", "Name", themeArticle.ThemeId);
            return(View(themeArticle));
        }
コード例 #2
0
        public void Three_articles_in_two_themes_with_keyword_in_common()
        {
            var article1 = new ThemeArticle(new[] { "coronavirus", "italie" });
            var article2 = new ThemeArticle(new[] { "coronavirus", "china" });
            var article3 = new ThemeArticle(new[] { "coronavirus", "china" });

            _themeManager.Add(article1);
            _themeManager.Add(article2);
            _themeManager.Add(article3);

            var events = _themeManager.UncommittedEvents;

            events
            .OfType <NewThemeCreated>()
            .Should()
            .BeEquivalentTo(new[] {
                new {
                    Keywords = new[] { "coronavirus" },
                    Articles = new[] { article1, article2 }
                },
                new {
                    Keywords = new[] { "coronavirus", "china" },
                    Articles = new[] { article2, article3 }
                }
            });

            events
            .OfType <ArticleAddedToTheme>()
            .Should()
            .BeEquivalentTo(new { Article = article3 });
        }
コード例 #3
0
        public void A_single_article_does_not_create_theme()
        {
            var article = new ThemeArticle(new[] { "test 1" });

            _themeManager.Add(article);

            _themeManager.UncommittedEvents
            .Should()
            .BeEmpty();
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("ThemeId,ArticleId")] ThemeArticle themeArticle)
        {
            if (ModelState.IsValid)
            {
                _context.Add(themeArticle);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ArticleId"] = new SelectList(_context.Article, "Id", "Name", themeArticle.ArticleId);
            ViewData["ThemeId"]   = new SelectList(_context.Theme, "Id", "Name", themeArticle.ThemeId);
            return(View(themeArticle));
        }
コード例 #5
0
        public void Two_articles_with_same_keywords_create_theme_with_keyword_intersection()
        {
            var article1 = new ThemeArticle(new[] { "coronavirus", "italie" });
            var article2 = new ThemeArticle(new[] { "coronavirus", "china" });

            _themeManager.Add(article1);
            _themeManager.Add(article2);

            _themeManager.UncommittedEvents
            .Should()
            .BeEquivalentTo(new {
                Keywords = new[] { "coronavirus" },
                Articles = new[] { article1, article2 }
            });
        }
コード例 #6
0
        public void Three_articles_create_two_themes()
        {
            var article1 = new ThemeArticle(new[] { "coronavirus", "italie" });
            var article2 = new ThemeArticle(new[] { "coronavirus", "china" });
            var article3 = new ThemeArticle(new[] { "opera", "china" });

            _themeManager.Add(article1);
            _themeManager.Add(article2);
            _themeManager.Add(article3);

            _themeManager.UncommittedEvents
            .Should()
            .BeEquivalentTo(new[] {
                new {
                    Keywords = new[] { "coronavirus" },
                    Articles = new[] { article1, article2 }
                },
                new {
                    Keywords = new[] { "china" },
                    Articles = new[] { article2, article3 }
                }
            });
        }