/// <summary>
 /// Runs combinations using specified engine provider.
 /// </summary>
 /// <typeparam name="T1">Type of an item in the dimension.</typeparam>
 /// <typeparam name="T2">Type of an item in the dimension.</typeparam>
 /// <param name="provider">The combinatorial engine provider to use.</param>
 /// <param name="dimension1">Dimension to get combinations for.</param>
 /// <param name="dimension2">Dimension to get combinations for.</param>
 /// <param name="action">The action to run for all combinations.</param>
 /// <param name="skipTo">If specified determines which combination to skip to. Must be null when running outside the debugger.</param>
 public static void RunCombinations <T1, T2>(
     this ICombinatorialEngineProvider provider,
     IEnumerable <T1> dimension1,
     IEnumerable <T2> dimension2,
     Action <T1, T2> action,
     int?skipTo = null)
 {
     provider.RunCombinations(action, skipTo, dimension1, dimension2);
 }
Пример #2
0
 /// <summary>
 /// Runs combinations using specified engine provider.
 /// </summary>
 /// <typeparam name="T1">Type of an item in the dimension.</typeparam>
 /// <typeparam name="T2">Type of an item in the dimension.</typeparam>
 /// <typeparam name="T3">Type of an item in the dimension.</typeparam>
 /// <typeparam name="T4">Type of an item in the dimension.</typeparam>
 /// <typeparam name="T5">Type of an item in the dimension.</typeparam>
 /// <param name="provider">The combinatorial engine provider to use.</param>
 /// <param name="dimension1">Dimension to get combinations for.</param>
 /// <param name="dimension2">Dimension to get combinations for.</param>
 /// <param name="dimension3">Dimension to get combinations for.</param>
 /// <param name="dimension4">Dimension to get combinations for.</param>
 /// <param name="dimension5">Dimension to get combinations for.</param>
 /// <param name="action">The action to run for all combinations.</param>
 /// <param name="skipTo">If specified determines which combination to skip to. Must be null when running outside the debugger.</param>
 public static void RunCombinations <T1, T2, T3, T4, T5>(
     this ICombinatorialEngineProvider provider,
     IEnumerable <T1> dimension1,
     IEnumerable <T2> dimension2,
     IEnumerable <T3> dimension3,
     IEnumerable <T4> dimension4,
     IEnumerable <T5> dimension5,
     Action <T1, T2, T3, T4, T5> action,
     int?skipTo = null)
 {
     provider.RunCombinations(action, skipTo, dimension1, dimension2, dimension3, dimension4, dimension5);
 }
