Exemplo n.º 1
0
        public void Equals_ReturnFalseForNull()
        {
            Tag target = new Tag("test-key", "test-value");
            object other = null;

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

            Assert.False(target.Equals(other));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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"));
        }
Exemplo n.º 10
0
        public void CopyTo_ThrowsArgumentOutOfRangeExceptionIfIndexIsLessThenZero()
        {
            Tag[] array = new Tag[5];
            TagsCollection target = new TagsCollection(_tags);

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

            Assert.Throws<ArgumentException>(() => target.CopyTo(array, 4));
        }
Exemplo n.º 12
0
        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]);
        }
Exemplo n.º 13
0
        public void Contains_Tag_ReturnsFalseIfCollectionDoesNotContainTag()
        {
            TagsCollection target = new TagsCollection(_tags);

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