Exemplo n.º 1
0
        public void Test_ThreadRatingCaluclations()
        {
            IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager);
            CMSSection section   = Test_CMSSections.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, null, this.Random);
            CMSThread  thread    = Test_CMSThreads.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, section, this.Random);

            CMSThreadRatingManager manager = new CMSThreadRatingManager(this.DataStore);

            for (int i = 0; i < 10; i++)
            {
                userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager);

                CMSThreadRating record = new CMSThreadRating(userBasic, thread, (short)i);

                BusinessObjectActionReport <RatingDataRepositoryActionStatus> report = manager.Create(record);
                Assert.AreEqual(RatingDataRepositoryActionStatus.Success, report.Status);
            }

            CMSThreadManager threadManager = new CMSThreadManager(this.DataStore);

            thread = threadManager.GetThread(section.CMSSectionType, thread.CMSThreadId);
            Assert.AreEqual(10, thread.CMSTotalRatings);
            Assert.AreEqual(45, thread.CMSRatingSum);

            Test_CMSSections.Delete(this.DataStore, section); // deleting the section should also delete the file
        }
Exemplo n.º 2
0
        public void Test_SendQueuedEmailPickup()
        {
            IUserBasic   userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager);
            EmailManager manager   = new EmailManager(this.DataStore);
            IEmail       record    = Create(this.DataStore, this.Random, this.Application, userBasic, EmailPriority.SendImmediately, EmailStatus.Unsent);

            List <IEmail> emails;

            emails = manager.PutInSendQueue(int.MaxValue, int.MaxValue, 1);

            Assert.AreEqual(1, emails.Count);
            Assert.AreEqual(emails[0].EmailId, record.EmailId, "Please ensure that there are no unsent emails in the database");

            Assert.AreEqual(EmailStatus.Queued, emails[0].Status);
            Assert.AreEqual(EmailStatus.Queued, manager.GetEmail(emails[0].EmailId).Status);

            record = manager.GetEmail(emails[0].EmailId);

            Thread.Sleep(100);

            emails = manager.PutInSendQueue(10000, int.MaxValue, 1);
            Assert.AreEqual(0, emails.Count);

            Thread.Sleep(100);
            emails = manager.PutInSendQueue(0, int.MaxValue, 1);
            Assert.AreEqual(1, emails.Count);

            Delete(this.DataStore, record);
        }
Exemplo n.º 3
0
        public void Test_Gets()
        {
            IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager);
            CMSSection section   = Test_CMSSections.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, null, this.Random);
            CMSThread  thread    = Test_CMSThreads.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, section, this.Random);

            List <CMSContent> records = new List <CMSContent>();
            CMSContentManager manager = new CMSContentManager(this.DataStore);

            for (int i = 0; i < 10; i++)
            {
                records.Add(Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, userBasic.UserId, thread, this.Random));
            }

            List <CMSContent> dsRecords = manager.GetContents(this.Application.ApplicationId, section.CMSSectionType);

            Assert.GreaterOrEqual(dsRecords.Count, records.Count);

            foreach (CMSContent record in records)
            {
                Assert.AreEqual(1, dsRecords.Count(c => c.CMSContentId == record.CMSContentId));
            }

            foreach (CMSContent record in records)
            {
                Delete(this.DataStore, record);
            }

            Test_CMSSections.Delete(this.DataStore, section);
        }
Exemplo n.º 4
0
        public void Test_CreateTempFileAndMove()
        {
            IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager);
            CMSSection section   = Test_CMSSections.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, null, this.Random);
            CMSThread  thread    = Test_CMSThreads.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, section, this.Random);
            CMSContent content   = Test_CMSContents.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, userBasic.UserId, thread, this.Random);

            CMSFileManager manager = new CMSFileManager(this.DataStore);

            ASCIIEncoding encoding      = new ASCIIEncoding();
            string        contentString = "Some String " + this.Random.Next(1000000, 10000000);

            CMSFile tempFile = CreateTemporaryFile(this.DataStore, this.Application.ApplicationId, userBasic, encoding.GetBytes(contentString), this.Random);

            int fileId;

            manager.MoveTemporaryFileToFiles(tempFile.CMSFileId, content.CMSContentId, "FileName", "FriendlyFileName", null, out fileId);
            CMSFile file = manager.GetFile(fileId);

            Assert.IsNotNull(file);

            // TODO (Roman): do all the value asserts

            Assert.AreEqual(contentString, encoding.GetString(file.Content));

            // TODO (Roman): check that tempFile doesn't exist any more
            Test_CMSSections.Delete(this.DataStore, section); // deleting the section should also delete the file
            Assert.IsNull(manager.GetFile(file.CMSFileId));
        }
