Example #1
0
        internal static void Delete(IDataStore dataStore, CMSContent content, IUserBasic userBasic)
        {
            CMSContentRatingManager manager = new CMSContentRatingManager(dataStore);

            CMSContentRating contentRating = manager.GetContentRating(content, userBasic);

            BusinessObjectActionReport <DataRepositoryActionStatus> report = manager.Delete(contentRating);

            Assert.AreEqual(DataRepositoryActionStatus.Success, report.Status);
            Assert.IsNull(manager.GetContentRating(content, userBasic));

            Trace.WriteLine("Successfully deleted contentRating " + contentRating.CMSContentId + " -> " + contentRating.CMSUserId);
        }
Example #2
0
        public MessageRating GetMessageRating(Message message, IUserBasic userBasic)
        {
            CMSContentRating contentRating = _CMSContentRatingManager.GetContentRating(message.CMSContent, userBasic);

            if (contentRating != null)
            {
                return(new MessageRating(contentRating));
            }
            return(null);
        }
Example #3
0
        public void Test_CreateUpdateDeleteContentRating()
        {
            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, true, out baseRatingInfo);

            Assert.AreEqual(RatingDataRepositoryActionStatus.Success, report.Status);
            Assert.AreEqual(1, baseRatingInfo.RatingSum);
            Assert.AreEqual(1, baseRatingInfo.TotalRatings);

            CMSContentRating recordToCompare;

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

                manager.Update(record);
                record = manager.GetContentRating(content, 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, content, userBasic);
            Test_CMSSections.Delete(this.DataStore, section); // deleting the section should also delete the file
        }