Beispiel #1
0
        public void Equals_ReturnFalseForNull()
        {
            Tag target = new Tag("test-key", "test-value");
            object other = null;

            Assert.False(target.Equals(other));
        }
Beispiel #2
0
        public void Equals_ReturnFalseForOtherObject()
        {
            Tag target = new Tag("test-key", "test-value");
            string other = "Test";

            Assert.False(target.Equals(other));
        }
Beispiel #3
0
        public void Equals_ReturnFalseForDifferentValues()
        {
            Tag target = new Tag("test-key", "test-value");
            Tag other = new Tag("test-key", "different-value");

            Assert.False(target.Equals(other));
        }
Beispiel #4
0
        public void Constructor_TagValue_SetsKeyAndValue()
        {
            string key = "test-key";
            string value = "test-value";

            Tag target = new Tag(key, value);

            Assert.Equal(key, target.Key);
            Assert.Equal(value, target.Value);
        }
Beispiel #5
0
        /// <summary>
        /// Compares the current Tag object with the specified Tag.
        /// </summary>
        /// <param name="other">The Tag to test for equivalence with the current Tag object.</param>
        /// <returns>true if the objects are equal, otherwise returns false.</returns>
        public bool Equals(Tag other)
        {
            if (other == null) {
                return false;
            }

            return _key.Equals(other._key) && _value.Equals(other._value);
        }
Beispiel #6
0
        public void Equals_ReturnTrueForSameKeyAndValue()
        {
            Tag target = new Tag("test-key", "test-value");
            Tag other = new Tag("test-key", "test-value");

            Assert.True(target.Equals(other));
        }
        public void Remove_string_RemovesItemAndReturnsTrueIfCollectionContainsTag()
        {
            Tag[] tags = new Tag[] { new Tag("test-key-1", "test-value"), new Tag("test-key-2", "test-value") };

            TagsCollection target = new TagsCollection(tags);

            Assert.True(target.Remove(tags[1].Key));
            Assert.Equal(1, target.Count);
            Assert.Contains(tags[0], target);
        }
        public void Remove_Tag_DoNothingAndReturnsFalseIfCollectionDoesNotContainTag()
        {
            TagsCollection target = new TagsCollection(_tags);

            Tag testTag = new Tag("other-key", "other-value");
            Assert.False(target.Remove(testTag));
            this.CompareCollections(_tags, target);
        }
        public void Remove_string_DoNothingAndReturnsFalseIfCollectionDoesNotContainTag()
        {
            Tag[] tags = new Tag[] { new Tag("test-key-1", "test-value"), new Tag("test-key-2", "test-value") };

            TagsCollection target = new TagsCollection(tags);

            Assert.False(target.Remove("non-existing-tag"));
        }
        public void CopyTo_ThrowsArgumentOutOfRangeExceptionIfIndexIsLessThenZero()
        {
            Tag[] array = new Tag[5];
            TagsCollection target = new TagsCollection(_tags);

            Assert.Throws<ArgumentOutOfRangeException>(() => target.CopyTo(array, -4));
        }
        public void CopyTo_ThrowsArgumentExceptionIfSpaceDesignedForCollectionInArrayIsShort()
        {
            Tag[] array = new Tag[5];
            TagsCollection target = new TagsCollection(_tags);

            Assert.Throws<ArgumentException>(() => target.CopyTo(array, 4));
        }
        public void CopyTo_CopiesElementsToArray()
        {
            Tag[] array = new Tag[5];
            TagsCollection target = new TagsCollection(_tags);

            target.CopyTo(array, 1);

            Assert.Null(array[0]);
            Assert.Same(_tags[0], array[1]);
            Assert.Same(_tags[1], array[2]);
            Assert.Same(_tags[2], array[3]);
            Assert.Null(array[4]);
        }
        public void Contains_Tag_ReturnsFalseIfCollectionDoesNotContainTag()
        {
            TagsCollection target = new TagsCollection(_tags);

            Tag testTag = new Tag("test-key-1", "other-value");
            Assert.False(target.Contains(testTag));
        }