Exemplo n.º 5
0
        public void Test_CreateUpdateDeleteSystemProfileImageFile()
        {
            IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager);

            SystemProfileImageManager manager = new SystemProfileImageManager(this.DataStore);
            SystemProfileImage        record  = Test_SystemProfileImages.CreateSystemProfileImage(this.DataStore, this.Application.ApplicationId, this.Random);

            SystemProfileImage recordToCompare;

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

                manager.Update(record);
                record = manager.GetSystemProfileImage(record.ImageId);

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

            Delete(this.DataStore, record);
        }
Exemplo n.º 6
0
        public void Test_CreateUpdateDeleteContent()
        {
            IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager);
            CMSSection section   = Test_CMSSections.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, null, this.Random);
            CMSThread  thread    = Test_CMSThreads.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, section, this.Random);

            CMSContentManager manager = new CMSContentManager(this.DataStore);
            CMSContent        record  = Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, userBasic.UserId, thread, this.Random);

            CMSContent recordToCompare;

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

                manager.Update(record);
                record = manager.GetContent(record.CMSContentId);

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

            Delete(this.DataStore, record);
            Test_CMSSections.Delete(this.DataStore, section);
        }
Exemplo n.º 7
0
        public void Test_CreateUpdateDeleteThreadRating()
        {
            IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager);
            CMSSection section   = Test_CMSSections.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, null, this.Random);
            CMSThread  thread    = Test_CMSThreads.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, section, this.Random);

            CMSThreadRatingManager manager = new CMSThreadRatingManager(this.DataStore);

            CMSThreadRating record = new CMSThreadRating(userBasic, thread, 1);

            BusinessObjectActionReport <RatingDataRepositoryActionStatus> report = manager.Create(record);

            Assert.AreEqual(RatingDataRepositoryActionStatus.Success, report.Status);

            CMSThreadRating recordToCompare;

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

                manager.Update(record);
                record = manager.GetThreadRating(thread, userBasic);

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

            Delete(this.DataStore, thread, userBasic);
            Test_CMSSections.Delete(this.DataStore, section); // deleting the section should also delete the file
        }
Exemplo n.º 8
0
        public void Test_CreateUpdateDeleteEmail()
        {
            IUserBasic   userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager);
            EmailManager manager   = new EmailManager(this.DataStore);
            IEmail       record    = Create(this.DataStore, this.Random, this.Application, userBasic);

            Delete(this.DataStore, record);
        }
Exemplo n.º 9
0
        List <IUserBasic> GenerateUsers(int totalUsersToCreate)
        {
            List <IUserBasic> records = new List <IUserBasic>();

            for (int i = 0; i < totalUsersToCreate; i++)
            {
                records.Add(Test_WorkmateMembershipProvider.CreateUser(this.DataStore
                                                                       , InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager));
            }
            return(records);
        }