Пример #3
0
        /// <summary>
        /// Creates the configurations for the specified format with indenting.
        /// </summary>
        /// <param name="combinatorialEngine">The combinatorial engine.</param>
        /// <param name="format">The <see cref="ODataFormat"/> to create test configurations for.</param>
        /// <param name="configurationsWithDefaultSettings">The list of test configurations with default settings (no indenting).</param>
        /// <returns>The list of generated test configurations.</returns>
        private static List <WriterTestConfiguration> CreateConfigurationsWithIndent(TestRunKind runKind, ICombinatorialEngineProvider combinatorialEngine, ODataFormat format, IEnumerable <WriterTestConfiguration> configurationsWithDefaultSettings)
        {
            List <WriterTestConfiguration> configurations = new List <WriterTestConfiguration>();

            if (runKind == TestRunKind.All)
            {
                combinatorialEngine.RunCombinations(
                    configurationsWithDefaultSettings,
                    new bool[] { true, false }, // indent
                    (config, indent) =>
                {
                    ODataMessageWriterSettings settings = config.MessageWriterSettings.Clone();
                    settings.Indent = indent;
                    configurations.Add(new WriterTestConfiguration(config.Format,
                                                                   settings,
                                                                   config.IsRequest,
                                                                   config.Synchronous));
                });
            }
            else
            {
                // We need only some to use indentation but we want for each of ATOM and JSON to to have some which use it for sure
                int[] primes = new int[] { 1, 2, 3, 5, 7, 11, 13, 17, 19 };
                int   i      = 0;
                foreach (var config in configurationsWithDefaultSettings)
                {
                    ODataMessageWriterSettings settings = config.MessageWriterSettings.Clone();
                    settings.Indent = primes.Contains(i++);
                    configurations.Add(new WriterTestConfiguration(config.Format,
                                                                   settings,
                                                                   config.IsRequest,
                                                                   config.Synchronous));
                }
            }

            return(configurations);
        }
        /// <summary>
        /// Creates the configurations for the specified format using the default settings.
        /// </summary>
        /// <param name="runKind">The kind of test run for which to create the configurations.</param>
        /// <param name="combinatorialEngine">The combinatorial engine.</param>
        /// <param name="format">The <see cref="ODataFormat"/> to create test configurations for.</param>
        /// <returns>The list of generated test configurations.</returns>
        private static List <WriterTestConfiguration> CreateConfigurationsWithDefaultSettings(TestRunKind runKind, ICombinatorialEngineProvider combinatorialEngine, ODataFormat format)
        {
            List <WriterTestConfiguration> configurations = new List <WriterTestConfiguration>();

            if (runKind == TestRunKind.All)
            {
                combinatorialEngine.RunCombinations(
                    ODataVersionUtils.AllSupportedVersions,
                    new bool[] { true, false },  // disableMessageStreamDisposal
                    new bool[] { true, false },  // isRequest
                    new bool[] { true, false },  // synchronous
                    (version, enableMessageStreamDisposal, isRequest, synchronous) =>
                {
#if SILVERLIGHT || WINDOWS_PHONE
                    // If we are running in Silverlight or windows phone, we don't want to generate asynchronous variations
                    // hence we will skip generation of asynchronous test combinations
                    if (!synchronous)
                    {
                        return;
                    }
#endif

                    configurations.Add(new WriterTestConfiguration(
                                           format,
                                           GetDefaultMessageWriterSettings(format, null, enableMessageStreamDisposal, version),
                                           isRequest,
                                           synchronous));
                });
            }
            else
            {
                IEnumerable <LimitedCombinationSpecification> limitedCombinations;
                limitedCombinations = new[]
                {
                    new LimitedCombinationSpecification {
                        EnableMessageStreamDisposal = true,
                        Synchronous = true,
                    },
                    new LimitedCombinationSpecification {
                        EnableMessageStreamDisposal = false,
                        Synchronous = false,
                    },
                };

                if (format == ODataFormat.Json)
                {
                    limitedCombinations
                    .ConcatSingle(new LimitedCombinationSpecification
                    {
                        EnableMessageStreamDisposal = false,
                        Synchronous = true
                    });
                }

                combinatorialEngine.RunCombinations(
                    limitedCombinations,
                    new bool[] { true, false },  // isRequest
                    (limitedCombination, isRequest) =>
                {
#if SILVERLIGHT || WINDOWS_PHONE
                    // If we are running in Silverlight or windows phone, we don't want to generate asynchronous variations
                    // hence we will skip generation of asynchronous test combinations
                    if (!limitedCombination.Synchronous)
                    {
                        return;
                    }
#endif
                    configurations.Add(new WriterTestConfiguration(
                                           format,
                                           GetDefaultMessageWriterSettings(
                                               format,
                                               null,
                                               limitedCombination.EnableMessageStreamDisposal),
                                           isRequest,
                                           limitedCombination.Synchronous));
                });
            }

            return(configurations);
        }
        /// <summary>
        /// Creates the configurations for the specified format using the default settings.
        /// </summary>
        /// <param name="runKind">The kind of test run for which to create the configurations.</param>
        /// <param name="combinatorialEngine">The combinatorial engine.</param>
        /// <param name="format">The <see cref="ODataFormat"/> to create test configurations for.</param>
        /// <returns>The list of generated test configurations.</returns>
        private static List <ReaderTestConfiguration> CreateConfigurations(TestRunKind runKind, ICombinatorialEngineProvider combinatorialEngine, ODataFormat format)
        {
            List <ReaderTestConfiguration> configurations = new List <ReaderTestConfiguration>();

            if (runKind == TestRunKind.All)
            {
                combinatorialEngine.RunCombinations(
                    ODataVersionUtils.AllSupportedVersions,
                    new bool[] { true, false },  // enableMessageStreamDisposal
                    new bool[] { true, false },  // isRequest
                    new bool[] { true, false },  // synchronous
                    new bool[] { true, false },  // skipStateValidationBeforeRead
                    (version, enableMessageStreamDisposal, isRequest, synchronous, skipStateValidationBeforeRead) =>
                {
                    var settings = new ODataMessageReaderSettings
                    {
                        EnableMessageStreamDisposal = enableMessageStreamDisposal
                    };
                    configurations.Add(new ReaderTestConfiguration(
                                           format,
                                           settings,
                                           isRequest,
                                           synchronous,
                                           skipStateValidationBeforeRead: skipStateValidationBeforeRead));
                });
            }
            else
            {
                var limitedCombinations = new[]
                {
                    new {
                        EnableMessageStreamDisposal = true,
                        Synchronous = true,
                    },
                    new {
                        EnableMessageStreamDisposal = false,
                        Synchronous = false,
                    },
                };

                combinatorialEngine.RunCombinations(
                    limitedCombinations,
                    new bool[] { true, false }, // isRequest
                    new bool[] { true, false }, // skipStateValidationBeforeRead
                    (limitedCombination, isRequest, skipStateValidationBeforeRead) =>
                {
                    var settings = new ODataMessageReaderSettings
                    {
                        EnableMessageStreamDisposal = limitedCombination.EnableMessageStreamDisposal
                    };
                    configurations.Add(new ReaderTestConfiguration(
                                           format,
                                           settings,
                                           isRequest,
                                           limitedCombination.Synchronous,
                                           skipStateValidationBeforeRead: skipStateValidationBeforeRead));
                });
            }

            return(configurations);
        }
        /// <summary>
        /// Creates the configurations for the specified format with indenting.
        /// </summary>
        /// <param name="combinatorialEngine">The combinatorial engine.</param>
        /// <param name="format">The <see cref="ODataFormat"/> to create test configurations for.</param>
        /// <param name="configurationsWithDefaultSettings">The list of test configurations with default settings (no indenting).</param>
        /// <returns>The list of generated test configurations.</returns>
        private static List<WriterTestConfiguration> CreateConfigurationsWithIndent(TestRunKind runKind, ICombinatorialEngineProvider combinatorialEngine, ODataFormat format, IEnumerable<WriterTestConfiguration> configurationsWithDefaultSettings)
        {
            List<WriterTestConfiguration> configurations = new List<WriterTestConfiguration>();

            if (runKind == TestRunKind.All)
            {
                combinatorialEngine.RunCombinations(
                    configurationsWithDefaultSettings,
                    new bool[] { true, false }, // indent
                    (config, indent) =>
                    {
                        ODataMessageWriterSettings settings = config.MessageWriterSettings.Clone();
                        settings.Indent = indent;
                        configurations.Add(new WriterTestConfiguration(config.Format,
                            settings,
                            config.IsRequest,
                            config.Synchronous));
                    });
            }
            else
            {
                // We need only some to use indentation but we want for each of ATOM and JSON to to have some which use it for sure
                int[] primes = new int[] { 1, 2, 3, 5, 7, 11, 13, 17, 19 };
                int i = 0;
                foreach (var config in configurationsWithDefaultSettings)
                {
                    ODataMessageWriterSettings settings = config.MessageWriterSettings.Clone();
                    settings.Indent = primes.Contains(i++);
                    configurations.Add(new WriterTestConfiguration(config.Format,
                        settings,
                        config.IsRequest,
                        config.Synchronous));
                }
            }

            return configurations;
        }
        /// <summary>
        /// Creates the configurations for the specified format using the default settings.
        /// </summary>
        /// <param name="runKind">The kind of test run for which to create the configurations.</param>
        /// <param name="combinatorialEngine">The combinatorial engine.</param>
        /// <param name="format">The <see cref="ODataFormat"/> to create test configurations for.</param>
        /// <returns>The list of generated test configurations.</returns>
        private static List<WriterTestConfiguration> CreateConfigurationsWithDefaultSettings(TestRunKind runKind, ICombinatorialEngineProvider combinatorialEngine, ODataFormat format)
        {
            List<WriterTestConfiguration> configurations = new List<WriterTestConfiguration>();

            if (runKind == TestRunKind.All)
            {
                combinatorialEngine.RunCombinations(
                    ODataVersionUtils.AllSupportedVersions,
                    new bool[] { true, false },  // disableMessageStreamDisposal
                    new bool[] { true, false },  // isRequest
                    new bool[] { true, false },  // synchronous
                    (version, disableMessageStreamDisposal, isRequest, synchronous) =>
                    {
#if SILVERLIGHT || WINDOWS_PHONE
                        // If we are running in Silverlight or windows phone, we don't want to generate asynchronous variations
                        // hence we will skip generation of asynchronous test combinations
                        if (!synchronous)
                        {
                            return;
                        }
#endif

                        configurations.Add(new WriterTestConfiguration(
                            format,
                            GetDefaultMessageWriterSettings(format, null, disableMessageStreamDisposal, version),
                            isRequest,
                            synchronous));
                    });
            }
            else
            {
                IEnumerable<LimitedCombinationSpecification> limitedCombinations;
                limitedCombinations = new[]
                {
                    new LimitedCombinationSpecification {
                        DisableMessageStreamDisposal = false,
                        Synchronous = true,
                    },
                    new LimitedCombinationSpecification {
                        DisableMessageStreamDisposal = true,
                        Synchronous = false,
                    },
                };

                if (format == ODataFormat.Json)
                {
                    limitedCombinations
                        .ConcatSingle(new LimitedCombinationSpecification
                        {
                            DisableMessageStreamDisposal = true,
                            Synchronous = true
                        });
                }

                combinatorialEngine.RunCombinations(
                    limitedCombinations,
                    new bool[] { true, false },  // isRequest
                    (limitedCombination, isRequest) =>
                    {
#if SILVERLIGHT || WINDOWS_PHONE
                        // If we are running in Silverlight or windows phone, we don't want to generate asynchronous variations
                        // hence we will skip generation of asynchronous test combinations
                        if (!limitedCombination.Synchronous)
                        {
                            return;
                        }
#endif
                        configurations.Add(new WriterTestConfiguration(
                            format,
                            GetDefaultMessageWriterSettings(
                                format,
                                null,
                                limitedCombination.DisableMessageStreamDisposal),
                            isRequest,
                            limitedCombination.Synchronous));
                    });
            }

            return configurations;
        }
        /// <summary>
        /// Creates the configurations for the specified format using the default settings.
        /// </summary>
        /// <param name="runKind">The kind of test run for which to create the configurations.</param>
        /// <param name="combinatorialEngine">The combinatorial engine.</param>
        /// <param name="format">The <see cref="ODataFormat"/> to create test configurations for.</param>
        /// <returns>The list of generated test configurations.</returns>
        private static List <ReaderTestConfiguration> CreateConfigurations(TestRunKind runKind, ICombinatorialEngineProvider combinatorialEngine, ODataFormat format)
        {
            List <ReaderTestConfiguration> configurations = new List <ReaderTestConfiguration>();

            if (runKind == TestRunKind.All)
            {
                combinatorialEngine.RunCombinations(
                    ODataVersionUtils.AllSupportedVersions,
                    new bool[] { true, false },  // enableMessageStreamDisposal
                    new bool[] { true, false },  // isRequest
                    new bool[] { true, false },  // synchronous
                    new bool[] { true, false },  // skipStateValidationBeforeRead
                    (version, enableMessageStreamDisposal, isRequest, synchronous, skipStateValidationBeforeRead) =>
                {
#if SILVERLIGHT || WINDOWS_PHONE
                    // If we are running in Silverlight or windows phone, we don't want to generate asynchronous variations
                    // hence we will skip generation of asynchronous test combinations
                    if (!synchronous)
                    {
                        return;
                    }
#endif
                    var settings = new ODataMessageReaderSettings
                    {
                        EnableMessageStreamDisposal = enableMessageStreamDisposal
                    };
                    configurations.Add(new ReaderTestConfiguration(
                                           format,
                                           settings,
                                           isRequest,
                                           synchronous,
                                           skipStateValidationBeforeRead: skipStateValidationBeforeRead));
                });
            }
            else
            {
                var limitedCombinations = new[]
                {
                    new {
                        EnableMessageStreamDisposal = true,
                        Synchronous = true,
                    },
                    new {
                        EnableMessageStreamDisposal = false,
                        Synchronous = false,
                    },
                };

                combinatorialEngine.RunCombinations(
                    limitedCombinations,
                    new bool[] { true, false }, // isRequest
                    new bool[] { true, false }, // skipStateValidationBeforeRead
                    (limitedCombination, isRequest, skipStateValidationBeforeRead) =>
                {
#if SILVERLIGHT || WINDOWS_PHONE
                    // If we are running in Silverlight or windows phone, we don't want to generate asynchronous variations
                    // hence we will skip generation of asynchronous test combinations
                    if (!limitedCombination.Synchronous)
                    {
                        return;
                    }
#endif
                    var settings = new ODataMessageReaderSettings
                    {
                        EnableMessageStreamDisposal = limitedCombination.EnableMessageStreamDisposal
                    };
                    configurations.Add(new ReaderTestConfiguration(
                                           format,
                                           settings,
                                           isRequest,
                                           limitedCombination.Synchronous,
                                           skipStateValidationBeforeRead: skipStateValidationBeforeRead));
                });
            }

            return(configurations);
        }
