annotate ArraysTests.cs @ 31:d8b6dcfb053d

Convince VS2k8 that it doesn't want to keep re-updating the project no-open-ticket
author IBBoard <dev@ibboard.co.uk>
date Sat, 30 Oct 2010 14:24:05 +0000
parents 9bdfaf717b58
children 8c1e331b47d5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 // This file (ArraysTests.cs) is a part of the IBBoard.Tests project and is copyright 2010 IBBoard
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
29
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU LGPL, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
27
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 using System;
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using NUnit.Framework;
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using NUnit.Framework.SyntaxHelpers;
29
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
7 using IBBoard.NUnit;
27
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 namespace IBBoard
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 {
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 [TestFixture()]
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 public class ArraysTests
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 {
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 private static readonly string STRING_ONE = "one";
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 private static readonly string STRING_TWO = "two";
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 private static readonly string STRING_THREE = "three";
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 private static readonly string STRING_FOUR = "four";
29
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
17 private static readonly string[] EMPTY_ARRAY = new string[0];
27
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 private static readonly string[] THREE_ITEM_ARRAY = new string[] {
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 STRING_ONE,
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 STRING_TWO,
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 STRING_THREE
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 };
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 private static readonly string[] ONE_ITEM_ARRAY = new string[] { STRING_FOUR };
29
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
24 private static readonly string[] OTHER_ONE_ITEM_ARRAY = new string[] { STRING_TWO };
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
25 private static readonly string[] ANOTHER_ONE_ITEM_ARRAY = new string[] { STRING_THREE };
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
26 private static readonly string[] TWO_ITEM_ARRAY = new string[] { STRING_ONE, STRING_THREE };
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
27 private static readonly string[] OTHER_TWO_ITEM_ARRAY = new string[] { STRING_ONE, STRING_TWO };
27
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 [Test()]
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 public void TestSubtractWithNoOverlapLeavesSameArray()
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 {
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 Assert.That(Arrays.Subtract(THREE_ITEM_ARRAY, ONE_ITEM_ARRAY), Is.EqualTo(THREE_ITEM_ARRAY));
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 Assert.That(Arrays.Subtract(ONE_ITEM_ARRAY, THREE_ITEM_ARRAY), Is.EqualTo(ONE_ITEM_ARRAY));
29
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
34 Assert.That(Arrays.Subtract(EMPTY_ARRAY, THREE_ITEM_ARRAY), Is.EqualTo(EMPTY_ARRAY));
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
35 Assert.That(Arrays.Subtract(ONE_ITEM_ARRAY, EMPTY_ARRAY), Is.EqualTo(ONE_ITEM_ARRAY));
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
36
27
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37 }
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39 [Test()]
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40 public void TestSubtractWithFullOverlapLeaveEmptyArray()
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41 {
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 Assert.That(Arrays.Subtract(THREE_ITEM_ARRAY, THREE_ITEM_ARRAY), Has.Length(0));
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43 Assert.That(Arrays.Subtract(ONE_ITEM_ARRAY, ONE_ITEM_ARRAY), Has.Length(0));
29
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
44 Assert.That(Arrays.Subtract(EMPTY_ARRAY, EMPTY_ARRAY), Has.Length(0));
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
45 }
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
46
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
47 [Test()]
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
48 public void TestSubtractWithEmptyArraysDoesNotError()
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
49 {
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
50 Assert.That(Arrays.Subtract(EMPTY_ARRAY, ONE_ITEM_ARRAY), Has.Length(0));
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
51 Assert.That(Arrays.Subtract(ONE_ITEM_ARRAY, EMPTY_ARRAY), Is.EqualTo(ONE_ITEM_ARRAY));
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
52 }
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
53
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
54 [Test()]
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
55 public void TestSubtractWithPartialOverlapLeavesPartialArray()
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
56 {
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
57 Assert.That(Arrays.Subtract(THREE_ITEM_ARRAY, OTHER_ONE_ITEM_ARRAY), Is.EqualTo(TWO_ITEM_ARRAY));
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
58 Assert.That(Arrays.Subtract(THREE_ITEM_ARRAY, ANOTHER_ONE_ITEM_ARRAY), Is.EqualTo(OTHER_TWO_ITEM_ARRAY));
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
59 }
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
60
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
61 [Test()]
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
62 public void TestDifferenceWithNoOverlapReturnsAllEntities()
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
63 {
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
64 Assert.That(Arrays.Difference(ONE_ITEM_ARRAY, OTHER_ONE_ITEM_ARRAY), Does.ArrayContain(STRING_FOUR, STRING_TWO));
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
65 Assert.That(Arrays.Difference(ONE_ITEM_ARRAY, TWO_ITEM_ARRAY), Does.ArrayContain(STRING_ONE, STRING_THREE, STRING_FOUR));
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
66 Assert.That(Arrays.Difference(TWO_ITEM_ARRAY, ONE_ITEM_ARRAY), Does.ArrayContain(STRING_ONE, STRING_THREE, STRING_FOUR));
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
67 Assert.That(Arrays.Difference(EMPTY_ARRAY, ONE_ITEM_ARRAY), Does.ArrayContain(STRING_FOUR));
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
68 Assert.That(Arrays.Difference(TWO_ITEM_ARRAY, EMPTY_ARRAY), Does.ArrayContain(STRING_ONE, STRING_THREE));
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
69 }
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
70
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
71 [Test()]
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
72 public void TestDifferenceWithFullOverlapReturnsNoEntities()
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
73 {
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
74 Assert.That(Arrays.Difference(THREE_ITEM_ARRAY, THREE_ITEM_ARRAY), Is.Empty);
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
75 Assert.That(Arrays.Difference(ONE_ITEM_ARRAY, ONE_ITEM_ARRAY), Is.Empty);
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
76 }
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
77
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
78 [Test()]
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
79 public void TestIndexOf()
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
80 {
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
81 Assert.That(Arrays.IndexOf(THREE_ITEM_ARRAY, STRING_ONE), Is.EqualTo(0));
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
82 Assert.That(Arrays.IndexOf(THREE_ITEM_ARRAY, STRING_TWO), Is.EqualTo(1));
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
83 Assert.That(Arrays.IndexOf(THREE_ITEM_ARRAY, STRING_FOUR), Is.EqualTo(-1));
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
84 Assert.That(Arrays.IndexOf(EMPTY_ARRAY, STRING_FOUR), Is.EqualTo(-1));
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
85 }
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
86
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
87 [Test()]
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
88 public void TestContains()
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
89 {
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
90 Assert.That(Arrays.Contains(THREE_ITEM_ARRAY, STRING_ONE), Is.True);
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
91 Assert.That(Arrays.Contains(THREE_ITEM_ARRAY, STRING_TWO), Is.True);
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
92 Assert.That(Arrays.Contains(THREE_ITEM_ARRAY, STRING_FOUR), Is.False);
9bdfaf717b58 Re #2: Refactor API
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
93 Assert.That(Arrays.Contains(EMPTY_ARRAY, STRING_FOUR), Is.False);
27
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
94 }
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
95 }
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
96 }
16c28954b559 * Start to unit test array utility methods before refactoring them to bring them up to date
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
97