Exemplo n.º 10
0
        public void Test_UpdateContentBlock()
        {
            IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager);
            ContentPlaceholderGroup   contentPlaceholderGroup = Test_ContentPlaceholderGroup.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.Random);
            ContentPlaceholderManager manager             = new ContentPlaceholderManager(this.DataStore);
            ContentBlockManager       contentBlockManager = new ContentBlockManager(this.DataStore);

            string key = "test_content_block";

            int contentBlockId;
            Dictionary <string, string> lookup;

            ContentUpdateStatus contentUpdateStatus = manager.UpdateContentBlock(this.Application.ApplicationId, userBasic
                                                                                 , key, "Body1", out contentBlockId);

            // TODO (Roman): Html testing...

            Assert.AreEqual(ContentUpdateStatus.Success, contentUpdateStatus);
            Assert.Greater(contentBlockId, 0);

            ContentBlock contentBlock1 = contentBlockManager.GetContentBlock(contentBlockId);

            Assert.IsNotNull(contentBlock1);
            Assert.AreEqual(ContentBlockStatus.Active, contentBlock1.ContentBlockStatus);
            Assert.AreEqual("Body1", contentBlock1.FormattedBody);

            lookup = manager.GetContentPlaceholderBodies(this.Application.ApplicationId);
            Assert.IsNotNull(lookup);
            Assert.IsTrue(lookup.ContainsKey(key));
            Assert.AreEqual(lookup[key], "Body1");

            contentUpdateStatus = manager.UpdateContentBlock(this.Application.ApplicationId, userBasic
                                                             , key, "Body2", out contentBlockId);

            Assert.AreEqual(ContentUpdateStatus.Success, contentUpdateStatus);
            Assert.Greater(contentBlockId, 0);

            ContentBlock contentBlock2 = contentBlockManager.GetContentBlock(contentBlockId);

            Assert.IsNotNull(contentBlock2);
            Assert.AreEqual(ContentBlockStatus.Active, contentBlock2.ContentBlockStatus);
            Assert.AreEqual("Body2", contentBlock2.FormattedBody);

            contentBlock1 = contentBlockManager.GetContentBlock(contentBlock1.ContentBlockId);
            Assert.IsNotNull(contentBlock1);
            Assert.AreEqual(ContentBlockStatus.Inactive, contentBlock1.ContentBlockStatus);
            Assert.AreEqual("Body1", contentBlock1.FormattedBody);

            lookup = manager.GetContentPlaceholderBodies(this.Application.ApplicationId);
            Assert.IsNotNull(lookup);
            Assert.IsTrue(lookup.ContainsKey(key));
            Assert.AreEqual(lookup[key], "Body2");
        }
Exemplo n.º 11
0
        public void Test_SendEmails()
        {
            IUserBasic   userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager);
            EmailManager manager   = new EmailManager(this.DataStore);

            List <IEmail> highPriorityEmails = new List <IEmail>();

            for (int i = 0; i < 3; i++)
            {
                highPriorityEmails.Add(Create(this.DataStore, this.Random, this.Application, userBasic, EmailPriority.SendImmediately, EmailStatus.Unsent));
            }
            List <IEmail> lowPriorityEmails = new List <IEmail>();

            for (int i = 0; i < 3; i++)
            {
                lowPriorityEmails.Add(Create(this.DataStore, this.Random, this.Application, userBasic, EmailPriority.CanWait, EmailStatus.Unsent));
            }

            List <IEmail> emails;

            emails = manager.PutInSendQueue(int.MaxValue, int.MaxValue, 4);

            Assert.AreEqual(4, emails.Count);
            Assert.AreEqual(emails[0].EmailId, highPriorityEmails[0].EmailId);
            Assert.AreEqual(emails[1].EmailId, highPriorityEmails[1].EmailId);
            Assert.AreEqual(emails[2].EmailId, highPriorityEmails[2].EmailId);
            Assert.AreEqual(emails[3].EmailId, lowPriorityEmails[0].EmailId);

            for (int i = 0; i < 4; i++)
            {
                Assert.AreEqual(EmailStatus.Queued, emails[i].Status);
                Assert.AreEqual(EmailStatus.Queued, manager.GetEmail(emails[i].EmailId).Status);
            }

            manager.SetToSent(emails[0].EmailId, EmailStatus.Sent, emails[0].Priority);
            manager.SetToSent(emails[1].EmailId, EmailStatus.Sent, emails[1].Priority);
            manager.SetToSent(emails[2].EmailId, EmailStatus.Sent, emails[2].Priority);
            manager.SetToSent(emails[3].EmailId, EmailStatus.Sent, emails[3].Priority);

            emails = manager.PutInSendQueue(int.MaxValue, int.MaxValue, 4);
            Assert.AreEqual(2, emails.Count);
            Assert.AreEqual(emails[0].EmailId, lowPriorityEmails[1].EmailId);
            Assert.AreEqual(emails[1].EmailId, lowPriorityEmails[2].EmailId);

            foreach (IEmail email in highPriorityEmails)
            {
                Delete(this.DataStore, email);
            }
            foreach (IEmail email in lowPriorityEmails)
            {
                Delete(this.DataStore, email);
            }
        }
