public void WhenANewArticleIsAdded_TheNumberOfArticlesIncreasesBy1() { using (var db = new SportsblogContext()) { var numberOfArticlesBefore = db.Articles.Count(); _articleManager.Create("Test", "Test Article", "Dylan Lewis", "This article is a test"); var numberOfArticlesAfter = db.Articles.Count(); Assert.AreEqual(numberOfArticlesBefore + 1, numberOfArticlesAfter); } }
private void ButtonCreate_Click(object sender, RoutedEventArgs e) { _articleManager.Create(TextId.Text, TextTitle.Text, ComboAuthor.Text, TextContent.Text); MainWindow mainWindow = new MainWindow(); mainWindow.Show(); this.Close(); }
internal static Article Create(IDataStore dataStore, IApplicationSettings applicationSettings, IApplication application , IUserBasic author, ArticleGroupThread articleGroupThread , MessageBoard messageBoard , Random random) { ArticleManager manager = new ArticleManager(dataStore); Article article = new Article( author , articleGroupThread , DebugUtility.GetRandomEnum <ArticleStatus>(random) , DebugUtility.GetRandomEnum <ArticleType>(random) , "Article Subject" + random.Next(1000000, 10000000) , "Article Body" + random.Next(1000000, 10000000) , "URLName" + random.Next(1000000, 10000000) , DebugUtility.FlipCoin(random)); int count = random.Next(0, 10); for (int i = 0; i < count; i++) { article.ContentLevelNodeNames.Add("Category " + i + (DebugUtility.FlipRiggedCoin(random, .2) ? " " + random.Next(10000, 100000) : string.Empty)); } BusinessObjectActionReport <DataRepositoryActionStatus> report = manager.Create(article, messageBoard.MessageBoardId, DebugUtility.FlipCoin(random)); Assert.AreEqual(DataRepositoryActionStatus.Success, report.Status); Assert.Greater(article.ArticleId, 0); Article dsArticle = manager.GetArticle(article.ArticleId); Assert.IsNotNull(dsArticle); IArticleModel articelModel = manager.GetArticleModel(dsArticle.ArticleId); Assert.AreEqual(article.ContentLevelNodeNames.Count, articelModel.ContentLevelNodes.Count); for (int i = 0; i < article.ContentLevelNodeNames.Count; i++) { Assert.AreEqual(article.ContentLevelNodeNames[i], articelModel.ContentLevelNodes[i]); } return(dsArticle); }