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); }
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); }
public void Test_CreateTempFileAndMove() { 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); CMSFileManager manager = new CMSFileManager(this.DataStore); ASCIIEncoding encoding = new ASCIIEncoding(); string contentString = "Some String " + this.Random.Next(1000000, 10000000); CMSFile tempFile = CreateTemporaryFile(this.DataStore, this.Application.ApplicationId, userBasic, encoding.GetBytes(contentString), this.Random); int fileId; manager.MoveTemporaryFileToFiles(tempFile.CMSFileId, content.CMSContentId, "FileName", "FriendlyFileName", null, out fileId); CMSFile file = manager.GetFile(fileId); Assert.IsNotNull(file); // TODO (Roman): do all the value asserts Assert.AreEqual(contentString, encoding.GetString(file.Content)); // TODO (Roman): check that tempFile doesn't exist any more Test_CMSSections.Delete(this.DataStore, section); // deleting the section should also delete the file Assert.IsNull(manager.GetFile(file.CMSFileId)); }
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_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 }
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)); }
public void Test_CreateUpdateDeleteContentUser() { 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); CMSContentUserManager manager = new CMSContentUserManager(this.DataStore); CMSContentUser record = new CMSContentUser(userBasic, content); BusinessObjectActionReport <DataRepositoryActionStatus> report = manager.Create(record); Assert.AreEqual(DataRepositoryActionStatus.Success, report.Status); Delete(this.DataStore, content, userBasic); Test_CMSSections.Delete(this.DataStore, section); // deleting the section should also delete the file }
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 }