diff --git a/NBi.NUnit/Builder/AbstractExecutionBuilder.cs b/NBi.NUnit/Builder/AbstractExecutionBuilder.cs index 5b74e4e93..a529083f5 100644 --- a/NBi.NUnit/Builder/AbstractExecutionBuilder.cs +++ b/NBi.NUnit/Builder/AbstractExecutionBuilder.cs @@ -54,7 +54,7 @@ protected virtual IQuery GetQuery(ExecutionXml executionXml) { var builder = new QueryResolverArgsBuilder(ServiceLocator); parameters = builder.BuildParameters(((QueryXml)executionXml.BaseItem).GetParameters()); - variables = ((QueryXml)executionXml.BaseItem).GetVariables(); + variables = ((QueryXml)executionXml.BaseItem).GetTemplateVariables(); timeout = ((QueryXml)executionXml.BaseItem).Timeout; } if (executionXml.BaseItem is ReportXml) diff --git a/NBi.NUnit/Builder/AbstractResultSetBuilder.cs b/NBi.NUnit/Builder/AbstractResultSetBuilder.cs index b52b0878d..c52480515 100644 --- a/NBi.NUnit/Builder/AbstractResultSetBuilder.cs +++ b/NBi.NUnit/Builder/AbstractResultSetBuilder.cs @@ -62,14 +62,14 @@ protected virtual IResultSetService InstantiateSystemUnderTest(ExecutionXml exec var statement = (executionXml.Item as QueryableXml).GetQuery(); IEnumerable parameters = null; - IEnumerable variables = null; + IEnumerable templateVariables = null; int timeout = 0; - var commandType = System.Data.CommandType.Text; + var commandType = CommandType.Text; if (executionXml.BaseItem is QueryXml) { parameters = argsBuilder.BuildParameters(((QueryXml)executionXml.BaseItem).GetParameters()); - variables = ((QueryXml)executionXml.BaseItem).GetVariables(); + templateVariables = ((QueryXml)executionXml.BaseItem).GetTemplateVariables(); timeout = ((QueryXml)executionXml.BaseItem).Timeout; } if (executionXml.BaseItem is ReportXml) @@ -82,7 +82,7 @@ protected virtual IResultSetService InstantiateSystemUnderTest(ExecutionXml exec commandType = ((ReportXml)executionXml.BaseItem).GetCommandType(); } - var queryArgs = new QueryResolverArgs(statement, connectionString, parameters, variables, new TimeSpan(0, 0, timeout), commandType); + var queryArgs = new QueryResolverArgs(statement, connectionString, parameters, templateVariables, new TimeSpan(0, 0, timeout), commandType); var args = new QueryResultSetResolverArgs(queryArgs); var factory = ServiceLocator.GetResultSetResolverFactory(); var resolver = factory.Instantiate(args); diff --git a/NBi.NUnit/Builder/Helper/QueryResolverArgsBuilder.cs b/NBi.NUnit/Builder/Helper/QueryResolverArgsBuilder.cs index 013578af1..26d69b033 100644 --- a/NBi.NUnit/Builder/Helper/QueryResolverArgsBuilder.cs +++ b/NBi.NUnit/Builder/Helper/QueryResolverArgsBuilder.cs @@ -53,19 +53,19 @@ public void Build() var connectionString = queryXml.GetConnectionString(); var parameters = BuildParameters(queryXml.GetParameters()); - var variables = queryXml.GetVariables(); + var templateVariables = queryXml.GetTemplateVariables(); var timeout = queryXml.Timeout; if (!string.IsNullOrEmpty(queryXml.InlineQuery)) args = new EmbeddedQueryResolverArgs(queryXml.InlineQuery - , connectionString, parameters, variables, new TimeSpan(0, 0, timeout)); + , connectionString, parameters, templateVariables, new TimeSpan(0, 0, timeout)); else if (!string.IsNullOrEmpty(queryXml.File)) { var file = GetFullPath(settingsXml?.BasePath, queryXml.File); args = new ExternalFileQueryResolverArgs(file - , connectionString, parameters, variables, new TimeSpan(0, 0, timeout)); + , connectionString, parameters, templateVariables, new TimeSpan(0, 0, timeout)); } else if (queryXml.Assembly != null) @@ -75,7 +75,7 @@ public void Build() args = new AssemblyQueryResolverArgs( file, queryXml.Assembly.Klass, queryXml.Assembly.Method, queryXml.Assembly.Static, queryXml.Assembly.GetMethodParameters() - , connectionString, parameters, variables, new TimeSpan(0, 0, timeout)); + , connectionString, parameters, templateVariables, new TimeSpan(0, 0, timeout)); } else if (queryXml.Report != null) @@ -84,7 +84,7 @@ public void Build() args = new ReportDataSetQueryResolverArgs( queryXml.Report.Source, path, queryXml.Report.Name, queryXml.Report.Dataset - , connectionString, parameters, variables, new TimeSpan(0, 0, timeout)); + , connectionString, parameters, templateVariables, new TimeSpan(0, 0, timeout)); } else if (queryXml.SharedDataset != null) @@ -93,7 +93,7 @@ public void Build() args = new SharedDataSetQueryResolverArgs( queryXml.SharedDataset.Source, queryXml.SharedDataset.Path, queryXml.SharedDataset.Name - , connectionString, parameters, variables, new TimeSpan(0, 0, timeout)); + , connectionString, parameters, templateVariables, new TimeSpan(0, 0, timeout)); } if (args == null) diff --git a/NBi.NUnit/Builder/Helper/ScalarResolverArgsBuilder.cs b/NBi.NUnit/Builder/Helper/ScalarResolverArgsBuilder.cs index 5bb00aac3..25f33f461 100644 --- a/NBi.NUnit/Builder/Helper/ScalarResolverArgsBuilder.cs +++ b/NBi.NUnit/Builder/Helper/ScalarResolverArgsBuilder.cs @@ -75,6 +75,7 @@ public void Build() var builder = new ResultSetResolverArgsBuilder(serviceLocator); builder.Setup(((ProjectionXml)obj).ResultSet); builder.Setup(settings); + builder.Setup(globalVariables); builder.Build(); args = new RowCountResultSetScalarResolverArgs(builder.GetArgs()); } diff --git a/NBi.NUnit/Builder/MembersContainBuilder.cs b/NBi.NUnit/Builder/MembersContainBuilder.cs index 913ce9bc4..6e330672c 100644 --- a/NBi.NUnit/Builder/MembersContainBuilder.cs +++ b/NBi.NUnit/Builder/MembersContainBuilder.cs @@ -43,6 +43,7 @@ protected NBiConstraint InstantiateConstraint(ContainXml ctrXml) var builder = new ResultSetResolverArgsBuilder(ServiceLocator); builder.Setup(ctrXml.Query); builder.Setup(ctrXml.Settings); + builder.Setup(Variables); builder.Build(); var factory = ServiceLocator.GetResultSetResolverFactory(); diff --git a/NBi.NUnit/Builder/MembersContainedInBuilder.cs b/NBi.NUnit/Builder/MembersContainedInBuilder.cs index 2fbea304e..74ae85575 100644 --- a/NBi.NUnit/Builder/MembersContainedInBuilder.cs +++ b/NBi.NUnit/Builder/MembersContainedInBuilder.cs @@ -43,6 +43,7 @@ protected NBiConstraint InstantiateConstraint(ContainedInXml ctrXml) var builder = new ResultSetResolverArgsBuilder(ServiceLocator); builder.Setup(ctrXml.Query); builder.Setup(ctrXml.Settings); + builder.Setup(Variables); builder.Build(); var factory = ServiceLocator.GetResultSetResolverFactory(); diff --git a/NBi.NUnit/Builder/MembersEquivalentToBuilder.cs b/NBi.NUnit/Builder/MembersEquivalentToBuilder.cs index c94175ce1..37687ec70 100644 --- a/NBi.NUnit/Builder/MembersEquivalentToBuilder.cs +++ b/NBi.NUnit/Builder/MembersEquivalentToBuilder.cs @@ -43,6 +43,7 @@ protected NBiConstraint InstantiateConstraint(EquivalentToXml ctrXml) var builder = new ResultSetResolverArgsBuilder(ServiceLocator); builder.Setup(ctrXml.Query); builder.Setup(ctrXml.Settings); + builder.Setup(Variables); builder.Build(); var factory = ServiceLocator.GetResultSetResolverFactory(); diff --git a/NBi.NUnit/Builder/ResultSetEqualToBuilder.cs b/NBi.NUnit/Builder/ResultSetEqualToBuilder.cs index b8223f7f7..9100e0a17 100644 --- a/NBi.NUnit/Builder/ResultSetEqualToBuilder.cs +++ b/NBi.NUnit/Builder/ResultSetEqualToBuilder.cs @@ -27,14 +27,10 @@ class ResultSetEqualToBuilder : AbstractResultSetBuilder protected EqualToXml ConstraintXml { get; set; } protected virtual EquivalenceKind EquivalenceKind - { - get { return EquivalenceKind.EqualTo; } - } + { get => EquivalenceKind.EqualTo; } public ResultSetEqualToBuilder() - { - - } + { } protected override void SpecificSetup(AbstractSystemUnderTestXml sutXml, AbstractConstraintXml ctrXml) { @@ -111,6 +107,7 @@ protected virtual BaseResultSetComparisonConstraint InstantiateConstraint(object var argsBuilder = new ResultSetResolverArgsBuilder(ServiceLocator); argsBuilder.Setup(obj); argsBuilder.Setup(settings); + argsBuilder.Setup(Variables); argsBuilder.Build(); var factory = ServiceLocator.GetResultSetResolverFactory(); @@ -123,9 +120,10 @@ protected virtual BaseResultSetComparisonConstraint InstantiateConstraint(object var service = serviceBuilder.GetService(); - return new EqualToConstraint(service); + return InstantiateConstraint(service); } - + protected virtual BaseResultSetComparisonConstraint InstantiateConstraint(IResultSetService service) + => new EqualToConstraint(service); } } diff --git a/NBi.NUnit/Builder/ResultSetSubsetOfBuilder.cs b/NBi.NUnit/Builder/ResultSetSubsetOfBuilder.cs index 90317c812..a240fe4e2 100644 --- a/NBi.NUnit/Builder/ResultSetSubsetOfBuilder.cs +++ b/NBi.NUnit/Builder/ResultSetSubsetOfBuilder.cs @@ -22,14 +22,11 @@ namespace NBi.NUnit.Builder { class ResultSetSubsetOfBuilder : ResultSetEqualToBuilder { - public ResultSetSubsetOfBuilder() - { - - } protected override EquivalenceKind EquivalenceKind - { - get { return EquivalenceKind.SubsetOf; } - } + { get => EquivalenceKind.SubsetOf; } + + public ResultSetSubsetOfBuilder() + { } protected override void SpecificSetup(AbstractSystemUnderTestXml sutXml, AbstractConstraintXml ctrXml) { @@ -39,30 +36,7 @@ protected override void SpecificSetup(AbstractSystemUnderTestXml sutXml, Abstrac ConstraintXml = (SubsetOfXml)ctrXml; } - protected override void SpecificBuild() - { - Constraint = InstantiateConstraint(); - } - - - protected override BaseResultSetComparisonConstraint InstantiateConstraint(object obj, SettingsXml settings, TransformationProvider transformation) - { - var argsBuilder = new ResultSetResolverArgsBuilder(ServiceLocator); - argsBuilder.Setup(obj); - argsBuilder.Setup(settings); - argsBuilder.Build(); - - var factory = ServiceLocator.GetResultSetResolverFactory(); - var resolver = factory.Instantiate(argsBuilder.GetArgs()); - - var builder = new ResultSetServiceBuilder(); - builder.Setup(resolver); - if (transformation != null) - builder.Setup(transformation.Transform); - var service = builder.GetService(); - - return new SubsetOfConstraint(service); - } - + protected override BaseResultSetComparisonConstraint InstantiateConstraint(IResultSetService service) + => new SubsetOfConstraint(service); } } diff --git a/NBi.NUnit/Builder/ResultSetSupersetOfBuilder.cs b/NBi.NUnit/Builder/ResultSetSupersetOfBuilder.cs index cefca87c2..94be4dc00 100644 --- a/NBi.NUnit/Builder/ResultSetSupersetOfBuilder.cs +++ b/NBi.NUnit/Builder/ResultSetSupersetOfBuilder.cs @@ -35,27 +35,8 @@ protected override void SpecificSetup(AbstractSystemUnderTestXml sutXml, Abstrac ConstraintXml = (SupersetOfXml)ctrXml; } - protected override void SpecificBuild() - { - Constraint = InstantiateConstraint(); - } - - protected override BaseResultSetComparisonConstraint InstantiateConstraint(object obj, SettingsXml settings, TransformationProvider transformation) - { - var argsBuilder = new ResultSetResolverArgsBuilder(ServiceLocator); - argsBuilder.Setup(obj); - argsBuilder.Build(); + protected override BaseResultSetComparisonConstraint InstantiateConstraint(IResultSetService service) + => new SupersetOfConstraint(service); - var factory = ServiceLocator.GetResultSetResolverFactory(); - var resolver = factory.Instantiate(argsBuilder.GetArgs()); - - var builder = new ResultSetServiceBuilder(); - builder.Setup(resolver); - if (transformation != null) - builder.Setup(transformation.Transform); - var service = builder.GetService(); - - return new SupersetOfConstraint(service); - } } } diff --git a/NBi.Testing/Acceptance/Resources/Positive/Variable.nbits b/NBi.Testing/Acceptance/Resources/Positive/Variable.nbits index 2290742a3..e0a4c754c 100644 --- a/NBi.Testing/Acceptance/Resources/Positive/Variable.nbits +++ b/NBi.Testing/Acceptance/Resources/Positive/Variable.nbits @@ -41,6 +41,7 @@ + @common select @common; diff --git a/NBi.Testing/Unit/NUnit/Builder/ExecutionMatchPatternBuilderTest.cs b/NBi.Testing/Unit/NUnit/Builder/ExecutionMatchPatternBuilderTest.cs index e240da229..2d380940a 100644 --- a/NBi.Testing/Unit/NUnit/Builder/ExecutionMatchPatternBuilderTest.cs +++ b/NBi.Testing/Unit/NUnit/Builder/ExecutionMatchPatternBuilderTest.cs @@ -55,7 +55,7 @@ public void GetConstraint_Build_CorrectConstraint() var itemXmlStubFactory = new Mock(); itemXmlStubFactory.Setup(i => i.GetQuery()).Returns("query"); itemXmlStubFactory.Setup(i => i.GetParameters()).Returns(new List()); - itemXmlStubFactory.Setup(i => i.GetVariables()).Returns(new List()); + itemXmlStubFactory.Setup(i => i.GetTemplateVariables()).Returns(new List()); sutXmlStubFactory.Setup(s => s.Item).Returns(itemXmlStubFactory.Object); var sutXml = sutXmlStubFactory.Object; sutXml.Item = itemXmlStubFactory.Object; @@ -77,7 +77,7 @@ public void GetSystemUnderTest_Build_CorrectIDbCommand() var itemXmlStubFactory = new Mock(); itemXmlStubFactory.Setup(i => i.GetQuery()).Returns("query"); itemXmlStubFactory.Setup(i => i.GetParameters()).Returns(new List()); - itemXmlStubFactory.Setup(i => i.GetVariables()).Returns(new List()); + itemXmlStubFactory.Setup(i => i.GetTemplateVariables()).Returns(new List()); sutXmlStubFactory.Setup(s => s.Item).Returns(itemXmlStubFactory.Object); var sutXml = sutXmlStubFactory.Object; sutXml.Item = itemXmlStubFactory.Object; diff --git a/NBi.Testing/Unit/Xml/Settings/SettingsXmlTest.cs b/NBi.Testing/Unit/Xml/Settings/SettingsXmlTest.cs index 45b09027f..03a384b49 100644 --- a/NBi.Testing/Unit/Xml/Settings/SettingsXmlTest.cs +++ b/NBi.Testing/Unit/Xml/Settings/SettingsXmlTest.cs @@ -267,7 +267,7 @@ public void DeserializeStructurePerspective_SettingsWithVariables_True() // Create an instance of the XmlSerializer specifying type and namespace. TestSuiteXml ts = DeserializeSample("SettingsXmlWithVariables"); - var parameters = ((QueryXml)ts.Tests[testNr].Systems[0].BaseItem).GetVariables(); + var parameters = ((QueryXml)ts.Tests[testNr].Systems[0].BaseItem).GetTemplateVariables(); Assert.That(parameters.Count, Is.EqualTo(3)); } diff --git a/NBi.Xml/Items/QueryableXml.cs b/NBi.Xml/Items/QueryableXml.cs index a1a837f17..b0722351f 100644 --- a/NBi.Xml/Items/QueryableXml.cs +++ b/NBi.Xml/Items/QueryableXml.cs @@ -44,7 +44,7 @@ public virtual List GetParameters() return list; } - public virtual List GetVariables() + public virtual List GetTemplateVariables() { var list = Variables; foreach (var variable in Default.Variables)