Skip to content

Commit

Permalink
Merge branch 'hotfix/connection-string_not_inherited_for_row-count_(#560
Browse files Browse the repository at this point in the history
)'
  • Loading branch information
Cédric L. Charlier committed Nov 20, 2019
2 parents 9d058c6 + 3a6a15f commit 33f2661
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 113 deletions.
31 changes: 16 additions & 15 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,7 +66,8 @@ public void Build()

protected void Build(QueryXml queryXml)
{
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 @@ -77,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 @@ -110,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 @@ -119,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 @@ -132,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
9 changes: 4 additions & 5 deletions NBi.NUnit/Builder/ResultSetRowCountBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using NBi.Core.Scalar;
using NBi.Core.Calculation.Predicate;
using NBi.Core.Variable;
using NBi.Xml.Settings;

namespace NBi.NUnit.Builder
{
Expand All @@ -22,9 +23,7 @@ class ResultSetRowCountBuilder : AbstractResultSetBuilder
protected RowCountXml ConstraintXml { get; set; }

public ResultSetRowCountBuilder()
{

}
{ }

protected override void SpecificSetup(AbstractSystemUnderTestXml sutXml, AbstractConstraintXml ctrXml)
{
Expand Down Expand Up @@ -112,10 +111,10 @@ protected virtual DifferedConstraint BuildChildConstraint(ScalarReferencePredica
}

if (xml.QueryScalar != null)
builder.Setup(xml.QueryScalar, ConstraintXml.Settings, Xml.Settings.SettingsXml.DefaultScope.Assert);
builder.Setup(xml.QueryScalar, ConstraintXml.Settings, SettingsXml.DefaultScope.Assert);

if (xml.Projection != null)
builder.Setup(xml.Projection, ConstraintXml.Settings, Xml.Settings.SettingsXml.DefaultScope.Assert);
builder.Setup(xml.Projection, ConstraintXml.Settings, SettingsXml.DefaultScope.Assert);

builder.Build();
var args = builder.GetArgs();
Expand Down
Loading

0 comments on commit 33f2661

Please sign in to comment.