Correcting invalid tests related to Compositions
This commit is contained in:
@@ -6,6 +6,7 @@ using System.Web;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
using Umbraco.Core.Persistence.Caching;
|
||||
@@ -418,7 +419,7 @@ namespace Umbraco.Tests.Models
|
||||
Assert.That(content.Properties["title"], Is.Not.Null);
|
||||
Assert.That(content.Properties["title"].Alias, Is.EqualTo("title"));
|
||||
Assert.That(content.Properties["title"].Value, Is.EqualTo("This is the new title"));
|
||||
Assert.That(content.Properties["metaDescription"].Value, Is.EqualTo("This is the meta description for a textpage"));
|
||||
Assert.That(content.Properties["description"].Value, Is.EqualTo("This is the meta description for a textpage"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -612,9 +613,9 @@ namespace Umbraco.Tests.Models
|
||||
// Assert
|
||||
Assert.That(content.Properties.Contains("author"), Is.True);
|
||||
Assert.That(content.Properties.Contains("keywords"), Is.True);
|
||||
Assert.That(content.Properties.Contains("metaDescription"), Is.True);
|
||||
Assert.That(content.Properties.Contains("description"), Is.True);
|
||||
Assert.That(content.Properties["keywords"].Value, Is.EqualTo("text,page,meta"));
|
||||
Assert.That(content.Properties["metaDescription"].Value, Is.EqualTo("This is the meta description for a textpage"));
|
||||
Assert.That(content.Properties["description"].Value, Is.EqualTo("This is the meta description for a textpage"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -631,7 +632,7 @@ namespace Umbraco.Tests.Models
|
||||
// Assert
|
||||
Assert.That(content.Properties.Contains("author"), Is.True);
|
||||
Assert.That(content.Properties.Contains("keywords"), Is.False);
|
||||
Assert.That(content.Properties.Contains("metaDescription"), Is.False);
|
||||
Assert.That(content.Properties.Contains("description"), Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -828,7 +829,7 @@ namespace Umbraco.Tests.Models
|
||||
public void Can_Avoid_Circular_Dependencies_In_Composition()
|
||||
{
|
||||
var textPage = MockedContentTypes.CreateTextpageContentType();
|
||||
var parent = MockedContentTypes.CreateSimpleContentType("parent", "Parent");
|
||||
var parent = MockedContentTypes.CreateSimpleContentType("parent", "Parent", null, true);
|
||||
var meta = MockedContentTypes.CreateMetaContentType();
|
||||
var mixin1 = MockedContentTypes.CreateSimpleContentType("mixin1", "Mixin1", new PropertyTypeCollection(
|
||||
new List<PropertyType>
|
||||
@@ -863,7 +864,9 @@ namespace Umbraco.Tests.Models
|
||||
var addedMetaMixin2 = mixin2.AddContentType(meta);
|
||||
var addedMixin2 = mixin1.AddContentType(mixin2);
|
||||
var addedMeta = parent.AddContentType(meta);
|
||||
|
||||
var addedMixin1 = parent.AddContentType(mixin1);
|
||||
|
||||
var addedMixin1Textpage = textPage.AddContentType(mixin1);
|
||||
var addedTextpageParent = parent.AddContentType(textPage);
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Umbraco.Tests.Models
|
||||
Assert.AreEqual(content.Properties["title"].Value.ToString(), element.Elements("title").Single().Value);
|
||||
Assert.AreEqual(content.Properties["bodyText"].Value.ToString(), element.Elements("bodyText").Single().Value);
|
||||
Assert.AreEqual(content.Properties["keywords"].Value.ToString(), element.Elements("keywords").Single().Value);
|
||||
Assert.AreEqual(content.Properties["metaDescription"].Value.ToString(), element.Elements("metaDescription").Single().Value);
|
||||
Assert.AreEqual(content.Properties["description"].Value.ToString(), element.Elements("description").Single().Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -193,8 +193,8 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
using (var repository = CreateRepository(unitOfWork))
|
||||
{
|
||||
var ctMain = MockedContentTypes.CreateSimpleContentType();
|
||||
var ctChild1 = MockedContentTypes.CreateSimpleContentType("child1", "Child 1", ctMain);
|
||||
var ctChild2 = MockedContentTypes.CreateSimpleContentType("child2", "Child 2", ctChild1);
|
||||
var ctChild1 = MockedContentTypes.CreateSimpleContentType("child1", "Child 1", ctMain, true);
|
||||
var ctChild2 = MockedContentTypes.CreateSimpleContentType("child2", "Child 2", ctChild1, true);
|
||||
|
||||
repository.AddOrUpdate(ctMain);
|
||||
repository.AddOrUpdate(ctChild1);
|
||||
@@ -282,14 +282,14 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var contentType = repository.Get(NodeDto.NodeIdSeed + 1);
|
||||
|
||||
// Act
|
||||
contentType.PropertyGroups["Meta"].PropertyTypes.Remove("metaDescription");
|
||||
contentType.PropertyGroups["Meta"].PropertyTypes.Remove("description");
|
||||
repository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
|
||||
var result = repository.Get(NodeDto.NodeIdSeed + 1);
|
||||
|
||||
// Assert
|
||||
Assert.That(result.PropertyTypes.Any(x => x.Alias == "metaDescription"), Is.False);
|
||||
Assert.That(result.PropertyTypes.Any(x => x.Alias == "description"), Is.False);
|
||||
Assert.That(contentType.PropertyGroups.Count, Is.EqualTo(result.PropertyGroups.Count));
|
||||
Assert.That(contentType.PropertyTypes.Count(), Is.EqualTo(result.PropertyTypes.Count()));
|
||||
}
|
||||
@@ -434,7 +434,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// 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 == "metaDescription").Value, Is.EqualTo("This is the meta description for a textpage"));
|
||||
Assert.That(subpage.Properties.First(x => x.Alias == "description").Value, Is.EqualTo("This is the meta description for a textpage"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -534,7 +534,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
//Assert
|
||||
var updated = contentRepository.Get(subpage.Id);
|
||||
Assert.That(updated.GetValue("metaAuthor").ToString(), Is.EqualTo("John Doe"));
|
||||
Assert.That(updated.Properties.First(x => x.Alias == "metaDescription").Value, Is.EqualTo("This is the meta description for a textpage"));
|
||||
Assert.That(updated.Properties.First(x => x.Alias == "description").Value, 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);
|
||||
|
||||
@@ -1335,7 +1335,7 @@ namespace Umbraco.Tests.Services
|
||||
//MCH: I'm guessing this is an issue because of the format the date is actually stored as, right? Cause we don't do any formatting when saving or loading
|
||||
Assert.That(sut.GetValue<DateTime>("dateTime").ToString("G"), Is.EqualTo(content.GetValue<DateTime>("dateTime").ToString("G")));
|
||||
Assert.That(sut.GetValue<string>("colorPicker"), Is.EqualTo("black"));
|
||||
Assert.That(sut.GetValue<string>("folderBrowser"), Is.Empty);
|
||||
Assert.That(sut.GetValue<string>("folderBrowser"), Is.Null);
|
||||
Assert.That(sut.GetValue<string>("ddlMultiple"), Is.EqualTo("1234,1235"));
|
||||
Assert.That(sut.GetValue<string>("rbList"), Is.EqualTo("random"));
|
||||
Assert.That(sut.GetValue<DateTime>("date").ToString("G"), Is.EqualTo(content.GetValue<DateTime>("date").ToString("G")));
|
||||
|
||||
@@ -339,10 +339,10 @@ namespace Umbraco.Tests.Services
|
||||
|
||||
var parentContentType1 = MockedContentTypes.CreateSimpleContentType("parent1", "Parent1");
|
||||
service.Save(parentContentType1);
|
||||
var parentContentType2 = MockedContentTypes.CreateSimpleContentType("parent2", "Parent2");
|
||||
var parentContentType2 = MockedContentTypes.CreateSimpleContentType("parent2", "Parent2", null, true);
|
||||
service.Save(parentContentType2);
|
||||
|
||||
var simpleContentType = MockedContentTypes.CreateSimpleContentType("category", "Category", parentContentType1);
|
||||
var simpleContentType = MockedContentTypes.CreateSimpleContentType("category", "Category", parentContentType1, true);
|
||||
service.Save(simpleContentType);
|
||||
|
||||
// Act
|
||||
@@ -371,8 +371,8 @@ namespace Umbraco.Tests.Services
|
||||
Assert.AreNotEqual(clonedContentType.Key, originalContentType.Key);
|
||||
Assert.AreNotEqual(clonedContentType.Path, originalContentType.Path);
|
||||
|
||||
Assert.AreNotEqual(clonedContentType.PropertyTypes.First(x => x.Alias.Equals("title")).Id, originalContentType.PropertyTypes.First(x => x.Alias.Equals("title")).Id);
|
||||
Assert.AreNotEqual(clonedContentType.PropertyGroups.First(x => x.Name.Equals("Content")).Id, originalContentType.PropertyGroups.First(x => x.Name.Equals("Content")).Id);
|
||||
Assert.AreNotEqual(clonedContentType.PropertyTypes.First(x => x.Alias.StartsWith("title")).Id, originalContentType.PropertyTypes.First(x => x.Alias.StartsWith("title")).Id);
|
||||
Assert.AreNotEqual(clonedContentType.PropertyGroups.First(x => x.Name.StartsWith("Content")).Id, originalContentType.PropertyGroups.First(x => x.Name.StartsWith("Content")).Id);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -432,10 +432,10 @@ namespace Umbraco.Tests.Services
|
||||
|
||||
var parentContentType1 = MockedContentTypes.CreateSimpleContentType("parent1", "Parent1");
|
||||
service.Save(parentContentType1);
|
||||
var parentContentType2 = MockedContentTypes.CreateSimpleContentType("parent2", "Parent2");
|
||||
var parentContentType2 = MockedContentTypes.CreateSimpleContentType("parent2", "Parent2", null, true);
|
||||
service.Save(parentContentType2);
|
||||
|
||||
var simpleContentType = MockedContentTypes.CreateSimpleContentType("category", "Category", parentContentType1);
|
||||
var simpleContentType = MockedContentTypes.CreateSimpleContentType("category", "Category", parentContentType1, true);
|
||||
service.Save(simpleContentType);
|
||||
|
||||
// Act
|
||||
@@ -460,8 +460,8 @@ namespace Umbraco.Tests.Services
|
||||
Assert.AreNotEqual(clonedContentType.Key, originalContentType.Key);
|
||||
Assert.AreNotEqual(clonedContentType.Path, originalContentType.Path);
|
||||
|
||||
Assert.AreNotEqual(clonedContentType.PropertyTypes.First(x => x.Alias.Equals("title")).Id, originalContentType.PropertyTypes.First(x => x.Alias.Equals("title")).Id);
|
||||
Assert.AreNotEqual(clonedContentType.PropertyGroups.First(x => x.Name.Equals("Content")).Id, originalContentType.PropertyGroups.First(x => x.Name.Equals("Content")).Id);
|
||||
Assert.AreNotEqual(clonedContentType.PropertyTypes.First(x => x.Alias.StartsWith("title")).Id, originalContentType.PropertyTypes.First(x => x.Alias.StartsWith("title")).Id);
|
||||
Assert.AreNotEqual(clonedContentType.PropertyGroups.First(x => x.Name.StartsWith("Content")).Id, originalContentType.PropertyGroups.First(x => x.Name.StartsWith("Content")).Id);
|
||||
}
|
||||
|
||||
private ContentType CreateComponent()
|
||||
@@ -571,7 +571,7 @@ namespace Umbraco.Tests.Services
|
||||
{
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("childType" + i, "ChildType" + i,
|
||||
//make the last entry in the list, this one's parent
|
||||
list.Last());
|
||||
list.Last(), true);
|
||||
|
||||
list.Add(contentType);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Umbraco.Tests.TestHelpers.Entities
|
||||
title = name + " textpage",
|
||||
bodyText = string.Format("This is a textpage based on the {0} ContentType", contentType.Alias),
|
||||
keywords = "text,page,meta",
|
||||
metaDescription = "This is the meta description for a textpage"
|
||||
description = "This is the meta description for a textpage"
|
||||
};
|
||||
|
||||
content.PropertyValues(obj);
|
||||
@@ -121,7 +121,7 @@ namespace Umbraco.Tests.TestHelpers.Entities
|
||||
title = name + " title",
|
||||
bodyText = string.Format("This is a textpage based on the {0} ContentType", contentType.Alias),
|
||||
keywords = "text,page,meta",
|
||||
metaDescription = "This is the meta description for a textpage"
|
||||
description = "This is the meta description for a textpage"
|
||||
};
|
||||
|
||||
content.PropertyValues(obj);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
|
||||
namespace Umbraco.Tests.TestHelpers.Entities
|
||||
{
|
||||
@@ -29,7 +28,7 @@ namespace Umbraco.Tests.TestHelpers.Entities
|
||||
|
||||
var metaCollection = new PropertyTypeCollection();
|
||||
metaCollection.Add(new PropertyType("test", DataTypeDatabaseType.Ntext) { Alias = "keywords", Name = "Meta Keywords", Description = "", HelpText = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 });
|
||||
metaCollection.Add(new PropertyType("test", DataTypeDatabaseType.Ntext) { Alias = "metaDescription", Name = "Meta Description", Description = "", HelpText = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -89 });
|
||||
metaCollection.Add(new PropertyType("test", DataTypeDatabaseType.Ntext) { Alias = "description", Name = "Meta Description", Description = "", HelpText = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -89 });
|
||||
|
||||
contentType.PropertyGroups.Add(new PropertyGroup(contentCollection) { Name = "Content", SortOrder = 1 });
|
||||
contentType.PropertyGroups.Add(new PropertyGroup(metaCollection) { Name = "Meta", SortOrder = 2 });
|
||||
@@ -93,7 +92,7 @@ namespace Umbraco.Tests.TestHelpers.Entities
|
||||
return contentType;
|
||||
}
|
||||
|
||||
public static ContentType CreateSimpleContentType(string alias, string name, IContentType parent = null)
|
||||
public static ContentType CreateSimpleContentType(string alias, string name, IContentType parent = null, bool randomizeAliases = false)
|
||||
{
|
||||
var contentType = parent == null ? new ContentType(-1) : new ContentType(parent);
|
||||
|
||||
@@ -107,9 +106,9 @@ namespace Umbraco.Tests.TestHelpers.Entities
|
||||
contentType.Trashed = false;
|
||||
|
||||
var contentCollection = new PropertyTypeCollection();
|
||||
contentCollection.Add(new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext) { Alias = "title", Name = "Title", Description = "", HelpText = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 });
|
||||
contentCollection.Add(new PropertyType(Constants.PropertyEditors.TinyMCEAlias, DataTypeDatabaseType.Ntext) { Alias = "bodyText", Name = "Body Text", Description = "", HelpText = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -87 });
|
||||
contentCollection.Add(new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext) { Alias = "author", Name = "Author", Description = "Name of the author", HelpText = "", Mandatory = false, SortOrder = 3, DataTypeDefinitionId = -88 });
|
||||
contentCollection.Add(new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext) { Alias = RandomAlias("title", randomizeAliases), Name = "Title", Description = "", HelpText = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88 });
|
||||
contentCollection.Add(new PropertyType(Constants.PropertyEditors.TinyMCEAlias, DataTypeDatabaseType.Ntext) { Alias = RandomAlias("bodyText", randomizeAliases), Name = "Body Text", Description = "", HelpText = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -87 });
|
||||
contentCollection.Add(new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext) { Alias = RandomAlias("author", randomizeAliases) , Name = "Author", Description = "Name of the author", HelpText = "", Mandatory = false, SortOrder = 3, DataTypeDefinitionId = -88 });
|
||||
|
||||
contentType.PropertyGroups.Add(new PropertyGroup(contentCollection) { Name = "Content", SortOrder = 1 });
|
||||
|
||||
@@ -307,5 +306,15 @@ namespace Umbraco.Tests.TestHelpers.Entities
|
||||
|
||||
return contentType;
|
||||
}
|
||||
|
||||
private static string RandomAlias(string alias, bool randomizeAliases)
|
||||
{
|
||||
if (randomizeAliases)
|
||||
{
|
||||
return string.Concat(alias, Guid.NewGuid().ToString("N"));
|
||||
}
|
||||
|
||||
return alias;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user