Mercurial > repos > IBBoard.Tests
changeset 27:16c28954b559
* Start to unit test array utility methods before refactoring them to bring them up to date
* Add some Preference-related tests that have been hanging around for a while
no-open-ticket
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 17 Aug 2010 20:02:13 +0000 |
parents | 57b5d27e95fb |
children | 31fdc90f3556 |
files | ArraysTests.cs IBBoard.Tests.csproj PrefTestPref.xml Prefs/PreferencesTest.cs |
diffstat | 4 files changed, 89 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ArraysTests.cs Tue Aug 17 20:02:13 2010 +0000 @@ -0,0 +1,38 @@ +// This file (ArraysTests.cs) is a part of the IBBoard.Tests project and is copyright 2010 IBBoard +// +// // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. +using System; +using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; +namespace IBBoard +{ + [TestFixture()] + public class ArraysTests + { + private static readonly string STRING_ONE = "one"; + private static readonly string STRING_TWO = "two"; + private static readonly string STRING_THREE = "three"; + private static readonly string STRING_FOUR = "four"; + private static readonly string[] THREE_ITEM_ARRAY = new string[] { + STRING_ONE, + STRING_TWO, + STRING_THREE + }; + private static readonly string[] ONE_ITEM_ARRAY = new string[] { STRING_FOUR }; + + [Test()] + public void TestSubtractWithNoOverlapLeavesSameArray() + { + Assert.That(Arrays.Subtract(THREE_ITEM_ARRAY, ONE_ITEM_ARRAY), Is.EqualTo(THREE_ITEM_ARRAY)); + Assert.That(Arrays.Subtract(ONE_ITEM_ARRAY, THREE_ITEM_ARRAY), Is.EqualTo(ONE_ITEM_ARRAY)); + } + + [Test()] + public void TestSubtractWithFullOverlapLeaveEmptyArray() + { + Assert.That(Arrays.Subtract(THREE_ITEM_ARRAY, THREE_ITEM_ARRAY), Has.Length(0)); + Assert.That(Arrays.Subtract(ONE_ITEM_ARRAY, ONE_ITEM_ARRAY), Has.Length(0)); + } + } +} +
--- a/IBBoard.Tests.csproj Sat Jun 05 10:58:09 2010 +0000 +++ b/IBBoard.Tests.csproj Tue Aug 17 20:02:13 2010 +0000 @@ -43,6 +43,11 @@ <Compile Include="Lang\TranslationXmlLoaderTest.cs" /> <Compile Include="Lang\TranslationLanguageTest.cs" /> <Compile Include="Lang\XmlTranslationSetTest.cs" /> + <Compile Include="Prefs\PreferencesTest.cs" /> + <Compile Include="Limits\AbstractCompositeLimitTest.cs" /> + <Compile Include="Limits\CompositeMinimumLimitTest.cs" /> + <Compile Include="Limits\CompositeMaximumLimitTest.cs" /> + <Compile Include="ArraysTests.cs" /> </ItemGroup> <ItemGroup> <Reference Include="System" /> @@ -61,6 +66,7 @@ <Folder Include="test-data\TranslationTests\" /> <Folder Include="test-data\XmlLoaderTests\" /> <Folder Include="test-data\XmlLoaderTests\translations\" /> + <Folder Include="Prefs\" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\IBBoard\IBBoard.csproj"> @@ -102,5 +108,8 @@ <Gettext-ScanForTranslations>false</Gettext-ScanForTranslations> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> + <None Include="PrefTestPref.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> </ItemGroup> </Project> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PrefTestPref.xml Tue Aug 17 20:02:13 2010 +0000 @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!DOCTYPE races[ + <!ELEMENT preferences (preferece*)> + <!ELEMENT preference (CDATA|preferenceArr)> + <!ELEMENT preferenceArr (CDATA)> + <!ATTLIST preference id ID #REQUIRED> + <!ATTLIST preference type CDATA #REQUIRED> + <!ATTLIST preferenceArr id ID #REQUIRED> +]> +<preferences> + <preference id="boolVal" type="System.Boolean">true</preference> + <preference id="stringVal" type="System.String">some string here</preference> + <preference id="byteVal" type="System.Byte">255</preference> +</preferences> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Prefs/PreferencesTest.cs Tue Aug 17 20:02:13 2010 +0000 @@ -0,0 +1,28 @@ +// This file (PreferencesTest.cs) is a part of the IBBoard.Tests project and is copyright 2010 IBBoard +// +// // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. + +using System; +using NUnit.Framework; + +namespace IBBoard.Prefs +{ + [TestFixture()] + public class PreferencesTest + { + [Test()] + public void TestPreferencesContainExpectedPrefs() + { + Preferences prefs = new Preferences("PrefTest"); + Assert.AreEqual(true, prefs["boolVal"]); + Assert.AreEqual("some string here", prefs["stringVal"]); + Assert.AreEqual(255, prefs["byteVal"]); + } + + [Test()] + public void TestBehaviourOfMissingValue() + { + + } + } +}