Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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());
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }