public void Test_UpdateContentBlock() { IUserBasic userBasic = Test_WorkmateMembershipProvider.CreateUser(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.DummyDataManager); ContentPlaceholderGroup contentPlaceholderGroup = Test_ContentPlaceholderGroup.Create(this.DataStore, Workmate.Components.InstanceContainer.ApplicationSettings, this.Application, this.Random); ContentPlaceholderManager manager = new ContentPlaceholderManager(this.DataStore); ContentBlockManager contentBlockManager = new ContentBlockManager(this.DataStore); string key = "test_content_block"; int contentBlockId; Dictionary <string, string> lookup; ContentUpdateStatus contentUpdateStatus = manager.UpdateContentBlock(this.Application.ApplicationId, userBasic , key, "Body1", out contentBlockId); // TODO (Roman): Html testing... Assert.AreEqual(ContentUpdateStatus.Success, contentUpdateStatus); Assert.Greater(contentBlockId, 0); ContentBlock contentBlock1 = contentBlockManager.GetContentBlock(contentBlockId); Assert.IsNotNull(contentBlock1); Assert.AreEqual(ContentBlockStatus.Active, contentBlock1.ContentBlockStatus); Assert.AreEqual("Body1", contentBlock1.FormattedBody); lookup = manager.GetContentPlaceholderBodies(this.Application.ApplicationId); Assert.IsNotNull(lookup); Assert.IsTrue(lookup.ContainsKey(key)); Assert.AreEqual(lookup[key], "Body1"); contentUpdateStatus = manager.UpdateContentBlock(this.Application.ApplicationId, userBasic , key, "Body2", out contentBlockId); Assert.AreEqual(ContentUpdateStatus.Success, contentUpdateStatus); Assert.Greater(contentBlockId, 0); ContentBlock contentBlock2 = contentBlockManager.GetContentBlock(contentBlockId); Assert.IsNotNull(contentBlock2); Assert.AreEqual(ContentBlockStatus.Active, contentBlock2.ContentBlockStatus); Assert.AreEqual("Body2", contentBlock2.FormattedBody); contentBlock1 = contentBlockManager.GetContentBlock(contentBlock1.ContentBlockId); Assert.IsNotNull(contentBlock1); Assert.AreEqual(ContentBlockStatus.Inactive, contentBlock1.ContentBlockStatus); Assert.AreEqual("Body1", contentBlock1.FormattedBody); lookup = manager.GetContentPlaceholderBodies(this.Application.ApplicationId); Assert.IsNotNull(lookup); Assert.IsTrue(lookup.ContainsKey(key)); Assert.AreEqual(lookup[key], "Body2"); }
internal static void Delete(IDataStore dataStore, ContentBlock contentBlock) { ContentBlockManager manager = new ContentBlockManager(dataStore); BusinessObjectActionReport <DataRepositoryActionStatus> report = manager.Delete(contentBlock); Assert.AreEqual(DataRepositoryActionStatus.Success, report.Status); Assert.IsNull(manager.GetContentBlock(contentBlock.ContentBlockId)); Trace.WriteLine("Successfully deleted contentBlock " + contentBlock.Subject); }
internal static ContentBlock Create(IDataStore dataStore, IApplicationSettings applicationSettings, IApplication application , IUserBasic author, ContentPlaceholderHistory contentPlaceholderHistory, Random random) { ContentBlockManager manager = new ContentBlockManager(dataStore); ContentBlock contentBlock = new ContentBlock( author , contentPlaceholderHistory , "ContentBlock Body" + random.Next(1000000, 10000000) , Workmate.Components.Contracts.CMS.Content.ContentBlockStatus.Active); BusinessObjectActionReport <DataRepositoryActionStatus> report = manager.Create(contentBlock); Assert.AreEqual(DataRepositoryActionStatus.Success, report.Status); Assert.Greater(contentBlock.ContentBlockId, 0); ContentBlock dsContentBlock = manager.GetContentBlock(contentBlock.ContentBlockId); Assert.IsNotNull(dsContentBlock); return(dsContentBlock); }