Esempio n. 1
0
        internal Arguments(string prefix, params KeyValuePair <string, string>[] pairs)
        {
            this._prefix = prefix ?? string.Empty;
            ChainableEqualizer <KeyValuePair <string, string> > chainableEqualizer = Eq <KeyValuePair <string, string> > .By((KeyValuePair <string, string> x, KeyValuePair <string, string> y) => string.Equals(x.Key, y.Key, StringComparison.OrdinalIgnoreCase), (KeyValuePair <string, string> x) => x.Key.ToLowerInvariant().GetHashCode());

            this._pairs      = ((IEnumerable <KeyValuePair <string, string> >)(pairs ?? new KeyValuePair <string, string> [0])).Distinct <KeyValuePair <string, string> >(chainableEqualizer).ToArray <KeyValuePair <string, string> >();
            this._dictionary = ((IEnumerable <KeyValuePair <string, string> >) this._pairs).ToDictionary <KeyValuePair <string, string>, string, string>((KeyValuePair <string, string> x) => x.Key, (KeyValuePair <string, string> x) => x.Value, StringComparer.OrdinalIgnoreCase);
        }
        public void Explore()
        {
            PropertySEqualizer inheritor = new PropertySEqualizer();

            Assert.That(inheritor, Is.InstanceOf <IEqualityComparer <EqualitySubject> >(), "is a proper comparer");

            EqualitySubject one = new EqualitySubject("1", 1, 1m), two = new EqualitySubject("1", 2, 2m);

            Assert.That(inheritor.Equals(one, two), Is.True, "x.S == y.S");
            Assert.That(inheritor.GetHashCode(one), Is.EqualTo(one.S.GetHashCode()));

            ChainableEqualizer <EqualitySubject> chained = inheritor.Then(new PropertyIEqualizer());

            Assert.That(one, Is.Not.EqualTo(two).Using(chained), "x.I != y.I");
        }
Esempio n. 3
0
        internal Arguments(string prefix, params KeyValuePair <string, string>[] pairs)
        {
            this._prefix = prefix ?? string.Empty;
            bool equals(KeyValuePair <string, string> x, KeyValuePair <string, string> y) => string.Equals(x.Key, y.Key, StringComparison.OrdinalIgnoreCase);

            ChainableEqualizer <KeyValuePair <string, string> > chainableEqualizer = Eq <KeyValuePair <string, string> > .By(equals, x => x.Key.ToLowerInvariant().GetHashCode());

            _pairs = ((IEnumerable <KeyValuePair <string, string> >)(pairs ?? new KeyValuePair <string, string> [0])).Distinct(chainableEqualizer).ToArray();
            KeyValuePair <string, string>[] pairs1 = _pairs;
            string keySelector(KeyValuePair <string, string> x) => x.Key;

            StringComparer ordinalIgnoreCase = StringComparer.OrdinalIgnoreCase;

            _dictionary = ((IEnumerable <KeyValuePair <string, string> >)pairs1).ToDictionary(keySelector, x => x.Value, ordinalIgnoreCase);
        }