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 }
public void Test_Gets() { CMSSection section = Test_CMSSections.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, null, this.Random); List <CMSThread> records = new List <CMSThread>(); CMSThreadManager manager = new CMSThreadManager(this.DataStore); for (int i = 0; i < 10; i++) { records.Add(Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, section, this.Random)); } List <CMSThread> dsRecords = manager.GetAllThreads(this.Application.ApplicationId, section.CMSSectionType); Assert.GreaterOrEqual(dsRecords.Count, records.Count); foreach (CMSThread record in records) { Assert.AreEqual(1, dsRecords.Count(c => c.CMSThreadId == record.CMSThreadId)); } foreach (CMSThread record in records) { Delete(this.DataStore, record, section.CMSSectionType); } Test_CMSSections.Delete(this.DataStore, section); }
public void Test_CreateUpdateDeleteThread() { CMSSection section = Test_CMSSections.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, null, this.Random); CMSThreadManager manager = new CMSThreadManager(this.DataStore); CMSThread record = Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, section, this.Random); CMSThread recordToCompare; for (int i = 0; i < this.DefaultUpdateTestIterations; i++) { PopulateWithRandomValues(record, this.DummyDataManager, this.Random); recordToCompare = record; manager.Update(record); record = manager.GetThread(section.CMSSectionType, record.CMSThreadId); 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, section.CMSSectionType); Test_CMSSections.Delete(this.DataStore, section); }
internal static void Delete(IDataStore dataStore, CMSThread thread, CMSSectionType sectionType) { CMSThreadManager manager = new CMSThreadManager(dataStore); BusinessObjectActionReport <DataRepositoryActionStatus> report = manager.Delete(thread, true); Assert.AreEqual(DataRepositoryActionStatus.Success, report.Status); Assert.IsNull(manager.GetThread(sectionType, thread.CMSThreadId)); Trace.WriteLine("Successfully deleted thread " + thread.CMSName); }
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)); }
internal static CMSThread Create(IDataStore dataStore, IApplicationSettings applicationSettings, IApplication application, CMSSection section, Random random) { CMSThreadManager manager = new CMSThreadManager(dataStore); CMSThread thread = new CMSThread( section , true , -1); BusinessObjectActionReport <DataRepositoryActionStatus> report = manager.Create(thread); Assert.AreEqual(DataRepositoryActionStatus.Success, report.Status); Assert.Greater(thread.CMSThreadId, 0); CMSThread dsThread = manager.GetThread(section.CMSSectionType, thread.CMSThreadId); Assert.IsNotNull(dsThread); return(dsThread); }