From: <gc...@us...> - 2003-03-11 20:05:29
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework.Tests/Xml/XPath In directory sc8-pr-cvs1:/tmp/cvs-serv9039/Xml/XPath Added Files: MockXPathNavigableTests.cs Log Message: --- NEW FILE: MockXPathNavigableTests.cs --- using System; using System.Xml; using System.Xml.XPath; using NUnit.Framework; using DotNetMock.Xml.XPath; namespace DotNetMock.Tests.Xml.XPath { [TestFixture] public class MockXPathNavigableTests { private class TestXPathNavigator : XPathNavigator { public override string BaseURI { get { return null; } } public override System.Xml.XPath.XPathNavigator Clone() { return null; } public override string GetAttribute(string localName, string namespaceURI) { return null; } public override string GetNamespace(string name) { return null; } public override bool HasAttributes { get { return true; } } public override bool HasChildren { get { return true; } } public override bool IsEmptyElement { get { return true; } } public override bool IsSamePosition(System.Xml.XPath.XPathNavigator other) { return true; } public override string LocalName { get { return null; } } public override bool MoveTo(System.Xml.XPath.XPathNavigator other) { return true; } public override bool MoveToAttribute(string localName, string namespaceURI) { return true; } public override bool MoveToFirst() { return true; } public override bool MoveToFirstAttribute() { return true; } public override bool MoveToFirstChild() { return true; } public override bool MoveToFirstNamespace(System.Xml.XPath.XPathNamespaceScope namespaceScope) { return true; } public override bool MoveToId(string id) { return true; } public override bool MoveToNamespace(string name) { return true; } public override bool MoveToNext() { return true; } public override bool MoveToNextAttribute() { return true; } public override bool MoveToNextNamespace(System.Xml.XPath.XPathNamespaceScope namespaceScope) { return true; } public override bool MoveToParent() { return true; } public override void MoveToRoot() { } public override string Name { get { return null; } } public override string NamespaceURI { get { return null; } } public override System.Xml.XmlNameTable NameTable { get { return null; } } public override System.Xml.XPath.XPathNodeType NodeType { get { return new System.Xml.XPath.XPathNodeType(); } } public override string Prefix { get { return null; } } public override string Value { get { return null; } } public override string XmlLang { get { return null; } } public override bool MoveToPrevious() { return true; } } private MockXPathNavigable mockNav = null; [SetUp] public void init() { mockNav = new MockXPathNavigable(); } [TearDown] public void Destroy() { mockNav = null; } [Test] public void CreateNavigatorExpectedCount() { mockNav.SetExpectedCreateCount(2); mockNav.CreateNavigator(); mockNav.CreateNavigator(); mockNav.Verify(); } [Test] [ExpectedException(typeof(AssertionException))] public void CreateNavigatorExpectedCountFails() { mockNav.SetExpectedCreateCount(2); mockNav.CreateNavigator(); mockNav.Verify(); } [Test] [ExpectedException(typeof(XmlException))] public void ExceptionCreateNavigator() { mockNav.SetCreateException(new XmlException("", null)); mockNav.CreateNavigator(); } [Test] public void ExpectedNavigator() { XPathNavigator expectedNav = new TestXPathNavigator(); mockNav.SetExpectedNavigator( expectedNav ); Assertion.AssertEquals("Navigators not equal.", expectedNav, mockNav.CreateNavigator()); } [Test] public void DummyNavigator() { XPathNavigator navigator = null; navigator = mockNav.CreateNavigator(); Assertion.AssertNotNull( "Navigator should never be null.", navigator ); Assertion.AssertEquals( "Navigators should equal.", typeof(XPathNavigator), navigator.GetType().BaseType ); } } } |