示例#1
0
        public void When_Node_Exists_Checking_Contains_Should_Return_True()
        {
            // Given a value to add
            const string valueToAdd = "ValueToAdd";

            // And the value is added
            var result = _linkedList.TryAdd(valueToAdd);

            Assert.That(result, Is.True);

            // When we check if the value is there
            var contains = _linkedList.Contains(valueToAdd);

            // The result should be true
            Assert.That(contains, Is.True);
        }
        public void When_Node_Is_Added_Then_Removed_Checking_Contains_Should_Return_False()
        {
            // Given a value to add
            const string VALUE = "ValueToAddThenRemove";

            // And the value is added
            bool isAdded = _linkedList.TryAdd(VALUE);

            Assert.That(isAdded, Is.True);

            // And then the value is removed
            bool isRemoved = _linkedList.Remove(VALUE, out dynamic valueRemoved);

            Assert.That(isRemoved, Is.True);
            Assert.That(valueRemoved, Is.EqualTo(VALUE));

            // When we check if the value is there
            bool contains = _linkedList.Contains(VALUE);

            Assert.That(contains, Is.False);
        }