Exemplo n.º 1
0
        public void Test_CreateUpdateDeleteThread()
        {
            MessageBoard messageBoard = Test_MessageBoards.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.Random);

            MessageBoardThreadManager manager = new MessageBoardThreadManager(this.DataStore);
            MessageBoardThread        record  = Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, messageBoard, this.Random);

            MessageBoardThread recordToCompare;

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

                manager.Update(record);
                record = manager.GetMessageBoardThread(record.MessageBoardThreadId);

                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_MessageBoards.Delete(this.DataStore, messageBoard);
        }
Exemplo n.º 2
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.º 3
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);
        }