// Copyright (c) 2007 Omer Rauchwerger (a.k.a rauchy) (omer@rauchy.net) // All rights reserved. // // This file is part of Regionerate. // // This program is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, // or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . using System.Xml; using BestBrains.System; using NUnit.Framework; using Rauchy.Regionerate.Shared.Components.Rendering; namespace Rauchy.Regionerate.Shared.Components.Tests { /// /// Tests the class. /// [ TestFixture ] public class SymbolTests { #region Tests (3)  /// /// /// /// /// [ Test ] public void ParsesHiddenDragonSymbol() { // Create an XmlNode containing the Symbol data and parse it. string text = CommentReader.GetElement( "SymbolNode" ); ParseAndVerifyType( text ); } /// /// /// /// /// [ Test ] public void ParsesPrefixSymbol() { // Create an XmlNode containing the Symbol data and parse it. string text = CommentReader.GetElement( "SymbolNode" ); Prefix prefix = ParseAndVerifyType( text ); // Verify that the Prefix which was created holds the correct value. Assert.AreEqual( "[rgn]", prefix.Value ); } /// /// /// /// /// [ Test ] public void ParsesWrapperSymbol() { // Create an XmlNode containing the Symbol data and parse it. string text = CommentReader.GetElement( "SymbolNode" ); Wrapper wrapper = ParseAndVerifyType( text ); // Verify that the Wrapper which was created holds the correct values. Assert.AreEqual( "[", wrapper.Prefix ); Assert.AreEqual( "]", wrapper.Suffix ); } #endregion Tests  #region Helper Methods (1)  public TSymbol ParseAndVerifyType( string text ) where TSymbol : Symbol { // Create an XmlNode containing the Symbol text. XmlDocument symbolDocument = new XmlDocument(); symbolDocument.LoadXml( text ); XmlNode symbolNode = symbolDocument[ "Symbol" ]; // Parse the node. Symbol symbol = Symbol.Parse( symbolNode ); // Verify a Symbol of the requested type was created. Assert.IsInstanceOfType( typeof ( TSymbol ), symbol ); return ( TSymbol )symbol; } #endregion Helper Methods  } }