コード例 #1
0
        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);
        }