コード例 #1
0
        public void ValueMatcherEqualsByTypeAndValue()
        {
            var matcher = new ValueMatcher(typeof(string), "foo");
            var other   = new ValueMatcher(typeof(string), "foo");

            Assert.True(matcher.Equals(other));
            Assert.True(matcher.Equals(other, EqualityComparer <object> .Default));
            Assert.Equal(matcher.GetHashCode(), other.GetHashCode());
            Assert.Equal(matcher.GetHashCode(EqualityComparer <object> .Default), other.GetHashCode(EqualityComparer <object> .Default));

            Assert.False(matcher.Equals(new ValueMatcher(typeof(string), "bar")));
            Assert.False(matcher.Equals(new ValueMatcher(typeof(object), "foo")));
        }
コード例 #2
0
        public void ValueMatcherEqualsByEqualityComparer()
        {
            var comparer = StringComparer.OrdinalIgnoreCase;
            var matcher  = new ValueMatcher(typeof(string), "foo", comparer);
            var other    = new ValueMatcher(typeof(string), "FOO", comparer);

            Assert.True(matcher.Equals(other));
            Assert.Equal(matcher.GetHashCode(), other.GetHashCode());

            Assert.False(matcher.Equals(new ValueMatcher(typeof(string), "bar")));
            Assert.False(matcher.Equals(new ValueMatcher(typeof(object), "foo")));
        }