# HG changeset patch # User IBBoard # Date 1282075333 0 # Node ID 16c28954b559b982b21693fbe4d6f1b39cb357a5 # Parent 57b5d27e95fb5ee85cb54a27d6e86b179a20c7fe * 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 diff -r 57b5d27e95fb -r 16c28954b559 ArraysTests.cs --- /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)); + } + } +} + diff -r 57b5d27e95fb -r 16c28954b559 IBBoard.Tests.csproj --- 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 @@ + + + + + @@ -61,6 +66,7 @@ + @@ -102,5 +108,8 @@ false PreserveNewest + + PreserveNewest + \ No newline at end of file diff -r 57b5d27e95fb -r 16c28954b559 PrefTestPref.xml --- /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 @@ + + + + + + + +]> + + true + some string here + 255 + \ No newline at end of file diff -r 57b5d27e95fb -r 16c28954b559 Prefs/PreferencesTest.cs --- /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() + { + + } + } +}