Exemplo n.º 12
0
        public void Test_AssignNewProfileImage()
        {
            IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager);

            ProfileImageManager manager = new ProfileImageManager(this.DataStore);
            ProfileImage        record  = Test_ProfileImages.CreateProfileImage(this.DataStore, this.Application.ApplicationId, userBasic, this.Random);

            ProfileImage record2 = Test_ProfileImages.CreateProfileImage(this.DataStore, this.Application.ApplicationId, userBasic, this.Random);

            Assert.IsNull(manager.GetProfileImage(record.ImageId));

            Delete(this.DataStore, record2);
        }
Exemplo n.º 13
0
        public void Test_CreateUpdateDeleteContentBlock()
        {
            IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager);
            ContentPlaceholderGroup   contentPlaceholderGroup   = Test_ContentPlaceholderGroup.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.Random);
            ContentPlaceholder        contentPlaceholder        = Test_ContentPlaceholders.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, contentPlaceholderGroup, this.Random);
            ContentPlaceholderHistory contentPlaceholderHistory = Test_ContentPlaceholderHistorys.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, contentPlaceholder, this.Random);

            ContentBlockManager manager = new ContentBlockManager(this.DataStore);
            ContentBlock        record  = Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, userBasic, contentPlaceholderHistory, this.Random);

            Delete(this.DataStore, record);
            Test_ContentPlaceholders.Delete(this.DataStore, contentPlaceholder);
            Test_ContentPlaceholderGroup.Delete(this.DataStore, contentPlaceholderGroup);
        }
Exemplo n.º 14
0
        public void Test_Delete_Inbox()
        {
            IUserBasic     userBasic      = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager);
            Inbox          inbox          = Test_Inboxs.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.Random);
            Folder         folder         = Test_Folders.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, inbox, this.Random);
            PrivateMessage privateMessage = Test_PrivateMessages.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, userBasic, folder, this.Random);

            Test_Inboxs.Delete(this.DataStore, inbox);

            FolderManager         folderManager         = new FolderManager(this.DataStore);
            PrivateMessageManager privateMessageManager = new PrivateMessageManager(this.DataStore);

            Assert.IsNull(folderManager.GetFolder(folder.FolderId));
            Assert.IsNull(privateMessageManager.GetPrivateMessage(privateMessage.PrivateMessageId));
        }
Exemplo n.º 15
0
        public void Test_Delete_MessageBoard()
        {
            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);
            MessageBoardThread messageBoardThread = Test_MessageBoardThreads.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, messageBoard, this.Random);
            Message            message            = Test_Messages.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, userBasic, messageBoardThread, this.Random);

            Test_MessageBoards.Delete(this.DataStore, messageBoard);

            MessageBoardThreadManager messageBoardThreadManager = new MessageBoardThreadManager(this.DataStore);
            MessageManager            messageManager            = new MessageManager(this.DataStore);

            Assert.IsNull(messageBoardThreadManager.GetMessageBoardThread(messageBoardThread.MessageBoardThreadId));
            Assert.IsNull(messageManager.GetMessage(message.MessageId));
        }
Exemplo n.º 16
0
        public void Test_Delete_Section()
        {
            IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager);
            CMSSection section   = Test_CMSSections.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, null, this.Random);
            CMSThread  thread    = Test_CMSThreads.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, section, this.Random);
            CMSContent content   = Test_CMSContents.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, userBasic.UserId, thread, this.Random);

            Test_CMSSections.Delete(this.DataStore, section);

            CMSThreadManager  threadManager  = new CMSThreadManager(this.DataStore);
            CMSContentManager contentManager = new CMSContentManager(this.DataStore);

            Assert.IsNull(threadManager.GetThread(section.CMSSectionType, thread.CMSThreadId));
            Assert.IsNull(contentManager.GetContent(content.CMSContentId));
        }
