Esempio n. 1
0
        public void Test_Delete_ArticleGroup()
        {
            IUserBasic   userBasic    = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager);
            MessageBoard messageBoard = Test_MessageBoards.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.Random);

            ArticleGroup       articleGroup       = Test_ArticleGroups.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.Random);
            ArticleGroupThread articleGroupThread = Test_ArticleGroupThreads.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, articleGroup, this.Random);
            Article            article            = Test_Articles.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, userBasic
                                                                         , articleGroupThread, messageBoard, this.Random);

            Test_ArticleGroups.Delete(this.DataStore, articleGroup);

            ArticleGroupThreadManager articleGroupThreadManager = new ArticleGroupThreadManager(this.DataStore);
            ArticleManager            articleManager            = new ArticleManager(this.DataStore);

            Assert.IsNull(articleGroupThreadManager.GetArticleGroupThread(articleGroupThread.ArticleGroupThreadId));
            Assert.IsNull(articleManager.GetArticle(article.ArticleId));
        }
Esempio n. 2
0
        public void Test_CreateUpdateDeleteArticle()
        {
            IUserBasic         userBasic          = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager);
            MessageBoard       messageBoard       = Test_MessageBoards.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.Random);
            ArticleGroup       articleGroup       = Test_ArticleGroups.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.Random);
            ArticleGroupThread articleGroupThread = Test_ArticleGroupThreads.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, articleGroup, this.Random);

            ArticleManager manager = new ArticleManager(this.DataStore);
            Article        record  = Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, userBasic
                                            , articleGroupThread, messageBoard, this.Random);

            MessageBoardThreadManager messageBoardThreadManager = new MessageBoardThreadManager(this.DataStore);

            Article recordToCompare;

            for (int i = 0; i < this.DefaultUpdateTestIterations; i++)
            {
                PopulateWithRandomValues(record, this.DummyDataManager, this.Random);
                recordToCompare = record;

                manager.Update(record);
                record = manager.GetArticle(record.ArticleId);

                string errors = string.Empty;
                // TODO (Roman): relax datetime comparisons
                Assert.IsTrue(DebugUtility.ArePropertyValuesEqual(record, recordToCompare, out errors), errors);
                Trace.WriteLine("Update test successfull.");
            }

            IArticleModel articleModel = manager.GetArticleModel(record.ArticleId);

            Assert.AreEqual(0, articleModel.TotalComments);

            #region messageboards
            MessageBoardThread messageBoardThread = messageBoardThreadManager.GetMessageBoardThread(articleModel.MessageBoardThreadId);
            Assert.IsNotNull(messageBoardThread);

            MessageManager messageManager = new MessageManager(this.DataStore);

            messageManager.Create(new Message(userBasic, messageBoardThread, "Test Message Subject 1", "Body1"));
            messageManager.Create(new Message(userBasic, messageBoardThread, "Test Message Subject 2", "Body2"));

            Message message = new Message(userBasic, messageBoardThread, "Test Message Subject 3", "Body3");
            messageManager.Create(message);

            articleModel = manager.GetArticleModel(record.ArticleId);
            Assert.AreEqual(3, articleModel.TotalComments);

            Assert.AreEqual(DataRepositoryActionStatus.Success, messageManager.Delete(message).Status);
            articleModel = manager.GetArticleModel(record.ArticleId);
            Assert.AreEqual(2, articleModel.TotalComments);
            #endregion

            #region attachments
            IArticleAttachmentModel articleAttachmentModel = AddAttachment(this.DataStore, this.Application.ApplicationId, articleModel, userBasic, this.Random);
            AddAttachment(this.DataStore, this.Application.ApplicationId, articleModel, userBasic, this.Random);

            DeleteAttachment(this.DataStore, articleModel, articleAttachmentModel.AttachmentId, this.Random);

            AddAttachment(this.DataStore, this.Application.ApplicationId, articleModel, userBasic, this.Random);
            AddAttachment(this.DataStore, this.Application.ApplicationId, articleModel, userBasic, this.Random);

            articleAttachmentModel = AddAttachment(this.DataStore, this.Application.ApplicationId, articleModel, userBasic, this.Random);
            DeleteAttachment(this.DataStore, articleModel, articleAttachmentModel.AttachmentId, this.Random);

            AddAttachment(this.DataStore, this.Application.ApplicationId, articleModel, userBasic, this.Random);
            #endregion

            #region contentnodelevels
            if (articleModel.ContentLevelNodeId.HasValue)
            {
                string newName = "Some Name" + this.Random.Next(10000, 100000);
                CMSContentLevelNodeManager contentLevelNodeManager = new CMSContentLevelNodeManager(this.DataStore);
                contentLevelNodeManager.RenameContentLevelNode(articleModel.ContentLevelNodeId.Value, newName);

                articleModel = manager.GetArticleModel(record.ArticleId);
                Assert.AreEqual(articleModel.ContentLevelNodes[articleModel.ContentLevelNodes.Count - 1], newName);
            }
            #endregion

            Delete(this.DataStore, record);
            Test_ArticleGroups.Delete(this.DataStore, articleGroup);

            Assert.IsNull(messageBoardThreadManager.GetMessageBoardThread(articleModel.MessageBoardThreadId));

            ArticleAttachmentManager articleAttachmentManager = new ArticleAttachmentManager(this.DataStore);
            Assert.IsEmpty(articleAttachmentManager.GetArticleAttachments(articleModel.ArticleId));
        }