Skip to content

Commit

Permalink
Fix issue with settings being null
Browse files Browse the repository at this point in the history
  • Loading branch information
Cédric L. Charlier committed Nov 20, 2019
1 parent 978013c commit 3a6a15f
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions NBi.NUnit/Builder/Helper/QueryResolverArgsBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class QueryResolverArgsBuilder
private readonly ServiceLocator serviceLocator;

private object obj = null;
private SettingsXml settingsXml = null;
private SettingsXml.DefaultScope scope = SettingsXml.DefaultScope.Everywhere;
private IDictionary<string, ITestVariable> Variables { get; set; } = null;
protected SettingsXml Settings { get; private set; } = SettingsXml.Empty;
protected SettingsXml.DefaultScope Scope { get; private set; } = SettingsXml.DefaultScope.Everywhere;
protected IDictionary<string, ITestVariable> Variables { get; private set; } = new Dictionary<string, ITestVariable>();
private BaseQueryResolverArgs args = null;

public QueryResolverArgsBuilder(ServiceLocator serviceLocator)
Expand All @@ -36,19 +36,19 @@ public QueryResolverArgsBuilder(ServiceLocator serviceLocator)

public void Setup(QueryXml queryXml, SettingsXml settingsXml, SettingsXml.DefaultScope scope, IDictionary<string, ITestVariable> variables)
{
this.obj = queryXml;
this.settingsXml = settingsXml;
this.scope = scope;
obj = queryXml;
Settings = settingsXml ?? SettingsXml.Empty;
Scope = scope;
Variables = variables;
isSetup = true;
}

public void Setup(ExecutableXml executableXml, SettingsXml settingsXml, IDictionary<string, ITestVariable> variables)
{
this.obj = executableXml;
this.settingsXml = settingsXml;
this.scope = SettingsXml.DefaultScope.SystemUnderTest;
this.Variables = variables;
obj = executableXml;
Settings = settingsXml ?? SettingsXml.Empty;
Scope = SettingsXml.DefaultScope.SystemUnderTest;
Variables = variables;
isSetup = true;
}

Expand All @@ -66,8 +66,8 @@ public void Build()

protected void Build(QueryXml queryXml)
{
queryXml.Settings = settingsXml;
var connectionString = new ConnectionStringHelper().Execute(queryXml, scope);
queryXml.Settings = Settings;
var connectionString = new ConnectionStringHelper().Execute(queryXml, Scope);
var parameters = BuildParameters(queryXml.GetParameters());
var templateVariables = queryXml.GetTemplateVariables();
var timeout = Convert.ToInt32(Math.Ceiling(queryXml.Timeout / 1000m)); //Timeout is expressed in milliseconds
Expand All @@ -78,7 +78,7 @@ protected void Build(QueryXml queryXml)

else if (!string.IsNullOrEmpty(queryXml.File))
{
var file = GetFullPath(settingsXml?.BasePath, queryXml.File);
var file = GetFullPath(Settings?.BasePath, queryXml.File);

args = new ExternalFileQueryResolverArgs(file
, connectionString, parameters, templateVariables, new TimeSpan(0, 0, timeout));
Expand Down Expand Up @@ -111,7 +111,7 @@ private BaseQueryResolverArgs Build(AssemblyXml xml, string connectionString, IE

private BaseQueryResolverArgs Build(ReportXml xml, string connectionString, IEnumerable<IQueryParameter> parameters, IEnumerable<IQueryTemplateVariable> templateVariables, TimeSpan timeout)
{
var path = string.IsNullOrEmpty(xml.Source) ? settingsXml.BasePath + xml.Path : xml.Path;
var path = string.IsNullOrEmpty(xml.Source) ? Settings.BasePath + xml.Path : xml.Path;

return new ReportDataSetQueryResolverArgs(
xml.Source, path, xml.Name, xml.Dataset
Expand All @@ -120,7 +120,7 @@ private BaseQueryResolverArgs Build(ReportXml xml, string connectionString, IEnu

private BaseQueryResolverArgs Build(SharedDatasetXml xml, string connectionString, IEnumerable<IQueryParameter> parameters, IEnumerable<IQueryTemplateVariable> templateVariables, TimeSpan timeout)
{
var path = string.IsNullOrEmpty(xml.Source) ? settingsXml.BasePath + xml.Path : xml.Path;
var path = string.IsNullOrEmpty(xml.Source) ? Settings.BasePath + xml.Path : xml.Path;

return new SharedDataSetQueryResolverArgs(
xml.Source, path, xml.Name
Expand All @@ -133,7 +133,7 @@ protected void Build(ExecutableXml executableXml)
Build(executableXml as QueryXml);
else
{
var connectionString = new ConnectionStringHelper().Execute(executableXml, scope);
var connectionString = new ConnectionStringHelper().Execute(executableXml, Scope);

var queryableXml = executableXml as QueryableXml;
var parameters = BuildParameters(queryableXml.GetParameters());
Expand Down

0 comments on commit 3a6a15f

Please sign in to comment.