Mercurial > repos > IBBoard.Tests
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 |
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 | 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 | 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 | 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 | 24 private static readonly string[] OTHER_ONE_ITEM_ARRAY = new string[] { STRING_TWO }; |
25 private static readonly string[] ANOTHER_ONE_ITEM_ARRAY = new string[] { STRING_THREE }; | |
26 private static readonly string[] TWO_ITEM_ARRAY = new string[] { STRING_ONE, STRING_THREE }; | |
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 | 34 Assert.That(Arrays.Subtract(EMPTY_ARRAY, THREE_ITEM_ARRAY), Is.EqualTo(EMPTY_ARRAY)); |
35 Assert.That(Arrays.Subtract(ONE_ITEM_ARRAY, EMPTY_ARRAY), Is.EqualTo(ONE_ITEM_ARRAY)); | |
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 | 44 Assert.That(Arrays.Subtract(EMPTY_ARRAY, EMPTY_ARRAY), Has.Length(0)); |
45 } | |
46 | |
47 [Test()] | |
48 public void TestSubtractWithEmptyArraysDoesNotError() | |
49 { | |
50 Assert.That(Arrays.Subtract(EMPTY_ARRAY, ONE_ITEM_ARRAY), Has.Length(0)); | |
51 Assert.That(Arrays.Subtract(ONE_ITEM_ARRAY, EMPTY_ARRAY), Is.EqualTo(ONE_ITEM_ARRAY)); | |
52 } | |
53 | |
54 [Test()] | |
55 public void TestSubtractWithPartialOverlapLeavesPartialArray() | |
56 { | |
57 Assert.That(Arrays.Subtract(THREE_ITEM_ARRAY, OTHER_ONE_ITEM_ARRAY), Is.EqualTo(TWO_ITEM_ARRAY)); | |
58 Assert.That(Arrays.Subtract(THREE_ITEM_ARRAY, ANOTHER_ONE_ITEM_ARRAY), Is.EqualTo(OTHER_TWO_ITEM_ARRAY)); | |
59 } | |
60 | |
61 [Test()] | |
62 public void TestDifferenceWithNoOverlapReturnsAllEntities() | |
63 { | |
64 Assert.That(Arrays.Difference(ONE_ITEM_ARRAY, OTHER_ONE_ITEM_ARRAY), Does.ArrayContain(STRING_FOUR, STRING_TWO)); | |
65 Assert.That(Arrays.Difference(ONE_ITEM_ARRAY, TWO_ITEM_ARRAY), Does.ArrayContain(STRING_ONE, STRING_THREE, STRING_FOUR)); | |
66 Assert.That(Arrays.Difference(TWO_ITEM_ARRAY, ONE_ITEM_ARRAY), Does.ArrayContain(STRING_ONE, STRING_THREE, STRING_FOUR)); | |
67 Assert.That(Arrays.Difference(EMPTY_ARRAY, ONE_ITEM_ARRAY), Does.ArrayContain(STRING_FOUR)); | |
68 Assert.That(Arrays.Difference(TWO_ITEM_ARRAY, EMPTY_ARRAY), Does.ArrayContain(STRING_ONE, STRING_THREE)); | |
69 } | |
70 | |
71 [Test()] | |
72 public void TestDifferenceWithFullOverlapReturnsNoEntities() | |
73 { | |
74 Assert.That(Arrays.Difference(THREE_ITEM_ARRAY, THREE_ITEM_ARRAY), Is.Empty); | |
75 Assert.That(Arrays.Difference(ONE_ITEM_ARRAY, ONE_ITEM_ARRAY), Is.Empty); | |
76 } | |
77 | |
78 [Test()] | |
79 public void TestIndexOf() | |
80 { | |
81 Assert.That(Arrays.IndexOf(THREE_ITEM_ARRAY, STRING_ONE), Is.EqualTo(0)); | |
82 Assert.That(Arrays.IndexOf(THREE_ITEM_ARRAY, STRING_TWO), Is.EqualTo(1)); | |
83 Assert.That(Arrays.IndexOf(THREE_ITEM_ARRAY, STRING_FOUR), Is.EqualTo(-1)); | |
84 Assert.That(Arrays.IndexOf(EMPTY_ARRAY, STRING_FOUR), Is.EqualTo(-1)); | |
85 } | |
86 | |
87 [Test()] | |
88 public void TestContains() | |
89 { | |
90 Assert.That(Arrays.Contains(THREE_ITEM_ARRAY, STRING_ONE), Is.True); | |
91 Assert.That(Arrays.Contains(THREE_ITEM_ARRAY, STRING_TWO), Is.True); | |
92 Assert.That(Arrays.Contains(THREE_ITEM_ARRAY, STRING_FOUR), Is.False); | |
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 |