Mercurial > repos > IBBoard.Tests
annotate ArraysTests.cs @ 49:99e4c1949c92 default tip
* Update to v2.6 of NUnit and new syntax/API changes
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 28 Apr 2013 19:32:14 +0100 |
parents | 8c1e331b47d5 |
children |
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 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
|
7 { |
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 [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
|
9 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
|
10 { |
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 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
|
12 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
|
13 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
|
14 private static readonly string STRING_FOUR = "four"; |
29 | 15 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
|
16 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
|
17 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
|
18 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
|
19 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
|
20 }; |
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 private static readonly string[] ONE_ITEM_ARRAY = new string[] { STRING_FOUR }; |
29 | 22 private static readonly string[] OTHER_ONE_ITEM_ARRAY = new string[] { STRING_TWO }; |
23 private static readonly string[] ANOTHER_ONE_ITEM_ARRAY = new string[] { STRING_THREE }; | |
24 private static readonly string[] TWO_ITEM_ARRAY = new string[] { STRING_ONE, STRING_THREE }; | |
25 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
|
26 |
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
|
27 [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
|
28 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
|
29 { |
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 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
|
31 Assert.That(Arrays.Subtract(ONE_ITEM_ARRAY, THREE_ITEM_ARRAY), Is.EqualTo(ONE_ITEM_ARRAY)); |
29 | 32 Assert.That(Arrays.Subtract(EMPTY_ARRAY, THREE_ITEM_ARRAY), Is.EqualTo(EMPTY_ARRAY)); |
33 Assert.That(Arrays.Subtract(ONE_ITEM_ARRAY, EMPTY_ARRAY), Is.EqualTo(ONE_ITEM_ARRAY)); | |
34 | |
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
|
35 } |
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
|
36 |
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 [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
|
38 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
|
39 { |
49
99e4c1949c92
* Update to v2.6 of NUnit and new syntax/API changes
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
40 Assert.That(Arrays.Subtract(THREE_ITEM_ARRAY, THREE_ITEM_ARRAY), Has.Length.EqualTo(0)); |
99e4c1949c92
* Update to v2.6 of NUnit and new syntax/API changes
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
41 Assert.That(Arrays.Subtract(ONE_ITEM_ARRAY, ONE_ITEM_ARRAY), Has.Length.EqualTo(0)); |
99e4c1949c92
* Update to v2.6 of NUnit and new syntax/API changes
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
42 Assert.That(Arrays.Subtract(EMPTY_ARRAY, EMPTY_ARRAY), Has.Length.EqualTo(0)); |
29 | 43 } |
44 | |
45 [Test()] | |
46 public void TestSubtractWithEmptyArraysDoesNotError() | |
47 { | |
49
99e4c1949c92
* Update to v2.6 of NUnit and new syntax/API changes
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
48 Assert.That(Arrays.Subtract(EMPTY_ARRAY, ONE_ITEM_ARRAY), Has.Length.EqualTo(0)); |
29 | 49 Assert.That(Arrays.Subtract(ONE_ITEM_ARRAY, EMPTY_ARRAY), Is.EqualTo(ONE_ITEM_ARRAY)); |
50 } | |
51 | |
52 [Test()] | |
53 public void TestSubtractWithPartialOverlapLeavesPartialArray() | |
54 { | |
55 Assert.That(Arrays.Subtract(THREE_ITEM_ARRAY, OTHER_ONE_ITEM_ARRAY), Is.EqualTo(TWO_ITEM_ARRAY)); | |
56 Assert.That(Arrays.Subtract(THREE_ITEM_ARRAY, ANOTHER_ONE_ITEM_ARRAY), Is.EqualTo(OTHER_TWO_ITEM_ARRAY)); | |
57 } | |
58 | |
59 [Test()] | |
60 public void TestDifferenceWithNoOverlapReturnsAllEntities() | |
61 { | |
36
8c1e331b47d5
* Remove reliance on IBBoard.NUnit
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
62 Assert.AreEqual(Arrays.Difference(ONE_ITEM_ARRAY, OTHER_ONE_ITEM_ARRAY), new String[]{STRING_FOUR, STRING_TWO}); |
8c1e331b47d5
* Remove reliance on IBBoard.NUnit
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
63 Assert.AreEqual(Arrays.Difference(ONE_ITEM_ARRAY, TWO_ITEM_ARRAY), new String[]{STRING_ONE, STRING_THREE, STRING_FOUR}); |
8c1e331b47d5
* Remove reliance on IBBoard.NUnit
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
64 Assert.AreEqual(Arrays.Difference(TWO_ITEM_ARRAY, ONE_ITEM_ARRAY), new String[]{STRING_ONE, STRING_THREE, STRING_FOUR}); |
8c1e331b47d5
* Remove reliance on IBBoard.NUnit
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
65 Assert.AreEqual(Arrays.Difference(EMPTY_ARRAY, ONE_ITEM_ARRAY), new String[]{STRING_FOUR}); |
8c1e331b47d5
* Remove reliance on IBBoard.NUnit
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
66 Assert.AreEqual(Arrays.Difference(TWO_ITEM_ARRAY, EMPTY_ARRAY), new String[]{STRING_ONE, STRING_THREE}); |
29 | 67 } |
68 | |
69 [Test()] | |
70 public void TestDifferenceWithFullOverlapReturnsNoEntities() | |
71 { | |
72 Assert.That(Arrays.Difference(THREE_ITEM_ARRAY, THREE_ITEM_ARRAY), Is.Empty); | |
73 Assert.That(Arrays.Difference(ONE_ITEM_ARRAY, ONE_ITEM_ARRAY), Is.Empty); | |
74 } | |
75 | |
76 [Test()] | |
77 public void TestIndexOf() | |
78 { | |
79 Assert.That(Arrays.IndexOf(THREE_ITEM_ARRAY, STRING_ONE), Is.EqualTo(0)); | |
80 Assert.That(Arrays.IndexOf(THREE_ITEM_ARRAY, STRING_TWO), Is.EqualTo(1)); | |
81 Assert.That(Arrays.IndexOf(THREE_ITEM_ARRAY, STRING_FOUR), Is.EqualTo(-1)); | |
82 Assert.That(Arrays.IndexOf(EMPTY_ARRAY, STRING_FOUR), Is.EqualTo(-1)); | |
83 } | |
84 | |
85 [Test()] | |
86 public void TestContains() | |
87 { | |
88 Assert.That(Arrays.Contains(THREE_ITEM_ARRAY, STRING_ONE), Is.True); | |
89 Assert.That(Arrays.Contains(THREE_ITEM_ARRAY, STRING_TWO), Is.True); | |
90 Assert.That(Arrays.Contains(THREE_ITEM_ARRAY, STRING_FOUR), Is.False); | |
91 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
|
92 } |
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
|
93 } |
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 |