public void Can_Verify_Content_Type_Has_Content_Nodes() { // Arrange IScopeProvider provider = ScopeProvider; using (IScope scope = provider.CreateScope()) { ContentTypeRepository repository = ContentTypeRepository; int contentTypeId = _textpageContentType.Id; IContentType contentType = repository.Get(contentTypeId); // Act bool result = repository.HasContentNodes(contentTypeId); Content subpage = ContentBuilder.CreateTextpageContent(contentType, "Test Page 1", contentType.Id); DocumentRepository.Save(subpage); bool result2 = repository.HasContentNodes(contentTypeId); // Assert Assert.That(result, Is.False); Assert.That(result2, Is.True); } }
public void Can_Verify_Usage_Of_New_PropertyType_On_Content() { // Arrange IScopeProvider provider = ScopeProvider; using (IScope scope = provider.CreateScope()) { ContentTypeRepository repository = ContentTypeRepository; IContentType contentType = repository.Get(_textpageContentType.Id); Content subpage = ContentBuilder.CreateTextpageContent(contentType, "Text Page 1", contentType.Id); DocumentRepository.Save(subpage); PropertyGroup propertyGroup = contentType.PropertyGroups.First(x => x.Name == "Meta"); propertyGroup.PropertyTypes.Add(new PropertyType(ShortStringHelper, "test", ValueStorageType.Ntext, "metaAuthor") { Name = "Meta Author", Description = string.Empty, Mandatory = false, SortOrder = 1, DataTypeId = -88 }); repository.Save(contentType); // Act IContent content = DocumentRepository.Get(subpage.Id); content.SetValue("metaAuthor", "John Doe"); DocumentRepository.Save(content); // Assert IContent updated = DocumentRepository.Get(subpage.Id); Assert.That(updated.GetValue("metaAuthor").ToString(), Is.EqualTo("John Doe")); Assert.That(contentType.PropertyTypes.Count(), Is.EqualTo(5)); Assert.That(contentType.PropertyTypes.Any(x => x.Alias == "metaAuthor"), Is.True); } }
public void Can_Verify_That_A_Combination_Of_Adding_And_Deleting_PropertyTypes_Doesnt_Cause_Issues_For_Content_And_ContentType() { // Arrange IScopeProvider provider = ScopeProvider; using (IScope scope = provider.CreateScope()) { ContentTypeRepository repository = ContentTypeRepository; IContentType contentType = repository.Get(_textpageContentType.Id); Content subpage = ContentBuilder.CreateTextpageContent(contentType, "Text Page 1", contentType.Id); DocumentRepository.Save(subpage); // Remove PropertyType contentType.RemovePropertyType("keywords"); // Add PropertyType PropertyGroup propertyGroup = contentType.PropertyGroups.First(x => x.Name == "Meta"); propertyGroup.PropertyTypes.Add(new PropertyType(ShortStringHelper, "test", ValueStorageType.Ntext, "metaAuthor") { Name = "Meta Author", Description = string.Empty, Mandatory = false, SortOrder = 1, DataTypeId = -88 }); repository.Save(contentType); // Act IContent content = DocumentRepository.Get(subpage.Id); content.SetValue("metaAuthor", "John Doe"); DocumentRepository.Save(content); // Assert IContent updated = DocumentRepository.Get(subpage.Id); Assert.That(updated.GetValue("metaAuthor").ToString(), Is.EqualTo("John Doe")); Assert.That(updated.Properties.First(x => x.Alias == "description").GetValue(), Is.EqualTo("This is the meta description for a textpage")); Assert.That(contentType.PropertyTypes.Count(), Is.EqualTo(4)); Assert.That(contentType.PropertyTypes.Any(x => x.Alias == "metaAuthor"), Is.True); Assert.That(contentType.PropertyTypes.Any(x => x.Alias == "keywords"), Is.False); } }
private IEnumerable <IContent> CreateTestData(int count) { IScopeProvider provider = ScopeProvider; using (IScope scope = provider.CreateScope()) { ContentType ct = ContentTypeBuilder.CreateBasicContentType("testing"); ContentTypeRepository.Save(ct); var result = new List <IContent>(); for (int i = 0; i < count; i++) { var c = new Content("test" + i, -1, ct); DocumentRepository.Save(c); result.Add(c); } scope.Complete(); return(result); } }
public void Can_Verify_Removal_Of_Used_PropertyType_From_ContentType() { // Arrange IScopeProvider provider = ScopeProvider; using (IScope scope = provider.CreateScope()) { ContentTypeRepository repository = ContentTypeRepository; IContentType contentType = repository.Get(_textpageContentType.Id); Content subpage = ContentBuilder.CreateTextpageContent(contentType, "Text Page 1", contentType.Id); DocumentRepository.Save(subpage); // Act contentType.RemovePropertyType("keywords"); repository.Save(contentType); // Assert Assert.That(contentType.PropertyTypes.Count(), Is.EqualTo(3)); Assert.That(contentType.PropertyTypes.Any(x => x.Alias == "keywords"), Is.False); Assert.That(subpage.Properties.First(x => x.Alias == "description").GetValue(), Is.EqualTo("This is the meta description for a textpage")); } }
public void Can_Update_Variation_Of_Element_Type_Property() { var provider = ScopeProvider; using (var scope = provider.CreateScope()) { ContentTypeRepository repository = ContentTypeRepository; var contentRepository = DocumentRepository; // Create elementType var elementType = new ContentType(ShortStringHelper, -1) { Alias = "elementType", Name = "Element type", Description = "Element type to use as compositions", Icon = ".sprTreeDoc3", Thumbnail = "doc.png", SortOrder = 1, CreatorId = 0, Trashed = false, IsElement = true, Variations = ContentVariation.Nothing }; var contentCollection = new PropertyTypeCollection(true); contentCollection.Add(new PropertyType(ShortStringHelper, "test", ValueStorageType.Ntext) { Alias = "title", Name = "Title", Description = "", Mandatory = false, SortOrder = 1, DataTypeId = Constants.DataTypes.Textbox, LabelOnTop = true, Variations = ContentVariation.Nothing }); elementType.PropertyGroups.Add(new PropertyGroup(contentCollection) { Name = "Content", Alias = "content", SortOrder = 1 }); elementType.ResetDirtyProperties(false); elementType.SetDefaultTemplate(new Template(ShortStringHelper, "ElementType", "elementType")); repository.Save(elementType); // Create the basic "home" doc type that uses element type as comp var docType = new ContentType(ShortStringHelper, -1) { Alias = "home", Name = "Home", Description = "Home containing elementType", Icon = ".sprTreeDoc3", Thumbnail = "doc.png", SortOrder = 1, CreatorId = 0, Trashed = false, Variations = ContentVariation.Nothing }; var comp = new List <IContentTypeComposition>(); comp.Add(elementType); docType.ContentTypeComposition = comp; repository.Save(docType); // Create "home" content var content = new Content("Home", -1, docType) { Level = 1, SortOrder = 1, CreatorId = 0, WriterId = 0 }; object obj = new { title = "test title" }; content.PropertyValues(obj); content.ResetDirtyProperties(false); contentRepository.Save(content); // Update variation on element type elementType.Variations = ContentVariation.Culture; elementType.PropertyTypes.First().Variations = ContentVariation.Culture; repository.Save(elementType); // Update variation on doc type docType.Variations = ContentVariation.Culture; repository.Save(docType); // Re fetch renewedContent and make sure that the culture has been set. var renewedContent = ContentService.GetById(content.Id); var hasCulture = renewedContent.Properties["title"].Values.First().Culture != null; Assert.That(hasCulture, Is.True); } }