Esempio n. 1
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
        }
Esempio n. 2
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
        }
Esempio n. 3
0
        internal static void Delete(IDataStore dataStore, CMSThread thread, IUserBasic userBasic)
        {
            CMSThreadRatingManager manager = new CMSThreadRatingManager(dataStore);

            CMSThreadRating threadRating = manager.GetThreadRating(thread, userBasic);

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

            Assert.AreEqual(DataRepositoryActionStatus.Success, report.Status);
            Assert.IsNull(manager.GetThreadRating(thread, userBasic));

            Trace.WriteLine("Successfully deleted threadRating " + threadRating.CMSThreadId + " -> " + threadRating.CMSUserId);
        }