/// <summary>
        /// Initializes a new instance of the
        /// <see cref="MultiMapDataConcrete{TK, TV, TMap, TVCol}"/> class
        /// which encapsulates data a map testing fixture would use.
        /// </summary>
        /// <param name="implementorCtor">The constructor of a
        /// collection type that implements <typeparamref name="TMap"/>
        /// and is initialized with data from <paramref name="initialKeys"/>
        /// and <paramref name="initialValues"/>.</param>
        /// <param name="valueCollectionCtor">Delegate pointing to a
        /// constructor of <see cref="TVCol"/> that takes
        /// <see cref="IEnumerable{T}"/> of type <see cref="TV"/> as
        /// parameter.</param>
        /// <param name="comparerCollection">The comparer used for determining
        /// equality between value collections. Leave null if not
        /// applicable.</param>
        /// <param name="data">The test data used for this fixture.</param>
        public MultiMapDataConcrete(
            Func <TMap> implementorCtor,
            Func <IEnumerable <TV>, TVCol> valueCollectionCtor,
            IEqualityComparer <TVCol> comparerCollection,
            MultiMapData <TK, TV> data) : base(data)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            ImplementorCtor = implementorCtor
                              ?? throw new ArgumentNullException(nameof(implementorCtor));

            ValueCollectionCtor = valueCollectionCtor
                                  ?? throw new ArgumentNullException(nameof(valueCollectionCtor));

            ValuesInitial      = ConstructVCols(data.ValuesInitial, valueCollectionCtor);
            ValuesToAdd        = ConstructVCols(data.ValuesToAdd, valueCollectionCtor);
            ValuesExcluded     = ConstructVCols(data.ValuesExcluded, valueCollectionCtor);
            KVPsInitial        = HelperMethods.ConstructKVPs(KeysInitial, ValuesInitial);
            KVPsToAdd          = HelperMethods.ConstructKVPs(KeysToAdd, ValuesToAdd);
            KVPsExcluded       = HelperMethods.ConstructKVPs(KeysExcluded, ValuesExcluded);
            valuesInitialFlat  = data.ValuesInitial.SelectMany(a => a).ToArray();
            valuesToAddFlat    = data.ValuesToAdd.SelectMany(a => a).ToArray();
            valuesExcludedFlat = data.ValuesExcluded.SelectMany(a => a).ToArray();

            this.comparerCollection = comparerCollection;
        }
Beispiel #2
0
        Construct(
            Func <MultiMapData <TK, TV>, TCollection> ctorImplementor,
            Func <IEnumerable <TV>, IEqualityComparer <TV>, TVCol> ctorValCol,
            Func <MultiMapData <TK, TV>, IEqualityComparer <TVCol> > comparerCollection,
            MultiMapData <TK, TV> data,
            string concreteTypeName,
            string fixtureName = "")
        {
            var args = new MultiMapDataConcrete <TK, TV, TCollection, TVCol>(
                () => ctorImplementor(data),
                (x) => ctorValCol(x, data.ComparerValue),
                comparerCollection != null ? comparerCollection(data) : null,
                data);

            var exposedParams = new ExposedTestFixtureParams()
            {
                TestName   = $"{fixtureName}({concreteTypeName}, {data.TestDataName})",
                Arguments  = new object[] { args },
                Properties = new PropertyBag(),
                RunState   = RunState.Runnable,
                TypeArgs   = new Type[]
                {
                    typeof(TK),
                    typeof(TV),
                    typeof(TCollection),
                    typeof(TVCol)
                }
            };

            return(new TestFixtureParameters(exposedParams));
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the
        /// <see cref="MultiMapData{TK, TV}"/> class by copying members from
        /// another <see cref="MultiMapData{TK, TV}"/> instance.
        /// </summary>
        /// <param name="data">Instance to copy from.</param>
        public MultiMapData(MultiMapData <TK, TV> data)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            TestDataName   = data.TestDataName;
            KeysInitial    = data.KeysInitial;
            KeysToAdd      = data.KeysToAdd;
            KeysExcluded   = data.KeysExcluded;
            ValuesInitial  = data.ValuesInitial;
            ValuesToAdd    = data.ValuesToAdd;
            ValuesExcluded = data.ValuesExcluded;
            ComparerKey    = data.ComparerKey ?? EqualityComparer <TK> .Default;
            ComparerValue  = data.ComparerValue ?? EqualityComparer <TV> .Default;
            KeyIsNullabe   = default(TK) == null;
        }