public void Test_SelfRatingConstraint() { 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, false, out baseRatingInfo); Assert.AreEqual(RatingDataRepositoryActionStatus.SelfRatingNotAllowed, report.Status); Test_CMSSections.Delete(this.DataStore, section); // deleting the section should also delete the file }
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 }
public BusinessObjectActionReport <RatingDataRepositoryActionStatus> CreateOrUpdateExisting(MessageRating messageRating, out BaseRatingInfo baseRatingInfo) { return(_CMSContentRatingManager.Create(messageRating.CMSContentRating, true, false, out baseRatingInfo)); }
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 }