Exemplo n.º 17
0
        public void Test_CreateUpdateDelete()
        {
            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);
            MessageBoardThread messageBoardThread = Test_MessageBoardThreads.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, messageBoard, this.Random);
            Message            message            = Test_Messages.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, userBasic, messageBoardThread, this.Random);

            MessageRatingManager messageRatingManager = new MessageRatingManager(this.DataStore);

            BaseRatingInfo baseRatingInfo;
            int            totalThumbsUp = 0;

            for (int i = 0; i < 10; i++)
            {
                userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager);

                MessageRating record = new MessageRating(userBasic, message, DebugUtility.GetRandomEnum <MessageRatingType>(this.Random));

                BusinessObjectActionReport <RatingDataRepositoryActionStatus> report = messageRatingManager.Create(record, out baseRatingInfo);
                Assert.AreEqual(RatingDataRepositoryActionStatus.Success, report.Status);

                totalThumbsUp += (short)record.MessageRatingType;
                Assert.AreEqual(totalThumbsUp, baseRatingInfo.GetTotalThumbsUp());
                Assert.AreEqual(i + 1 - totalThumbsUp, baseRatingInfo.GetTotalThumbsDown());

                record = new MessageRating(userBasic, message, DebugUtility.GetRandomEnum <MessageRatingType>(this.Random, record.MessageRatingType));
                messageRatingManager.CreateOrUpdateExisting(record, out baseRatingInfo);
                Assert.AreEqual(RatingDataRepositoryActionStatus.Success, report.Status);

                totalThumbsUp += record.MessageRatingType == MessageRatingType.ThumbsUp ? 1 : -1;
                Assert.AreEqual(totalThumbsUp, baseRatingInfo.GetTotalThumbsUp());
                Assert.AreEqual(i + 1 - totalThumbsUp, baseRatingInfo.GetTotalThumbsDown());
            }

            Test_MessageBoardThreads.Delete(this.DataStore, messageBoardThread);

            MessageBoardThreadManager messageBoardThreadManager = new MessageBoardThreadManager(this.DataStore);
            MessageManager            messageManager            = new MessageManager(this.DataStore);

            Assert.IsNull(messageBoardThreadManager.GetMessageBoardThread(messageBoardThread.MessageBoardThreadId));
            Assert.IsNull(messageManager.GetMessage(message.MessageId));
            Assert.IsEmpty(messageRatingManager.GetAllRatingsForMessage(message));

            Test_MessageBoards.Delete(this.DataStore, messageBoard);
        }
Exemplo n.º 18
0
        public void Test_CreateUpdateDeleteContentUser()
        {
            IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager);
            CMSSection section   = Test_CMSSections.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, null, this.Random);
            CMSThread  thread    = Test_CMSThreads.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, section, this.Random);
            CMSContent content   = Test_CMSContents.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, userBasic.UserId, thread, this.Random);

            CMSContentUserManager manager = new CMSContentUserManager(this.DataStore);

            CMSContentUser record = new CMSContentUser(userBasic, content);

            BusinessObjectActionReport <DataRepositoryActionStatus> report = manager.Create(record);

            Assert.AreEqual(DataRepositoryActionStatus.Success, report.Status);

            Delete(this.DataStore, content, userBasic);
            Test_CMSSections.Delete(this.DataStore, section); // deleting the section should also delete the file
        }
Exemplo n.º 19
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));
        }
Exemplo n.º 20
0
        public void Test_SelfRatingConstraint()
        {
            IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager);
            CMSSection section   = Test_CMSSections.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, null, this.Random);
            CMSThread  thread    = Test_CMSThreads.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, section, this.Random);
            CMSContent content   = Test_CMSContents.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, userBasic.UserId, thread, this.Random);

            CMSContentRatingManager manager = new CMSContentRatingManager(this.DataStore);

            CMSContentRating record = new CMSContentRating(userBasic, content, 1);
            BaseRatingInfo   baseRatingInfo;

            BusinessObjectActionReport <RatingDataRepositoryActionStatus> report = manager.Create(record, true, false, out baseRatingInfo);

            Assert.AreEqual(RatingDataRepositoryActionStatus.SelfRatingNotAllowed, report.Status);

            Test_CMSSections.Delete(this.DataStore, section); // deleting the section should also delete the file
        }
Exemplo n.º 21
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));
        }