Permalink
Switch branches/tags
AllowBindingResultionBeCustomized AsyncSilverlight2 BeforeTestRunHookIssue CucumberHarmonization DotNetCore-CoreRuntime DotNetCore_Compiling DotNetCore_ExtractCommonMSBuildProperties DotNetCore_MigrateToXUnit DotNetCore_RemoveCodeGeneration DotNetCore_RemoveReports DotNetCore_RpcTests DotNetCore_Specs DotNetCore_TestProjectGenerationApi DotNetCore_TestProjects DotNetCore_UnitTestProviderConfiguration DotNetCore_UnitTests DotNetCore_UpdateNugetPackages DotNetCore Fix1305 Fix1328 FixMSBuildUpToDateCheck HookWithMultipleTagsExecutedMoreThanOnce HooksNotCalledIfScenarioFails Licenses MSBuild_NetSdkProjectTypeSupport MSBuild_NuspecVersioningImprovements MSBuildGeneration_IncrementalBuildAndCleanRebuildImprovements NewNupkgCreation Peter-B--CreateInstanceOverloadWithTableInCallback ReOrgTests RefactorDi ShareBindingLogic StepDefinitionSkeleton StepDefinitionsWithoutRegex VS2010Integration VS2010_RunTestsCommand VSBackNavigation assist_services_container_fix assist_with_less_static bring_back_the_datetime_retriever_that_got_lost_with_v2 check_body_v13 contributing datetimeoffset dry_up_tiny_code_duplication extendable_value_handlers_refactor2 extendable_value_handlers fix771 fixItemGroupSpecFlowPlusExcel future40ideas gh-pages gitextensions-configuration improve_bindingprocessor_errors injecttohooks integrate_gherkin3 issue_432_spike issue_696 line-v2.3 line-v2.4 master monodevelop-2.8 more_consistent_assist_signatures more_consistent_value_retriever_signature packageGeneration pr484-onv2 regexless_stepdef_fixes sequentialcomparetoset snake_case_properties step_transformation_value_retriever_spike step_transformation_value_retriever stepargumentransformation_support_in_table_helpers taggenerator test-pr test_build_config test_pull-request test_thread_context thread-safety timespan typo_fix v1-2-compatible-parser v2 versioning_on_ci vs_intellisense_bug2 vs2013sln xunit_console_output
Nothing to show
Find file Copy path
110 lines (98 sloc) 5.47 KB
using System;
using System.Collections.Generic;
using System.Globalization;
using BoDi;
using TechTalk.SpecFlow.BindingSkeletons;
using Utf8Json;
namespace TechTalk.SpecFlow.Configuration.JsonConfig
{
public class JsonConfigurationLoader
{
public SpecFlowConfiguration LoadJson(SpecFlowConfiguration specFlowConfiguration, string jsonContent)
{
if (String.IsNullOrWhiteSpace(jsonContent)) throw new ArgumentNullException(nameof(jsonContent));
var jsonConfig = JsonSerializer.Deserialize<JsonConfig>(jsonContent);
ContainerRegistrationCollection containerRegistrationCollection = specFlowConfiguration.CustomDependencies;
ContainerRegistrationCollection generatorContainerRegistrationCollection = specFlowConfiguration.GeneratorCustomDependencies;
CultureInfo featureLanguage = specFlowConfiguration.FeatureLanguage;
CultureInfo bindingCulture = specFlowConfiguration.BindingCulture;
bool stopAtFirstError = specFlowConfiguration.StopAtFirstError;
MissingOrPendingStepsOutcome missingOrPendingStepsOutcome = specFlowConfiguration.MissingOrPendingStepsOutcome;
bool traceSuccessfulSteps = specFlowConfiguration.TraceSuccessfulSteps;
bool traceTimings = specFlowConfiguration.TraceTimings;
TimeSpan minTracedDuration = specFlowConfiguration.MinTracedDuration;
StepDefinitionSkeletonStyle stepDefinitionSkeletonStyle = specFlowConfiguration.StepDefinitionSkeletonStyle;
List<string> additionalStepAssemblies = specFlowConfiguration.AdditionalStepAssemblies;
bool allowRowTests = specFlowConfiguration.AllowRowTests;
bool allowDebugGeneratedFiles = specFlowConfiguration.AllowDebugGeneratedFiles;
bool markFeaturesParallelizable = specFlowConfiguration.MarkFeaturesParallelizable;
string[] skipParallelizableMarkerForTags = specFlowConfiguration.SkipParallelizableMarkerForTags;
ObsoleteBehavior obsoleteBehavior = specFlowConfiguration.ObsoleteBehavior;
if (jsonConfig.Language != null)
{
if (jsonConfig.Language.Feature.IsNotNullOrWhiteSpace())
{
featureLanguage = CultureInfo.GetCultureInfo(jsonConfig.Language.Feature);
}
}
if (jsonConfig.BindingCulture != null)
{
if (jsonConfig.BindingCulture.Name.IsNotNullOrWhiteSpace())
{
bindingCulture = CultureInfo.GetCultureInfo(jsonConfig.BindingCulture.Name);
}
}
if (jsonConfig.Runtime != null)
{
missingOrPendingStepsOutcome = jsonConfig.Runtime.MissingOrPendingStepsOutcome;
stopAtFirstError = jsonConfig.Runtime.StopAtFirstError;
obsoleteBehavior = jsonConfig.Runtime.ObsoleteBehavior;
if (jsonConfig.Runtime.Dependencies != null)
{
foreach (var runtimeDependency in jsonConfig.Runtime.Dependencies)
{
containerRegistrationCollection.Add(runtimeDependency.ImplementationType, runtimeDependency.InterfaceType);
}
}
}
if (jsonConfig.Generator != null)
{
allowDebugGeneratedFiles = jsonConfig.Generator.AllowDebugGeneratedFiles;
allowRowTests = jsonConfig.Generator.AllowRowTests;
markFeaturesParallelizable = jsonConfig.Generator.MarkFeaturesParallelizable;
skipParallelizableMarkerForTags = jsonConfig.Generator.SkipParallelizableMarkerForTags?.ToArray();
}
if (jsonConfig.Trace != null)
{
traceSuccessfulSteps = jsonConfig.Trace.TraceSuccessfulSteps;
traceTimings = jsonConfig.Trace.TraceTimings;
minTracedDuration = jsonConfig.Trace.MinTracedDuration;
stepDefinitionSkeletonStyle = jsonConfig.Trace.StepDefinitionSkeletonStyle;
}
if (jsonConfig.StepAssemblies != null)
{
foreach (var stepAssemblyEntry in jsonConfig.StepAssemblies)
{
additionalStepAssemblies.Add(stepAssemblyEntry.Assembly);
}
}
return new SpecFlowConfiguration(ConfigSource.Json,
containerRegistrationCollection,
generatorContainerRegistrationCollection,
featureLanguage,
bindingCulture,
stopAtFirstError,
missingOrPendingStepsOutcome,
traceSuccessfulSteps,
traceTimings,
minTracedDuration,
stepDefinitionSkeletonStyle,
additionalStepAssemblies,
allowDebugGeneratedFiles,
allowRowTests,
markFeaturesParallelizable,
skipParallelizableMarkerForTags,
obsoleteBehavior);
}
}
}