예제 #1
0
        public ContractsTests(ISeries <K, V> testSeries,
                              SortedMap <K, V> materializedSeries,
                              SortedMap <K, V> ephemeralSeries = null)
        {
            _testSeries         = testSeries ?? throw new ArgumentNullException(nameof(testSeries));
            _materializedSeries = materializedSeries ?? throw new ArgumentNullException(nameof(materializedSeries));
            _ephemeralSeries    = ephemeralSeries;

            if (!ReferenceEquals(null, ephemeralSeries))
            {
                var eqc = EqualityComparer <V> .Default;
                // TODO (UX) Spreads signature conflicts with LINQ, easy to fix but not very convenient
                var intersect = materializedSeries.Zip(ephemeralSeries, (l, r) =>
                {
                    if (!eqc.Equals(l, r))
                    {
                        throw new ArgumentException("materializedSeries and ephemeralSeries contain different values for the same keys");
                    }
                    else
                    {
                        return(l);
                    }
                });
                if (intersect.First.IsMissing)
                {
                    foreach (var kvp in materializedSeries.Take(10))
                    {
                        ephemeralSeries.Set(kvp.Key, kvp.Value);
                    }
                }
            }
        }