public void GetHashCodeThrowsExceptionWithNullObjectTest()
        {
            var target = new SupportedTagAttributeComparer();

            Action action = () => target.GetHashCode(null);

            action.ShouldThrow <ArgumentNullException>();
        }
        public void EqualsReturnsFalseWhenSecondIsNullTest()
        {
            var tag = new SupportedTagAttribute(Guid.NewGuid().ToString());

            var target = new SupportedTagAttributeComparer();

            var actual = target.Equals(tag, null);

            actual.Should().BeFalse();
        }
        public void EqualsReturnsFalseWhenFirstIsNullTest()
        {
            var tag = new SupportedTagAttribute(Guid.NewGuid().ToString());

            var target = new SupportedTagAttributeComparer();

            var actual = target.Equals(null, tag);

            actual.Should().BeFalse();
        }
        public void EqualsReturnsFalseWhenAttributeFilterDoesNotMatchTest()
        {
            var first  = new SupportedTagAttribute(Guid.NewGuid().ToString());
            var second = new SupportedTagAttribute(first.TagName, Guid.NewGuid().ToString(), Guid.NewGuid().ToString());

            var target = new SupportedTagAttributeComparer();

            var actual = target.Equals(first, second);

            actual.Should().BeFalse();
        }
        public void EqualsReturnsTrueWhenTagsMatchWithoutAttributesTest()
        {
            var first  = new SupportedTagAttribute(Guid.NewGuid().ToString());
            var second = new SupportedTagAttribute(first.TagName);

            var target = new SupportedTagAttributeComparer();

            var actual = target.Equals(first, second);

            actual.Should().BeTrue();
        }
        public void EqualsReturnsFalseWhenAttributeFilterDoesNotMatchTest()
        {
            var first = new SupportedTagAttribute(Guid.NewGuid().ToString());
            var second = new SupportedTagAttribute(first.TagName, Guid.NewGuid().ToString(), Guid.NewGuid().ToString());

            var target = new SupportedTagAttributeComparer();

            var actual = target.Equals(first, second);

            actual.Should().BeFalse();
        }
        public void GetHashCodeReturnsSameValueForMatchingTagTest()
        {
            var first  = new SupportedTagAttribute(Guid.NewGuid().ToString());
            var second = new SupportedTagAttribute(first.TagName);

            var target = new SupportedTagAttributeComparer();

            var firstCode  = target.GetHashCode(first);
            var secondCode = target.GetHashCode(second);

            firstCode.Should().Be(secondCode);
        }
        public void GetHashCodeReturnsDifferentValueForMismatchedTagTest()
        {
            var first  = new SupportedTagAttribute(Guid.NewGuid().ToString());
            var second = new SupportedTagAttribute(Guid.NewGuid().ToString());

            var target = new SupportedTagAttributeComparer();

            var firstCode  = target.GetHashCode(first);
            var secondCode = target.GetHashCode(second);

            firstCode.Should().NotBe(secondCode);
        }
Example #9
0
        /// <summary>
        ///     Finds the supported tags.
        /// </summary>
        /// <param name="types">
        ///     The types.
        /// </param>
        /// <returns>
        ///     An <see cref="IEnumerable{T}" /> value.
        /// </returns>
        private static IList<SupportedTagAttribute> FindSupportedTags(IEnumerable<Type> types)
        {
            var tagsFound = new List<SupportedTagAttribute>();
            var comparer = new SupportedTagAttributeComparer();

            foreach (var type in types)
            {
                var attributes =
                    type.GetCustomAttributes(typeof(SupportedTagAttribute), true).OfType<SupportedTagAttribute>();

                foreach (var attribute in attributes)
                {
                    if (tagsFound.Contains(attribute, comparer))
                    {
                        continue;
                    }

                    tagsFound.Add(attribute);
                }
            }

            return tagsFound;
        }
        public void GetHashCodeThrowsExceptionWithNullObjectTest()
        {
            var target = new SupportedTagAttributeComparer();

            Action action = () => target.GetHashCode(null);

            action.ShouldThrow<ArgumentNullException>();
        }
        public void GetHashCodeReturnsSameValueForMatchingTagTest()
        {
            var first = new SupportedTagAttribute(Guid.NewGuid().ToString());
            var second = new SupportedTagAttribute(first.TagName);

            var target = new SupportedTagAttributeComparer();

            var firstCode = target.GetHashCode(first);
            var secondCode = target.GetHashCode(second);

            firstCode.Should().Be(secondCode);
        }
        public void GetHashCodeReturnsDifferentValueForMismatchedTagTest()
        {
            var first = new SupportedTagAttribute(Guid.NewGuid().ToString());
            var second = new SupportedTagAttribute(Guid.NewGuid().ToString());

            var target = new SupportedTagAttributeComparer();

            var firstCode = target.GetHashCode(first);
            var secondCode = target.GetHashCode(second);

            firstCode.Should().NotBe(secondCode);
        }
        public void EqualsReturnsTrueWhenTagsMatchWithoutAttributesTest()
        {
            var first = new SupportedTagAttribute(Guid.NewGuid().ToString());
            var second = new SupportedTagAttribute(first.TagName);

            var target = new SupportedTagAttributeComparer();

            var actual = target.Equals(first, second);

            actual.Should().BeTrue();
        }