Changed DynamicXml to public (somehow this wasn't checked in before) #U4-U4-1146

Added unit tests for DynamicXml.Find methods which are passing.
This commit is contained in:
Shannon Deminick
2012-11-06 08:32:21 +06:00
parent f80fa2f373
commit fb0c9c3fbb
3 changed files with 60 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ using System.Web;
namespace Umbraco.Core.Dynamics
{
internal class DynamicXml : DynamicObject, IEnumerable
public class DynamicXml : DynamicObject, IEnumerable
{
public XElement BaseElement { get; set; }

View File

@@ -0,0 +1,58 @@
using System;
using System.Xml;
using System.Xml.Linq;
using Microsoft.CSharp.RuntimeBinder;
using NUnit.Framework;
using Umbraco.Core.Dynamics;
namespace Umbraco.Tests.DynamicDocument
{
[TestFixture]
public class DynamicXmlTests
{
/// <summary>
/// Test the current Core class
/// </summary>
[Test]
public void Find_Test_Core_Class()
{
RunFindTest(x => new DynamicXml(x));
}
/// <summary>
/// Tests the macroEngines legacy class
/// </summary>
[Test]
public void Find_Test_Legacy_Class()
{
RunFindTest(x => new global::umbraco.MacroEngines.DynamicXml(x));
}
private void RunFindTest(Func<string, dynamic> getDynamicXml)
{
var xmlstring = @"<test>
<item id='1' name='test 1' value='found 1'/>
<item id='2' name='test 2' value='found 2'/>
<item id='3' name='test 3' value='found 3'/>
</test>";
dynamic dXml = getDynamicXml(xmlstring);
var result1 = dXml.Find("@name", "test 1");
var result2 = dXml.Find("@name", "test 2");
var result3 = dXml.Find("@name", "test 3");
var result4 = dXml.Find("@name", "dont find");
Assert.AreEqual("found 1", result1.value);
Assert.AreEqual("found 2", result2.value);
Assert.AreEqual("found 3", result3.value);
Assert.Throws<RuntimeBinderException>(() =>
{
//this will throw because result4 is not found
var temp = result4.value;
});
}
}
}

View File

@@ -55,6 +55,7 @@
<ItemGroup>
<Compile Include="BusinessLogic\DictionaryTest.cs" />
<Compile Include="ContentStores\PublishMediaStoreTests.cs" />
<Compile Include="DynamicDocument\DynamicXmlTests.cs" />
<Compile Include="DynamicDocument\PublishedContentDataTableTests.cs" />
<Compile Include="DynamicDocument\PublishedContentTests.cs" />
<Compile Include="DynamicDocument\StronglyTypedQueryTests.cs" />