// 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 NUnit.Framework; using Rauchy.Regionerate.Shared.Components.Rendering; namespace Rauchy.Regionerate.Shared.Components.Tests { /// /// Tests the class. /// [ TestFixture ] public class PrefixTests { #region Data Members (1)  private const string SampleText = "This is a sample text."; #endregion Data Members  #region Tests (5)  [ Test ] public void DoesNotRecognizeWrongEmbeddedValue() { bool isEmbedded = IsEmbedded( "[rgn]", "* My Region" ); Assert.IsFalse( isEmbedded ); } [ Test ] public void EmbedsAsteriskPrefix() { EmbedsPrefix( "*" ); } [ Test ] public void EmbedsRgnPrefix() { EmbedsPrefix( "[rgn]" ); } [ Test ] public void RecognizesEmbeddedAsteriskPrefix() { RecognizesEmbeddedPrefix( "*" ); } [ Test ] public void RecognizesEmbeddedRgnPrefix() { RecognizesEmbeddedPrefix( "[rgn]" ); } #endregion Tests  #region Helper Methods (4)  private static string EmbedPrefix( string prefixValue, string text ) { Prefix prefix = new Prefix( prefixValue ); string symbolizedText = prefix.Embed( text ); return symbolizedText; } private static void EmbedsPrefix( string prefixValue ) { string symbolizedText = EmbedPrefix( prefixValue, SampleText ); string expected = string.Format( "{0} {1}", prefixValue, SampleText ); Assert.AreEqual( expected, symbolizedText ); } private static bool IsEmbedded( string prefixValue, string text ) { Prefix prefix = new Prefix( prefixValue ); bool isEmbedded = prefix.IsEmbeddedIn( text ); return isEmbedded; } public void RecognizesEmbeddedPrefix( string prefixValue ) { string text = "#region " + prefixValue + " " + SampleText; bool isEmbedded = IsEmbedded( prefixValue, text ); Assert.IsTrue( isEmbedded ); } #endregion Helper Methods  } }