/// <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 test configurations with and without indenting based on a set of default configurations. /// </summary> /// <param name="runKind">The run kind to create the configurations for.</param> /// <param name="defaultConfigurations">The set of default configurations.</param> /// <returns>The created test configurations.</returns> private static CachedConfigurations CreateConfigurationsWithIndent(TestRunKind runKind, CachedConfigurations defaultConfigurations) { ICombinatorialEngineProvider combinatorialEngine = new FullCombinatorialEngineProvider(); return(new CachedConfigurations { // AtomConfigurations = CreateConfigurationsWithIndent(runKind, combinatorialEngine, ODataFormat.Atom, defaultConfigurations.AtomConfigurations), JsonLightConfigurations = CreateConfigurationsWithIndent(runKind, combinatorialEngine, ODataFormat.Json, defaultConfigurations.JsonLightConfigurations), DefaultFormatConfigurations = CreateConfigurationsWithIndent(runKind, combinatorialEngine, /*format*/ null, defaultConfigurations.DefaultFormatConfigurations), }); }
/// <summary> /// Creates the configurations for a particular test run kind. /// </summary> /// <param name="runKind">The run kind to create the configurations for.</param> /// <returns>The created test configurations.</returns> private static RunKindTestConfigurations CreateConfigurations(TestRunKind runKind) { CachedConfigurations defaultConfigurations = CreateDefaultConfigurations(runKind); CachedConfigurations configurationsWithIndent = CreateConfigurationsWithIndent(runKind, defaultConfigurations); return(new RunKindTestConfigurations { DefaultConfigurations = defaultConfigurations, ConfigurationsWithIndent = configurationsWithIndent, }); }
/// <summary> /// Creates the default test configurations for the specified run kind. /// </summary> /// <param name="runKind">The run kind to create the default configurations for.</param> /// <returns>The created test configurations.</returns> private static CachedConfigurations CreateDefaultConfigurations(TestRunKind runKind) { ICombinatorialEngineProvider combinatorialEngine = new FullCombinatorialEngineProvider(); return(new CachedConfigurations { //AtomConfigurations = CreateConfigurationsWithDefaultSettings(runKind, combinatorialEngine, ODataFormat.Atom), JsonLightConfigurations = CreateConfigurationsWithDefaultSettings(runKind, combinatorialEngine, ODataFormat.Json), DefaultFormatConfigurations = CreateConfigurationsWithDefaultSettings(runKind, combinatorialEngine, /*format*/ null), }); }
/// <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 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 <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 test configurations with and without indenting based on a set of default configurations. /// </summary> /// <param name="runKind">The run kind to create the configurations for.</param> /// <param name="defaultConfigurations">The set of default configurations.</param> /// <returns>The created test configurations.</returns> private static CachedConfigurations CreateConfigurationsWithIndent(TestRunKind runKind, CachedConfigurations defaultConfigurations) { ICombinatorialEngineProvider combinatorialEngine = new FullCombinatorialEngineProvider(); return new CachedConfigurations { AtomConfigurations = CreateConfigurationsWithIndent(runKind, combinatorialEngine, ODataFormat.Atom, defaultConfigurations.AtomConfigurations), JsonLightConfigurations = CreateConfigurationsWithIndent(runKind, combinatorialEngine, ODataFormat.Json, defaultConfigurations.JsonLightConfigurations), DefaultFormatConfigurations = CreateConfigurationsWithIndent(runKind, combinatorialEngine, /*format*/ null, defaultConfigurations.DefaultFormatConfigurations), }; }
/// <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 default test configurations for the specified run kind. /// </summary> /// <param name="runKind">The run kind to create the default configurations for.</param> /// <returns>The created test configurations.</returns> private static CachedConfigurations CreateDefaultConfigurations(TestRunKind runKind) { ICombinatorialEngineProvider combinatorialEngine = new FullCombinatorialEngineProvider(); return new CachedConfigurations { AtomConfigurations = CreateConfigurationsWithDefaultSettings(runKind, combinatorialEngine, ODataFormat.Atom), JsonLightConfigurations = CreateConfigurationsWithDefaultSettings(runKind, combinatorialEngine, ODataFormat.Json), DefaultFormatConfigurations = CreateConfigurationsWithDefaultSettings(runKind, combinatorialEngine, /*format*/ null), }; }
/// <summary> /// Creates the configurations for a particular test run kind. /// </summary> /// <param name="runKind">The run kind to create the configurations for.</param> /// <returns>The created test configurations.</returns> private static RunKindTestConfigurations CreateConfigurations(TestRunKind runKind) { CachedConfigurations defaultConfigurations = CreateDefaultConfigurations(runKind); CachedConfigurations configurationsWithIndent = CreateConfigurationsWithIndent(runKind, defaultConfigurations); return new RunKindTestConfigurations { DefaultConfigurations = defaultConfigurations, ConfigurationsWithIndent = configurationsWithIndent, }; }
/// <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); }
/// <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; }