public void Adding_WithForEach() { // Arrange ReverseCollection <int> reversedCollection = new ReverseCollection <int>(); // Act foreach (int item in initialArray) { reversedCollection.Add(item); } // Assert CollectionAssert.AreEqual(reversedArray, reversedCollection.ToArray()); }
public void IsEmpty() { // Arrange ReverseCollection <int> reversedCollection = new ReverseCollection <int>(); bool expectedIsEmptyBeforeAdding = true; bool actualIsEmptyBeforeAdding = reversedCollection.IsEmpty; bool expectedIsEmptyAfterAdding = false; // Act reversedCollection.Add(1); bool actualIsEmptyAfterAdding = reversedCollection.IsEmpty; // Assert Assert.AreEqual(expectedIsEmptyBeforeAdding, actualIsEmptyBeforeAdding); Assert.AreEqual(expectedIsEmptyAfterAdding, actualIsEmptyAfterAdding); }
public void Clear() { // Arrange ReverseCollection <int> reversedCollection = new ReverseCollection <int>(); int[] expectedCollectionAfterClearing = new int[0]; // Act foreach (int item in initialArray) { reversedCollection.Add(item); } reversedCollection.Clear(); // Assert Assert.IsTrue(reversedCollection.IsEmpty); CollectionAssert.AreEqual(expectedCollectionAfterClearing, reversedCollection.ToArray()); }
public void Count() { // Arrange ReverseCollection <int> reversedCollection = new ReverseCollection <int>(); int expectedCountBeforeAdding = 0; int actualCountBeforeAdding = reversedCollection.Count; int expectedCountAfterAdding = 5; // Act for (int i = 0; i < expectedCountAfterAdding; ++i) { reversedCollection.Add(i); } int actualCountAfterAdding = reversedCollection.Count; // Assert Assert.AreEqual(expectedCountBeforeAdding, actualCountBeforeAdding); Assert.AreEqual(expectedCountAfterAdding, actualCountAfterAdding); }
public void Contains() { // Arrange ReverseCollection <int> reversedCollection = new ReverseCollection <int>(); int elementToSearch = 2; bool expectedContainsElementBeforeAdding = false; bool expectedContainsElementAfterAdding = true; // Act bool actualContainsElementBeforeAdding = reversedCollection.Contains(elementToSearch); foreach (int item in initialArray) { reversedCollection.Add(item); } bool actualContainsElementAfterAdding = reversedCollection.Contains(elementToSearch); // Assert Assert.AreEqual(expectedContainsElementBeforeAdding, actualContainsElementBeforeAdding); Assert.AreEqual(expectedContainsElementAfterAdding, actualContainsElementAfterAdding); CollectionAssert.Contains(reversedCollection.ToArray(), elementToSearch); }
public void Adding_ThreeRandom() { // Arrange ReverseCollection <int> reversedCollection = new ReverseCollection <int>(); int[] baseCollection = new int[3] { Convert.ToInt32(TestContext.DataRow["First"]), Convert.ToInt32(TestContext.DataRow["Second"]), Convert.ToInt32(TestContext.DataRow["Third"]) }; int[] expectedCollection = baseCollection.Reverse().ToArray(); // Act foreach (int item in baseCollection) { reversedCollection.Add(item); } int[] actualCollection = reversedCollection.ToArray(); // Assert CollectionAssert.AreEqual(expectedCollection, actualCollection); }