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_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 Article GetArticle(string friendlyName, string articleGroupName, string articleGroupThreadName) { CMSContent content = _CMSContentManager.GetContent(friendlyName, articleGroupThreadName, articleGroupName, null); Article record = null; if (content != null) { CMSThread thread = null; CMSSection section = null; thread = _CMSThreadManager.GetThread(CMSSectionType.Article, content.CMSThreadId); section = _CMSSectionManager.GetSection(CMSSectionType.Article, thread.CMSSectionId); // this should only ever be used for testing List <string> contentLevelNodeNames = new List <string>(); if (content.ContentLevelNodeId.HasValue) { var lookup = _CMSContentLevelNodeManager.GetContentLevelNodes(); if (lookup.ContainsKey(content.ContentLevelNodeId.Value)) { ICMSContentLevelNode node = lookup[content.ContentLevelNodeId.Value]; contentLevelNodeNames.Add(node.Name); while (node.Parent != null) { node = node.Parent; contentLevelNodeNames.Insert(0, node.Name); } } } record = new Article(content, thread, section, _CMSTagManager.GetTagsByContentId(content.CMSContentId), contentLevelNodeNames); } return(record); }
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_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); }
internal static CMSSection Create(IDataStore dataStore, IApplicationSettings applicationSettings, IApplication application, CMSGroup group, Random random) { CMSSectionManager manager = new CMSSectionManager(dataStore); CMSSectionType sectionType = DebugUtility.GetRandomEnum <CMSSectionType>(random); CMSSection section = new CMSSection( application.ApplicationId , "TestSection " + random.Next(1000000, 10000000) , true , false , sectionType); if (group != null) { section.CMSGroupId = group.CMSGroupId; } BusinessObjectActionReport <DataRepositoryActionStatus> report = manager.Create(section); Assert.AreEqual(DataRepositoryActionStatus.Success, report.Status); Assert.Greater(section.CMSSectionId, 0); CMSSection dsSection = manager.GetSection(sectionType, section.CMSSectionId); Assert.IsNotNull(dsSection); if (group != null) { Assert.AreEqual(section.CMSGroupId, group.CMSGroupId); } return(dsSection); }
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_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); }
internal static void PopulateWithRandomValues(CMSSection record, DummyDataManager dtm, Random random) { record.Name = "TestSection " + random.Next(1000000, 10000000); record.Description = "Description " + random.Next(1000000, 10000000); record.CMSSectionType = DebugUtility.GetRandomEnum <CMSSectionType>(random); record.IsActive = DebugUtility.FlipCoin(random); record.IsModerated = DebugUtility.FlipCoin(random); }
public Folder(CMSThread cmsThread, CMSSection cmsSection) { this._CMSThread = cmsThread; if (cmsSection != null) { this.Inbox = new Inbox(cmsSection); } }
internal ArticleGroupThread(CMSThread cmsThread, CMSSection cmsSection) { this._CMSThread = cmsThread; if (cmsSection != null) { this.ArticleGroup = new ArticleGroup(cmsSection); } }
internal ContentBlock(CMSContent cmsContent, CMSThread cmsThread, CMSSection cmsSection) { this._CMSContent = cmsContent; if (cmsThread != null) { this.ContentPlaceholderHistory = new ContentPlaceholderHistory(cmsThread, cmsSection); } }
internal MessageBoardThread(CMSThread cmsThread, CMSSection cmsSection) { this._CMSThread = cmsThread; if (cmsSection != null) { this.MessageBoard = new MessageBoard(cmsSection); } }
internal Message(CMSContent cmsContent, CMSThread cmsThread, CMSSection cmsSection) { this._CMSContent = cmsContent; if (cmsThread != null) { this.MessageBoardThread = new MessageBoardThread(cmsThread, cmsSection); } }
internal ContentPlaceholderHistory(CMSThread cmsThread, CMSSection cmsSection) { this._CMSThread = cmsThread; if (cmsSection != null) { this.ContentPlaceholder = new ContentPlaceholder(cmsSection); } }
internal PrivateMessage(CMSContent cmsContent, CMSThread cmsThread, CMSSection cmsSection) { this._CMSContent = cmsContent; if (cmsThread != null) { this.Folder = new Folder(cmsThread, cmsSection); } }
public MessageBoard GetMessageBoard(int applicationId, string name) { CMSSection section = _CMSSectionManager.GetSection(applicationId, CMSSectionType.MessageBoard, name); if (section != null) { return(new MessageBoard(section)); } return(null); }
public Inbox GetInbox(int inboxId) { CMSSection section = _CMSSectionManager.GetSection(CMSSectionType.PrivateMessageInbox, inboxId); if (section != null) { return(new Inbox(section)); } return(null); }
public ContentPlaceholder GetContentPlaceholder(int contentPlaceholderId) { CMSSection section = _CMSSectionManager.GetSection(CMSSectionType.Content, contentPlaceholderId); if (section != null) { return(new ContentPlaceholder(section)); } return(null); }
public MessageBoard GetMessageBoard(int messageBoardId) { CMSSection section = _CMSSectionManager.GetSection(CMSSectionType.MessageBoard, messageBoardId); if (section != null) { return(new MessageBoard(section)); } return(null); }
public ArticleGroup GetArticleGroup(int articleGroupId) { CMSSection section = _CMSSectionManager.GetSection(CMSSectionType.Article, articleGroupId); if (section != null) { return(new ArticleGroup(section)); } return(null); }
public ContentPlaceholder GetContentPlaceholder(int applicationId, string key) { CMSSection section = _CMSSectionManager.GetSection(applicationId, CMSSectionType.Content, key); if (section != null) { return(new ContentPlaceholder(section)); } return(null); }
public ArticleGroup GetArticleGroup(int applicationId, string name) { CMSSection section = _CMSSectionManager.GetSection(applicationId, CMSSectionType.Article, name); if (section != null) { return(new ArticleGroup(section)); } return(null); }
internal static void Delete(IDataStore dataStore, CMSSection section) { CMSSectionManager manager = new CMSSectionManager(dataStore); BusinessObjectActionReport <DataRepositoryActionStatus> report = manager.Delete(section, true); Assert.AreEqual(DataRepositoryActionStatus.Success, report.Status); Assert.IsNull(manager.GetSection(section.CMSSectionType, section.CMSSectionId)); Trace.WriteLine("Successfully deleted section " + section.Name); }
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 }
public PrivateMessage GetPrivateMessage(int privateMessageId) { CMSContent content = _CMSContentManager.GetContent(privateMessageId); PrivateMessage record = null; if (content != null) { CMSThread thread = null; CMSSection section = null; thread = _CMSThreadManager.GetThread(CMSSectionType.PrivateMessageInbox, content.CMSThreadId); section = _CMSSectionManager.GetSection(CMSSectionType.PrivateMessageInbox, thread.CMSSectionId); record = new PrivateMessage(content, thread, section); } return(record); }
internal BusinessObjectActionReport <DataRepositoryActionStatus> Update(CMSSection cmsSection) { BusinessObjectActionReport <DataRepositoryActionStatus> businessObjectActionReport = new BusinessObjectActionReport <DataRepositoryActionStatus>(DataRepositoryActionStatus.Success); businessObjectActionReport.ValidationResult = BusinessObjectManager.Validate(cmsSection); if (businessObjectActionReport.ValidationResult.IsValid) { int num = 0; try { using (IDataStoreContext dataStoreContext = this._DataStore.CreateContext()) { num = dataStoreContext.cms_Sections_Update(cmsSection.CMSSectionId, cmsSection.CMSParentSectionId, cmsSection.CMSGroupId , cmsSection.Name, cmsSection.Description, cmsSection.CMSSectionType, cmsSection.IsActive, cmsSection.IsModerated); } } catch (Exception ex) { _Log.Error("Error at cms_Sections_Update", ex); throw new DataStoreException(ex, true); } // TODO (Roman): make sure we return the right values from db if (num != -1003) { if (num == 0) { businessObjectActionReport.Status = DataRepositoryActionStatus.NoRecordRowAffected; } } else { businessObjectActionReport.Status = DataRepositoryActionStatus.NameNotUnique; } } else { businessObjectActionReport.Status = DataRepositoryActionStatus.ValidationFailed; _Log.WarnFormat("CMSSection {0} was not updated at the database because the validation failed.\nReport: {1}" , DebugUtility.GetObjectString(cmsSection) , businessObjectActionReport.ValidationResult.ToString(TextFormat.ASCII)); } return(businessObjectActionReport); }
public int cms_Sections_Insert(int applicationId, int?parentSectionId, int?groupId, string name, string description, Components.Contracts.CMS.CMSSectionType sectionType, bool isActive, bool isModerated) { CMSSection record = new CMSSection( applicationId , _Sections.Count == 0 ? 1000 : _Sections.Last().CMSSectionId + 1 , parentSectionId , groupId , name , description , sectionType , isActive , isModerated , 0 , 0); _Sections.Add(record); return(record.CMSSectionId); }