/// <summary> /// Runs combinations using specified engine provider. /// </summary> /// <typeparam name="T">Type of an item in the dimension.</typeparam> /// <param name="provider">The combinatorial engine provider to use.</param> /// <param name="dimension">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 <T>( this ICombinatorialEngineProvider provider, IEnumerable <T> dimension, Action <T> action, int?skipTo = null) { provider.RunCombinations(action, skipTo, dimension); }
/// <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> /// <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="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>( this ICombinatorialEngineProvider provider, IEnumerable <T1> dimension1, IEnumerable <T2> dimension2, IEnumerable <T3> dimension3, Action <T1, T2, T3> action, int?skipTo = null) { provider.RunCombinations(action, skipTo, dimension1, dimension2, dimension3); }
/// <summary> /// Runs combinations using specified engine provider. /// </summary> /// <param name="provider">The engine provider to use to create the combinatorial engine.</param> /// <param name="action">The action to run for each combination.</param> /// <param name="skipTo">If specified determines which combination to skip to. Must be null when running outside the debugger.</param> /// <param name="dimensions">Array of enumerations which represent the dimensions, these are matched by order to the parameters of the action.</param> public static void RunCombinations(this ICombinatorialEngineProvider provider, Delegate action, int?skipTo, params IEnumerable[] dimensions) { ParameterInfo[] parameters = action.Method.GetParameters(); CombinatorialDimension[] dimensionInstances = dimensions.Select((dimensionEnumerable, dimensionIndex) => new CombinatorialDimension(parameters[dimensionIndex].Name, dimensionEnumerable)).ToArray(); ICombinatorialEngine engine = provider.CreateEngine(dimensionInstances); engine.RunCombinations((dimensionValues) => { action.DynamicInvoke(parameters.Select(parameter => dimensionValues[parameter.Name]).ToArray()); }, skipTo); }
/// <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, (config) => { ODataMessageWriterSettings settings = config.MessageWriterSettings.Clone(); 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 }; foreach (var config in configurationsWithDefaultSettings) { ODataMessageWriterSettings settings = config.MessageWriterSettings.Clone(); 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); }
public void Init() { CombinatorialEngineProvider = new FullCombinatorialEngineProvider(); }
/// <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; }