예제 #1
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);
        }
예제 #2
0
        internal static CMSContent Create(IDataStore dataStore, IApplicationSettings applicationSettings, IApplication application
                                          , int authorUserId, CMSThread thread, Random random)
        {
            CMSContentManager manager = new CMSContentManager(dataStore);

            CMSContent content = new CMSContent(
                authorUserId
                , thread
                , 0
                , 0
                , "Content Status" + random.Next(1000000, 10000000)
                , "Content Body" + random.Next(1000000, 10000000)
                , true);

            BusinessObjectActionReport <DataRepositoryActionStatus> report = manager.Create(content, null, null, false, false, null, null, null);

            Assert.AreEqual(DataRepositoryActionStatus.Success, report.Status);
            Assert.Greater(content.CMSContentId, 0);

            CMSContent dsContent = manager.GetContent(content.CMSContentId);

            Assert.IsNotNull(dsContent);

            return(dsContent);
        }
예제 #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);
        }
예제 #4
0
        public void Test_ContentRatingCaluclations()
        {
            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);

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

                CMSContentRating record = new CMSContentRating(userBasic, content, (short)i);

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

            CMSContentManager contentManager = new CMSContentManager(this.DataStore);

            content = contentManager.GetContent(content.CMSContentId);
            Assert.AreEqual(10, content.CMSTotalRatings);
            Assert.AreEqual(45, content.CMSRatingSum);

            Test_CMSSections.Delete(this.DataStore, section); // deleting the section should also delete the file
        }
예제 #5
0
        internal static void Delete(IDataStore dataStore, CMSContent content)
        {
            CMSContentManager manager = new CMSContentManager(dataStore);

            BusinessObjectActionReport <DataRepositoryActionStatus> report = manager.Delete(content, true);

            Assert.AreEqual(DataRepositoryActionStatus.Success, report.Status);
            Assert.IsNull(manager.GetContent(content.CMSContentId));

            Trace.WriteLine("Successfully deleted content " + content.Subject);
        }
예제 #6
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));
        }