Added more config defaults + unit tests

This commit is contained in:
Shannon
2013-09-02 19:54:31 +10:00
parent 30b42332e1
commit dc05b10f46
4 changed files with 42 additions and 22 deletions

View File

@@ -5,6 +5,11 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
{
internal class NotDynamicXmlDocumentElementCollection : ConfigurationElementCollection, IEnumerable<NotDynamicXmlDocumentElement>
{
internal void Add(NotDynamicXmlDocumentElement element)
{
BaseAdd(element);
}
protected override ConfigurationElement CreateNewElement()
{
return new NotDynamicXmlDocumentElement();

View File

@@ -8,7 +8,26 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
[ConfigurationProperty("notDynamicXmlDocumentElements", IsDefaultCollection = true)]
public NotDynamicXmlDocumentElementCollection NotDynamicXmlDocumentElements
{
get { return (NotDynamicXmlDocumentElementCollection) base["notDynamicXmlDocumentElements"]; }
get
{
//here we need to check if this element is defined, if it is not then we'll setup the defaults
var prop = Properties["notDynamicXmlDocumentElements"];
var autoFill = this[prop] as ConfigurationElement;
if (autoFill != null && autoFill.ElementInformation.IsPresent == false)
{
var collection = new NotDynamicXmlDocumentElementCollection
{
new NotDynamicXmlDocumentElement {RawValue = "p"},
new NotDynamicXmlDocumentElement {RawValue = "div"},
new NotDynamicXmlDocumentElement {RawValue = "ul"},
new NotDynamicXmlDocumentElement {RawValue = "span"}
};
return collection;
}
return (NotDynamicXmlDocumentElementCollection)base["notDynamicXmlDocumentElements"];
}
}
[ConfigurationCollection(typeof (RazorStaticMappingCollection), AddItemName = "mapping")]

View File

@@ -4,6 +4,22 @@ using NUnit.Framework;
namespace Umbraco.Tests.Configurations.UmbracoSettings
{
[TestFixture]
public class ScriptingElementDefaultTests : ScriptingElementTests
{
protected override bool TestingDefaults
{
get { return true; }
}
[Test]
public override void DataTypeModelStaticMappings()
{
Assert.AreEqual(0, Section.Scripting.Razor.DataTypeModelStaticMappings.Count);
}
}
[TestFixture]
public class ScriptingElementTests : UmbracoSettingsTests
{
@@ -15,7 +31,7 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
}
[Test]
public void DataTypeModelStaticMappings()
public virtual void DataTypeModelStaticMappings()
{
var mappings = Section.Scripting.Razor.DataTypeModelStaticMappings.ToArray();
Assert.IsTrue(mappings[0].DataTypeGuid == Guid.Parse("A3DB4034-BCB0-4E69-B3EE-DD4E6ECA74C2"));

View File

@@ -48,26 +48,6 @@
<defaultRenderingEngine>Mvc</defaultRenderingEngine>
</templates>
<scripting>
<razor>
<!-- razor DynamicNode typecasting detects XML and returns DynamicXml - Root elements that won't convert to DynamicXml -->
<notDynamicXmlDocumentElements>
<element>p</element>
<element>div</element>
<element>ul</element>
<element>span</element>
</notDynamicXmlDocumentElements>
<dataTypeModelStaticMappings>
<mapping dataTypeGuid="A3DB4034-BCB0-4E69-B3EE-DD4E6ECA74C2">MyName.1</mapping>
<mapping documentTypeAlias="textPage2" nodeTypeAlias="propertyAlias2">MyName.2</mapping>
<mapping dataTypeGuid="BD14E709-45BE-431C-B228-6255CDEDFCD5" documentTypeAlias="textPage3" nodeTypeAlias="propertyAlias3">MyName.3</mapping>
<mapping dataTypeGuid="FCE8187E-0366-4833-953A-E5ECA11AA23A" documentTypeAlias="textPage4">MyName.4</mapping>
<mapping dataTypeGuid="9139315A-6681-4C45-B89F-BE48D30F9AB9" nodeTypeAlias="propertyAlias5">MyName.5</mapping>
<mapping nodeTypeAlias="propertyAlias6">MyName.6</mapping>
</dataTypeModelStaticMappings>
</razor>
</scripting>
<!-- distributed calls make umbraco use webservices to handle cache refreshing -->
<distributedCall enable="true">
<!-- the id of the user who's making the calls -->