Пример #9
0
        /// <summary>
        /// Creates the configurations for the specified format using the default settings.
        /// </summary>
        /// <param name="runKind">The kind of test run for which to create the configurations.</param>
        /// <param name="combinatorialEngine">The combinatorial engine.</param>
        /// <param name="format">The <see cref="ODataFormat"/> to create test configurations for.</param>
        /// <returns>The list of generated test configurations.</returns>
        private static List <WriterTestConfiguration> CreateConfigurationsWithDefaultSettings(TestRunKind runKind, ICombinatorialEngineProvider combinatorialEngine, ODataFormat format)
        {
            List <WriterTestConfiguration> configurations = new List <WriterTestConfiguration>();

            if (runKind == TestRunKind.All)
            {
                combinatorialEngine.RunCombinations(
                    ODataVersionUtils.AllSupportedVersions,
                    new bool[] { true, false },  // disableMessageStreamDisposal
                    new bool[] { true, false },  // isRequest
                    new bool[] { true, false },  // synchronous
                    (version, enableMessageStreamDisposal, isRequest, synchronous) =>
                {
                    configurations.Add(new WriterTestConfiguration(
                                           format,
                                           GetDefaultMessageWriterSettings(format, null, enableMessageStreamDisposal, version),
                                           isRequest,
                                           synchronous));
                });
            }
            else
            {
                IEnumerable <LimitedCombinationSpecification> limitedCombinations;
                limitedCombinations = new[]
                {
                    new LimitedCombinationSpecification {
                        EnableMessageStreamDisposal = true,
                        Synchronous = true,
                    },
                    new LimitedCombinationSpecification {
                        EnableMessageStreamDisposal = false,
                        Synchronous = false,
                    },
                };

                if (format == ODataFormat.Json)
                {
                    limitedCombinations
                    .ConcatSingle(new LimitedCombinationSpecification
                    {
                        EnableMessageStreamDisposal = false,
                        Synchronous = true
                    });
                }

                combinatorialEngine.RunCombinations(
                    limitedCombinations,
                    new bool[] { true, false },  // isRequest
                    (limitedCombination, isRequest) =>
                {
                    configurations.Add(new WriterTestConfiguration(
                                           format,
                                           GetDefaultMessageWriterSettings(
                                               format,
                                               null,
                                               limitedCombination.EnableMessageStreamDisposal),
                                           isRequest,
                                           limitedCombination.Synchronous));
                });
            }

            return(configurations);
        }
        /// <summary>
        /// Creates the configurations for the specified format using the default settings.
        /// </summary>
        /// <param name="runKind">The kind of test run for which to create the configurations.</param>
        /// <param name="combinatorialEngine">The combinatorial engine.</param>
        /// <param name="format">The <see cref="ODataFormat"/> to create test configurations for.</param>
        /// <returns>The list of generated test configurations.</returns>
        private static List<ReaderTestConfiguration> CreateConfigurations(TestRunKind runKind, ICombinatorialEngineProvider combinatorialEngine, ODataFormat format)
        {
            List<ReaderTestConfiguration> configurations = new List<ReaderTestConfiguration>();

            if (runKind == TestRunKind.All)
            {
                combinatorialEngine.RunCombinations(
                    ODataVersionUtils.AllSupportedVersions,
                    new bool[] { true, false },  // disableMessageStreamDisposal
                    new bool[] { true, false },  // isRequest
                    new bool[] { true, false },  // synchronous
                    (version, disableMessageStreamDisposal, isRequest, synchronous) =>
                    {

#if SILVERLIGHT || WINDOWS_PHONE
                        // If we are running in Silverlight or windows phone, we don't want to generate asynchronous variations
                        // hence we will skip generation of asynchronous test combinations
                        if (!synchronous)
                        {
                            return;
                        }
#endif
                        configurations.Add(new ReaderTestConfiguration(
                            format,
                            new ODataMessageReaderSettings() 
                            { 
                                DisableMessageStreamDisposal = disableMessageStreamDisposal,
                                EnableAtom = true
                            },
                            isRequest,
                            synchronous));
                    });
            }
            else
            {
                var limitedCombinations = new[]
                {
                    new {
                        DisableMessageStreamDisposal = false,
                        Synchronous = true,
                    },
                    new {
                        DisableMessageStreamDisposal = true,
                        Synchronous = false,
                    },
                };

                combinatorialEngine.RunCombinations(
                    limitedCombinations,
                    new bool[] { true, false }, // isRequest
                    (limitedCombination, isRequest) =>
                    {

#if SILVERLIGHT || WINDOWS_PHONE
                        // If we are running in Silverlight or windows phone, we don't want to generate asynchronous variations
                        // hence we will skip generation of asynchronous test combinations
                        if (!limitedCombination.Synchronous)
                        {
                            return;
                        }
#endif
                        configurations.Add(new ReaderTestConfiguration(
                            format,
                            new ODataMessageReaderSettings() 
                            { 
                                DisableMessageStreamDisposal = limitedCombination.DisableMessageStreamDisposal,
                                EnableAtom = true
                            },
                            isRequest,
                            limitedCombination.Synchronous));
                    });
            }

            return configurations;
        }