コード例 #1
0
        public void Remove_ManyOccurrence()
        {
            // Arrange
            int[] startCollection = new int[] { 1, 2, 3, 3, 2, 1 };
            ReverseCollection <int> reversedCollection = new ReverseCollection <int>(startCollection);

            int  itemToRemove         = 2;
            bool expectedRemoveResult = true;

            bool expectedContainItemBeforeRemoving = true;
            bool exoectedContainItemAfterRemoving  = true;

            int[] expectedCollection = new int[] { 1, 3, 3, 2, 1 };

            // Act
            bool actualContainItemBeforeRemoving = reversedCollection.Contains(itemToRemove);
            bool actualRemoveResult             = reversedCollection.Remove(itemToRemove);
            bool actualContainItemAfterRemoving = reversedCollection.Contains(itemToRemove);

            // Assert
            Assert.AreEqual(expectedRemoveResult, actualRemoveResult);
            Assert.AreEqual(expectedContainItemBeforeRemoving, actualContainItemBeforeRemoving);
            Assert.AreEqual(exoectedContainItemAfterRemoving, actualContainItemAfterRemoving);
            CollectionAssert.Contains(reversedCollection.ToArray(), itemToRemove);
        }
コード例 #2
0
        public void Remove_OneOccurrence()
        {
            // Arrange
            ReverseCollection <int> reversedCollection = new ReverseCollection <int>(initialArray);

            int  itemToRemove         = 2;
            bool expectedRemoveResult = true;

            bool expectedContainItemBeforeRemoving = true;
            bool exoectedContainItemAfterRemoving  = false;

            int[] expectedCollection = new int[4] {
                5, 4, 3, 1
            };

            // Act
            bool actualContainItemBeforeRemoving = reversedCollection.Contains(itemToRemove);
            bool actualRemoveResult             = reversedCollection.Remove(itemToRemove);
            bool actualContainItemAfterRemoving = reversedCollection.Contains(itemToRemove);

            int[] actualCollection = reversedCollection.ToArray();

            // Assert
            Assert.AreEqual(expectedRemoveResult, actualRemoveResult);
            Assert.AreEqual(expectedContainItemBeforeRemoving, actualContainItemBeforeRemoving);
            Assert.AreEqual(exoectedContainItemAfterRemoving, actualContainItemAfterRemoving);
            CollectionAssert.AreEqual(expectedCollection, actualCollection);
            CollectionAssert.DoesNotContain(actualCollection, itemToRemove);
        }
コード例 #3
0
        public void Remove_WrongItem_False()
        {
            // Arrange
            ReverseCollection <int> reversedCollection = new ReverseCollection <int>(initialArray);

            int  itemToRemove         = int.MaxValue;
            bool expectedRemoveResult = false;

            bool expectedContainItemBeforeRemoving = false;
            bool exoectedContainItemAfterRemoving  = false;

            // Act
            bool actualContainItemBeforeRemoving = reversedCollection.Contains(itemToRemove);
            bool actualRemoveResult             = reversedCollection.Remove(itemToRemove);
            bool actualContainItemAfterRemoving = reversedCollection.Contains(itemToRemove);

            // Assert
            Assert.AreEqual(expectedRemoveResult, actualRemoveResult);
            Assert.AreEqual(expectedContainItemBeforeRemoving, actualContainItemBeforeRemoving);
            Assert.AreEqual(exoectedContainItemAfterRemoving, actualContainItemAfterRemoving);
            CollectionAssert.DoesNotContain(reversedCollection.ToArray(), itemToRemove);
        }