- traceract_exe.zip
- Clifton.Tools.Debug.dll
- Clifton.Tools.Interop.dll
- Clifton.Tools.Strings.dll
- Clifton.Tools.Xml.dll
- content.myxaml
- MenuIcons.resources
- MyXaml.Core.dll
- MyXaml.DockingManager.dll
- MyXaml.MxMenu.dll
- MyXaml.WinForms.dll
- Traceract.exe
- traceract.myxaml
- UnitTest.dll
- WeifenLuo.WinFormsUI.Docking.dll
- WinFormsUIDockingManager.dll
- traceract_src.zip
- aut
- CVS
- MuteLib
- UnitTest
- UTWinForm
- Clifton.Tools.Compiler
- Clifton.Tools.Debug
- Clifton.Tools.Events
- Clifton.Tools.Interop
- Clifton.Tools.Strings
- Clifton.Tools.Xml
- DockPanelSuite
- CVS
- DockSample
- WinFormsUI.ndoc
- WinFormsUI.sln
- WinFormsUI
- AssemblyInfo.cs
- bin
- Debug
- CodeDoc
- Controls
- CVS
- Entries.Log
- Docking
- Helpers
- obj
- Debug
- temp
- TempPE
- WeifenLuo.WinFormsUI.Docking.dll.incr
- WeifenLuo.WinFormsUI.Strings.resources
- Resources
- CVS
- DockPaneCaption.AutoHideNo.bmp
- DockPaneCaption.AutoHideYes.bmp
- DockPaneCaption.CloseDisabled.bmp
- DockPaneCaption.CloseEnabled.bmp
- DockPaneStrip.CloseDisabled.bmp
- DockPaneStrip.CloseEnabled.bmp
- DockPaneStrip.ScrollLeftDisabled.bmp
- DockPaneStrip.ScrollLeftEnabled.bmp
- DockPaneStrip.ScrollRightDisabled.bmp
- DockPaneStrip.ScrollRightEnabled.bmp
- Strings.ResX
- Win32
- WinFormsUI.csproj
- InfragisticsDockingManager
- Myxaml 2.0
- CVS
- MyXaml.Core
- MyXaml.DockingManager
- MyXaml.MxMenu
- MyXaml.MxWorkflow
- MyXaml.WinForms
- Traceract
- WinFormsUIDockingManager
|
using System;
using System.ComponentModel;
using System.Xml;
using Vts.UnitTest;
using MyXaml.Core;
using MyXaml.Core.Exceptions;
namespace MyXamlCoreUnitTests
{
public class Item
{
protected string text;
public string Text
{
get {return text;}
set {text=value;}
}
public Item()
{
}
}
public class Item2
{
protected string text;
public string Text
{
get {return text;}
set {text=value;}
}
}
public class ChildTest
{
}
public class ObjectGraphTestClass
{
protected string name;
protected Item[] items;
protected ChildTest childTest;
public string Name
{
get {return name;}
set {name=value;}
}
public Item[] Items
{
get {return items;}
set {items=value;}
}
public ChildTest MyChild
{
get {return childTest;}
set {childTest=value;}
}
}
[TestFixture]
public class ObjectGraphTests
{
protected Parser parser;
[SetUp]
public void SetUp()
{
parser=new Parser();
}
[Test]
public void PropertyArrayInitializationTest()
{
string xml="<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
xml+="<!-- (c) 2005 MyXaml All Rights Reserved -->\r\n";
xml+="<MyXaml\r\n";
xml+=" xmlns:def=\"Definition\"\r\n";
xml+=" xmlns:ref=\"Reference\"\r\n";
xml+=" xmlns=\"MyXamlCoreUnitTests\">\r\n";
xml+=" <ObjectGraphTestClass>\r\n";
xml+=" <Items>\r\n";
xml+=" <Item Text='a'/>\r\n";
xml+=" <Item Text='b'/>\r\n";
xml+=" <Item Text='c'/>\r\n";
xml+=" </Items>\r\n";
xml+=" </ObjectGraphTestClass>\r\n";
xml+="</MyXaml>\r\n";
ObjectGraphTestClass tc=(ObjectGraphTestClass)parser.InstantiateFromString(xml, "*");
Assertion.Assert(tc.Items[0].Text=="a", "Unexpected result.");
Assertion.Assert(tc.Items[1].Text=="b", "Unexpected result.");
Assertion.Assert(tc.Items[2].Text=="c", "Unexpected result.");
}
[Test]
[ExpectedException(typeof(ArrayConversionException))]
public void PropertyArrayInitializationFailureTest()
{
string xml="<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
xml+="<!-- (c) 2005 MyXaml All Rights Reserved -->\r\n";
xml+="<MyXaml\r\n";
xml+=" xmlns:def=\"Definition\"\r\n";
xml+=" xmlns:ref=\"Reference\"\r\n";
xml+=" xmlns=\"MyXamlCoreUnitTests\">\r\n";
xml+=" <ObjectGraphTestClass>\r\n";
xml+=" <Items>\r\n";
xml+=" <Item2 Text='a'/>\r\n";
xml+=" <Item2 Text='b'/>\r\n";
xml+=" <Item2 Text='c'/>\r\n";
xml+=" </Items>\r\n";
xml+=" </ObjectGraphTestClass>\r\n";
xml+="</MyXaml>\r\n";
parser.InstantiateFromString(xml, "*");
}
[Test]
public void ClassPropertyClassTest()
{
string xml="<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
xml+="<!-- (c) 2005 MyXaml All Rights Reserved -->\r\n";
xml+="<MyXaml\r\n";
xml+=" xmlns:def=\"Definition\"\r\n";
xml+=" xmlns:ref=\"Reference\"\r\n";
xml+=" xmlns=\"MyXamlCoreUnitTests\">\r\n";
xml+=" <ObjectGraphTestClass>\r\n";
xml+=" <MyChild>\r\n";
xml+=" <ChildTest/>\r\n";
xml+=" </MyChild>\r\n";
xml+=" </ObjectGraphTestClass>\r\n";
xml+="</MyXaml>\r\n";
ObjectGraphTestClass tc=(ObjectGraphTestClass)parser.InstantiateFromString(xml, "*");
Assertion.Assert(tc.MyChild != null, "Unexpected result.");
}
[Test]
[ExpectedException(typeof(ChildTypeNotPropertyTypeException))]
public void ClassPropertyNotKindOfTest()
{
string xml="<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
xml+="<!-- (c) 2005 MyXaml All Rights Reserved -->\r\n";
xml+="<MyXaml\r\n";
xml+=" xmlns:def=\"Definition\"\r\n";
xml+=" xmlns:ref=\"Reference\"\r\n";
xml+=" xmlns=\"MyXamlCoreUnitTests\">\r\n";
xml+=" <ObjectGraphTestClass>\r\n";
xml+=" <MyChild>\r\n";
xml+=" <Item/>\r\n";
xml+=" </MyChild>\r\n";
xml+=" </ObjectGraphTestClass>\r\n";
xml+="</MyXaml>\r\n";
parser.InstantiateFromString(xml, "*");
}
[Test]
[ExpectedException(typeof(ExpectedSingleChildException))]
public void MultipleChildrenForAPropertyTest()
{
string xml="<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
xml+="<!-- (c) 2005 MyXaml All Rights Reserved -->\r\n";
xml+="<MyXaml\r\n";
xml+=" xmlns:def=\"Definition\"\r\n";
xml+=" xmlns:ref=\"Reference\"\r\n";
xml+=" xmlns=\"MyXamlCoreUnitTests\">\r\n";
xml+=" <ObjectGraphTestClass>\r\n";
xml+=" <MyChild>\r\n";
xml+=" <ChildTest/>\r\n";
xml+=" <ChildTest/>\r\n";
xml+=" </MyChild>\r\n";
xml+=" </ObjectGraphTestClass>\r\n";
xml+="</MyXaml>\r\n";
parser.InstantiateFromString(xml, "*");
}
// ICollection
// IList
// Abstract property
// Interface implemented by child
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here