Best NBi code snippet using NBi.Core.ResultSet.ResultSetServiceBuilder.Setup
EqualToConstraintTest.cs
Source:EqualToConstraintTest.cs
...2425 #region SetUp & TearDown26 //Called only at instance creation27 [OneTimeSetUp]28 public void SetupMethods()29 {3031 }3233 //Called only at instance destruction34 [OneTimeTearDown]35 public void TearDownMethods()36 {37 }3839 //Called before each test40 [SetUp]41 public void SetupTest()42 {43 }4445 //Called after each test46 [TearDown]47 public void TearDownTest()48 {49 }50 #endregion5152 private class FakeQueryResultSetResolver : QueryResultSetResolver53 {54 private readonly IQuery query;5556 public FakeQueryResultSetResolver(IQuery query, ServiceLocator serviceLocator)57 : base(null, serviceLocator)58 {59 this.query = query;60 }6162 protected override IQuery Resolve() => query;63 }6465 [Test, Category("Sql"), Category("Slow")]66 public void Matches_TwoQueriesOfThreeSecondsParallel_FasterThanSixSeconds()67 {68 var query1 = new NBi.Core.Query.Query("WAITFOR DELAY '00:00:03';SELECT 1;", ConnectionStringReader.GetSqlClient());69 var query2 = new NBi.Core.Query.Query("WAITFOR DELAY '00:00:03';SELECT 1;", ConnectionStringReader.GetSqlClient());7071 var resolver = new FakeQueryResultSetResolver(query2, serviceLocator);72 var builder = new ResultSetServiceBuilder();73 builder.Setup(resolver);74 BaseResultSetComparisonConstraint ctr = new EqualToConstraint(builder.GetService());75 ctr = ctr.Parallel();7677 //Method under test78 var chrono = DateTime.Now;79 var actualBuilder = new ResultSetServiceBuilder();80 actualBuilder.Setup(new FakeQueryResultSetResolver(query1, serviceLocator));81 var actual = actualBuilder.GetService();82 Assert.That(actual, ctr);83 var elapsed = DateTime.Now.Subtract(chrono);8485 Assert.That(elapsed.Seconds, Is.LessThan(6));86 }8788 [Test, Category("Sql"), Category("Slow")]89 public void Matches_TwoQueriesOfThreeSecondsSequential_SlowerThanSixSeconds()90 {91 var query1 = new NBi.Core.Query.Query("WAITFOR DELAY '00:00:03';SELECT 1;", ConnectionStringReader.GetSqlClient());92 var query2 = new NBi.Core.Query.Query("WAITFOR DELAY '00:00:03';SELECT 1;", ConnectionStringReader.GetSqlClient());9394 var loader = new FakeQueryResultSetResolver(query2, serviceLocator);95 var builder = new ResultSetServiceBuilder();96 builder.Setup(loader);97 BaseResultSetComparisonConstraint ctr = new EqualToConstraint(builder.GetService());98 ctr = ctr.Sequential();99100 //Method under test101 var chrono = DateTime.Now;102 var actualBuilder = new ResultSetServiceBuilder();103 actualBuilder.Setup(new FakeQueryResultSetResolver(query1, serviceLocator));104 var actual = actualBuilder.GetService();105106 Assert.That(actual, ctr);107 var elapsed = DateTime.Now.Subtract(chrono);108109 Assert.That(elapsed.Seconds, Is.GreaterThanOrEqualTo(6));110 }111112113 [Test]114 [Category("Olap")]115 public void Matches_MdxQueryAndResulSetWithoutKeyValuesInfo_Matching()116 {117 //Buiding object used during test118 var objs = new List<object[]>(){119 new object[] { "CY 2005", "1874469.00" },120 new object[] { "CY 2006", "4511243.0" },121 new object[] { "CY 2007", "4709851" },122 new object[] { "CY 2008", "1513940" }123 };124125 var resolver = new ObjectsResultSetResolver(new ObjectsResultSetResolverArgs(objs.ToArray()));126 var builder = new ResultSetServiceBuilder();127 builder.Setup(resolver);128 var ctr = new EqualToConstraint(builder.GetService());129130 var mdx = "SELECT [Measures].[Amount] ON 0, NON EMPTY([Date].[Calendar].[Calendar Year]) ON 1 FROM [Adventure Works]";131 var query = new NBi.Core.Query.Query(mdx, ConnectionStringReader.GetAdomd());132133134 var actualBuilder = new ResultSetServiceBuilder();135 actualBuilder.Setup(new FakeQueryResultSetResolver(query, serviceLocator));136 var actual = actualBuilder.GetService();137138 //Assertion139 Assert.That(ctr.Matches(actual));140 }141142 [Test]143 [Category("Olap")]144 public void Matches_MdxQueryAndResulSetWithCorrectSettings_Matching()145 {146 //Buiding object used during test147 var objs = new List<object[]>(){148 new object[] { "CY 2005", "1874469.00" },149 new object[] { "CY 2006", "4511243.0" },150 new object[] { "CY 2007", "4709851" },151 new object[] { "CY 2008", "1513940" }152 };153154 var resolver = new ObjectsResultSetResolver(new ObjectsResultSetResolverArgs(objs.ToArray()));155 var builder = new ResultSetServiceBuilder();156 builder.Setup(resolver);157 var ctr = new EqualToConstraint(builder.GetService());158 ctr.Using(new SettingsOrdinalResultSet(159 SettingsOrdinalResultSet.KeysChoice.First,160 SettingsOrdinalResultSet.ValuesChoice.Last,161 new NumericAbsoluteTolerance(500, SideTolerance.Both)162 )163 );164165 var mdx = "SELECT [Measures].[Amount] ON 0, NON EMPTY([Date].[Calendar].[Calendar Year]) ON 1 FROM [Adventure Works]";166 var query = new NBi.Core.Query.Query(mdx, ConnectionStringReader.GetAdomd());167168169 var actualBuilder = new ResultSetServiceBuilder();170 actualBuilder.Setup(new FakeQueryResultSetResolver(query, serviceLocator));171 var actual = actualBuilder.GetService();172173 //Assertion174 Assert.That(ctr.Matches(actual));175 }176177 [Test]178 [Category("Olap")]179 public void Matches_MdxQueryAndDecimalResulSetWithCorrectSettings_Matching()180 {181 //Buiding object used during test182 var objs = new List<object[]>() {183 new object[] { "CY 2005", 1874469.00 },184 new object[] { "CY 2006", 4511243.0 },185 new object[] { "CY 2007", 4709851 },186 new object[] { "CY 2008", 1513940 }187 };188 var resolver = new ObjectsResultSetResolver(new ObjectsResultSetResolverArgs(objs.ToArray()));189 var builder = new ResultSetServiceBuilder();190 builder.Setup(resolver);191 var ctr = new EqualToConstraint(builder.GetService());192 ctr.Using(new SettingsOrdinalResultSet(193 SettingsOrdinalResultSet.KeysChoice.First,194 SettingsOrdinalResultSet.ValuesChoice.Last,195 NumericAbsoluteTolerance.None)196 );197198 var mdx = "SELECT [Measures].[Amount] ON 0, NON EMPTY([Date].[Calendar].[Calendar Year]) ON 1 FROM [Adventure Works]";199 var query = new NBi.Core.Query.Query(mdx, ConnectionStringReader.GetAdomd());200 var actualBuilder = new ResultSetServiceBuilder();201 actualBuilder.Setup(new FakeQueryResultSetResolver(query, serviceLocator));202 var actual = actualBuilder.GetService();203204 //Assertion205 Assert.That(ctr.Matches(actual));206 }207208 [Test]209 [Category("Olap")]210 public void Matches_MdxQueryAndSameQueryWithCorrectSettings_Matching()211 {212 //Buiding object used during test213 var mdx = "SELECT [Measures].[Amount] ON 0, NON EMPTY([Date].[Calendar].[Calendar Year]) ON 1 FROM [Adventure Works]";214 var expectedQuery = new NBi.Core.Query.Query(mdx, ConnectionStringReader.GetAdomd());215 var resolver = new FakeQueryResultSetResolver(expectedQuery, serviceLocator);216 var builder = new ResultSetServiceBuilder();217 builder.Setup(resolver);218 var ctr = new EqualToConstraint(builder.GetService());219 ctr.Using(new SettingsOrdinalResultSet(220 SettingsOrdinalResultSet.KeysChoice.First,221 SettingsOrdinalResultSet.ValuesChoice.Last,222 NumericAbsoluteTolerance.None)223 );224225 var mdx2 = "SELECT [Measures].[Amount] ON 0, NON EMPTY([Date].[Calendar].[Calendar Year]) ON 1 FROM [Adventure Works]";226 var query = new NBi.Core.Query.Query(mdx2, ConnectionStringReader.GetAdomd());227228 var actualBuilder = new ResultSetServiceBuilder();229 actualBuilder.Setup(new FakeQueryResultSetResolver(query, serviceLocator));230 var actual = actualBuilder.GetService();231232 //Assertion233 Assert.That(ctr.Matches(actual));234 }235236 [Test]237 [Category("Olap")]238 public void Matches_MdxQueryAndSlighltyDifferentQueryWithCorrectSettings_NotMatching()239 {240 //Buiding object used during test241 var mdx = "WITH MEMBER [Measures].NewAmount AS [Measures].[Amount]+1";242 mdx += " SELECT [Measures].NewAmount ON 0, NON EMPTY([Date].[Calendar].[Calendar Year]) ON 1 FROM [Adventure Works]";243 var expectedQuery = new NBi.Core.Query.Query(mdx, ConnectionStringReader.GetAdomd());244 var resolver = new FakeQueryResultSetResolver(expectedQuery, serviceLocator);245 var builder = new ResultSetServiceBuilder();246 builder.Setup(resolver);247 var ctr = new EqualToConstraint(builder.GetService());248 ctr.Using(new SettingsOrdinalResultSet(249 SettingsOrdinalResultSet.KeysChoice.First,250 SettingsOrdinalResultSet.ValuesChoice.Last,251 NumericAbsoluteTolerance.None)252 );253254 var mdx2 = "SELECT [Measures].[Amount] ON 0, ([Date].[Calendar].[Calendar Year]-[Date].[Calendar].[Calendar Year].&[2010]) ON 1 FROM [Adventure Works]";255 var query = new NBi.Core.Query.Query(mdx2, ConnectionStringReader.GetAdomd());256257 var actualBuilder = new ResultSetServiceBuilder();258 actualBuilder.Setup(new FakeQueryResultSetResolver(query, serviceLocator));259 var actual = actualBuilder.GetService();260261 //Assertion262 Assert.That(ctr.Matches(actual), Is.False);263 }264265 [Test]266 [Category("Olap")]267 public void Matches_MdxQueryAndSlighltyDifferentQueryWithCorrectSettingsAndTolerance_Matching()268 {269 //Buiding object used during test270 var mdx = "WITH MEMBER [Measures].NewAmount AS [Measures].[Amount]+1";271 mdx += " SELECT [Measures].NewAmount ON 0, ([Date].[Calendar].[Calendar Year].[CY 2005]:[Date].[Calendar].[Calendar Year].[CY 2008]) ON 1 FROM [Adventure Works]";272 var expectedQuery = new NBi.Core.Query.Query(mdx, ConnectionStringReader.GetAdomd());273 var resolver = new FakeQueryResultSetResolver(expectedQuery, serviceLocator);274 var builder = new ResultSetServiceBuilder();275 builder.Setup(resolver);276 var ctr = new EqualToConstraint(builder.GetService());277 ctr.Using(new SettingsOrdinalResultSet(278 SettingsOrdinalResultSet.KeysChoice.First,279 SettingsOrdinalResultSet.ValuesChoice.Last,280 new List<IColumnDefinition>()281 {282 new Column()283 {284 Identifier= new ColumnOrdinalIdentifier(1),285 Role= ColumnRole.Value,286 Type=ColumnType.Numeric,287 Tolerance= "10"288 }289 }290 )291 );292293 var query = "SELECT [Measures].[Amount] ON 0, NON EMPTY([Date].[Calendar].[Calendar Year]) ON 1 FROM [Adventure Works]";294 var cmd = new NBi.Core.Query.Query(query, ConnectionStringReader.GetAdomd());295296297 var actualBuilder = new ResultSetServiceBuilder();298 actualBuilder.Setup(new FakeQueryResultSetResolver(cmd, serviceLocator));299 var actual = actualBuilder.GetService();300301 //Assertion302 Assert.That(ctr.Matches(actual));303 }304305 [Test]306 [Category("Sql")]307 [Category("Olap")]308 public void Matches_MdxQueryAndSqlQueryWithCorrectSettings_Matching()309 {310 //Buiding object used during test311 var sql = "SELECT 'CY 2005', 1874469 UNION ";312 sql += " SELECT 'CY 2006', 4511243 UNION ";313 sql += " SELECT 'CY 2007', 4709851 UNION ";314 sql += " SELECT 'CY 2008', 1513940 ";315316 var expectedQuery = new NBi.Core.Query.Query(sql, ConnectionStringReader.GetSqlClient());317 var resolver = new FakeQueryResultSetResolver(expectedQuery, serviceLocator);318 var builder = new ResultSetServiceBuilder();319 builder.Setup(resolver);320 var ctr = new EqualToConstraint(builder.GetService());321 ctr.Using(322 new SettingsOrdinalResultSet(323 SettingsOrdinalResultSet.KeysChoice.AllExpectLast,324 SettingsOrdinalResultSet.ValuesChoice.Last,325 new List<IColumnDefinition>()326 {327 new Column()328 {329 Identifier= new ColumnOrdinalIdentifier(1),330 Role = ColumnRole.Value,331 Type = ColumnType.Numeric,332 Tolerance = "5"333 }334 }335 )336 );337338 var mdx = "SELECT [Measures].[Amount] ON 0, NON EMPTY([Date].[Calendar].[Calendar Year]) ON 1 FROM [Adventure Works]";339 var query = new NBi.Core.Query.Query(mdx, ConnectionStringReader.GetAdomd());340341 var actualBuilder = new ResultSetServiceBuilder();342 actualBuilder.Setup(new FakeQueryResultSetResolver(query, serviceLocator));343 var actual = actualBuilder.GetService();344345 //Assertion346 Assert.That(ctr.Matches(actual));347 }348349 [Test]350 [Category("Olap")]351 public void Matches_MdxQueryAndResulSetCsvFile_Matching()352 {353 //Buiding object used during test354 var filename = DiskOnFile.CreatePhysicalFile("NonEmptyAmountByYear.csv", "NBi.Testing.Integration.NUnit.Resources.NonEmptyAmountByYear.csv");355 var resolver = new FlatFileResultSetResolver(new FlatFileResultSetResolverArgs(new LiteralScalarResolver<string>(filename), string.Empty, string.Empty, null, CsvProfile.SemiColumnDoubleQuote), serviceLocator);356 var builder = new ResultSetServiceBuilder();357 builder.Setup(resolver);358 var ctr = new EqualToConstraint(builder.GetService());359360 var mdx = "SELECT [Measures].[Amount] ON 0, NON EMPTY([Date].[Calendar].[Calendar Year]) ON 1 FROM [Adventure Works]";361 var query = new NBi.Core.Query.Query(mdx, ConnectionStringReader.GetAdomd());362363364 var actualBuilder = new ResultSetServiceBuilder();365 actualBuilder.Setup(new FakeQueryResultSetResolver(query, serviceLocator));366 var actual = actualBuilder.GetService();367368 //Assertion369 Assert.That(ctr.Matches(actual));370 }371372 [Test]373 [Category("Olap")]374 public void Matches_MdxQueryWithNullComparedToSqlWithNull_Matching()375 {376 var sql = "SELECT 'CY 2010', NULL ";377 var expectedQuery = new NBi.Core.Query.Query(sql, ConnectionStringReader.GetSqlClient());378379 var resolver = new FakeQueryResultSetResolver(expectedQuery, serviceLocator);380 var builder = new ResultSetServiceBuilder();381 builder.Setup(resolver);382 var ctr = new EqualToConstraint(builder.GetService());383 ctr.Using(384 new SettingsOrdinalResultSet(385 SettingsOrdinalResultSet.KeysChoice.AllExpectLast,386 SettingsOrdinalResultSet.ValuesChoice.Last,387 NumericAbsoluteTolerance.None388 )389 );390391 var mdx = "SELECT [Measures].[Amount] ON 0, [Date].[Calendar].[Calendar Year].&[2010] ON 1 FROM [Adventure Works]";392 var query = new NBi.Core.Query.Query(mdx, ConnectionStringReader.GetAdomd());393394 var actualBuilder = new ResultSetServiceBuilder();395 actualBuilder.Setup(new FakeQueryResultSetResolver(query, serviceLocator));396 var actual = actualBuilder.GetService();397398 //Assertion399 Assert.That(ctr.Matches(actual));400 }401402 [Test]403 [Category("Olap")]404 public void Matches_MdxQueryWithNullComparedToSqlWithValue_NonMatching()405 {406 //Buiding object used during test407 var sql = "SELECT 'CY 2010', 0 ";408 var expectedQuery = new NBi.Core.Query.Query(sql, ConnectionStringReader.GetSqlClient());409 var resolver = new FakeQueryResultSetResolver(expectedQuery, serviceLocator);410 var builder = new ResultSetServiceBuilder();411 builder.Setup(resolver);412 var ctr = new EqualToConstraint(builder.GetService());413 ctr.Using(414 new SettingsOrdinalResultSet(415 SettingsOrdinalResultSet.KeysChoice.AllExpectLast,416 SettingsOrdinalResultSet.ValuesChoice.Last,417 NumericAbsoluteTolerance.None418 )419 );420421 var mdx = "SELECT [Measures].[Amount] ON 0, [Date].[Calendar].[Calendar Year].&[2010] ON 1 FROM [Adventure Works]";422 var query = new NBi.Core.Query.Query(mdx, ConnectionStringReader.GetAdomd());423424 var actualBuilder = new ResultSetServiceBuilder();425 actualBuilder.Setup(new FakeQueryResultSetResolver(query, serviceLocator));426 var actual = actualBuilder.GetService();427428 //Assertion429 Assert.That(ctr.Matches(actual), Is.False);430 }431432 [Test]433 [Category("Sql")]434 public void Matches_SqlQueryWithDateComparedToString_Matching()435 {436 var expectedSql = "SELECT 'CY 2010', CAST('2010-01-01' AS DATE)";437 var expectedQuery = new NBi.Core.Query.Query(expectedSql, ConnectionStringReader.GetSqlClient());438439 var columns = new List<IColumnDefinition>(){440 new Column() { Identifier= new ColumnOrdinalIdentifier(1), Role = ColumnRole.Value, Type = ColumnType.DateTime }441 };442 var resolver = new FakeQueryResultSetResolver(expectedQuery, serviceLocator);443 var builder = new ResultSetServiceBuilder();444 builder.Setup(resolver);445 var ctr = new EqualToConstraint(builder.GetService());446 ctr.Using(447 new SettingsOrdinalResultSet(448 SettingsOrdinalResultSet.KeysChoice.AllExpectLast,449 SettingsOrdinalResultSet.ValuesChoice.Last,450 columns451 )452 );453454 var sql = "SELECT 'CY 2010', '1/01/2010 00:00:00'";455 var query = new NBi.Core.Query.Query(sql, ConnectionStringReader.GetSqlClient());456457 var actualBuilder = new ResultSetServiceBuilder();458 actualBuilder.Setup(new FakeQueryResultSetResolver(query, serviceLocator));459 var actual = actualBuilder.GetService();460461 //Assertion462 Assert.That(ctr.Matches(actual));463 }464465 [Test]466 [Category("Sql")]467 public void Matches_SqlQueryWithDateComparedToStringAnotherDate_NonMatching()468 {469 //Buiding object used during test470 var expectedSql = "SELECT 'CY 2010', CAST('2010-01-02' AS DATE)";471 var expectedQuery = new NBi.Core.Query.Query(expectedSql, ConnectionStringReader.GetSqlClient());472473 var columns = new List<IColumnDefinition>(){474 new Column() { Identifier= new ColumnOrdinalIdentifier(1), Role = ColumnRole.Value, Type = ColumnType.DateTime }475 };476 var resolver = new FakeQueryResultSetResolver(expectedQuery, serviceLocator);477 var builder = new ResultSetServiceBuilder();478 builder.Setup(resolver);479 var ctr = new EqualToConstraint(builder.GetService());480 ctr.Using(481 new SettingsOrdinalResultSet(482 SettingsOrdinalResultSet.KeysChoice.AllExpectLast,483 SettingsOrdinalResultSet.ValuesChoice.Last,484 columns485 )486 );487488 var sql2 = "SELECT 'CY 2010', '1/01/2010 00:00:00'";489 var query = new NBi.Core.Query.Query(sql2, ConnectionStringReader.GetSqlClient());490491 var actualBuilder = new ResultSetServiceBuilder();492 actualBuilder.Setup(new FakeQueryResultSetResolver(query, serviceLocator));493 var actual = actualBuilder.GetService();494495 //Assertion496 Assert.That(ctr.Matches(actual), Is.False);497 }498499 [Test]500 [Category("Sql")]501 public void Matches_SqlQueryWithDateComparedToStringAnotherHour_NonMatching()502 {503 //Buiding object used during test504 var expectedSql = "SELECT 'CY 2010', CAST('2010-01-01' AS DATE)";505 var expectedQuery = new NBi.Core.Query.Query(expectedSql, ConnectionStringReader.GetSqlClient());506507 var columns = new List<IColumnDefinition>(){508 new Column() { Identifier= new ColumnOrdinalIdentifier(1), Role = ColumnRole.Value, Type = ColumnType.DateTime }509 };510511 var expectedLoader = new FakeQueryResultSetResolver(expectedQuery, serviceLocator);512 var expectedBuilder = new ResultSetServiceBuilder();513 expectedBuilder.Setup(expectedLoader);514 var ctr = new EqualToConstraint(expectedBuilder.GetService());515 ctr.Using(516 new SettingsOrdinalResultSet(517 SettingsOrdinalResultSet.KeysChoice.AllExpectLast,518 SettingsOrdinalResultSet.ValuesChoice.Last,519 columns520 )521 );522523 var sql2 = "SELECT 'CY 2010', '1/01/2010 01:00:00'";524 var query = new NBi.Core.Query.Query(sql2, ConnectionStringReader.GetSqlClient());525 var builder = new ResultSetServiceBuilder();526 builder.Setup(new FakeQueryResultSetResolver(query, serviceLocator));527 var actual = builder.GetService();528529 //Assertion530 Assert.That(ctr.Matches(actual), Is.False);531 }532 }533}
...
ResultSetServiceTest.cs
Source:ResultSetServiceTest.cs
...17 {18 var rs = new NBi.Core.ResultSet.ResultSet();19 rs.Load("a;1");20 var loaderMock = new Mock<IResultSetResolver>();21 loaderMock.Setup(l => l.Execute()).Returns(rs);22 var loader = loaderMock.Object;23 var builder = new ResultSetServiceBuilder();24 builder.Setup(loader);25 var service = builder.GetService();26 service.Execute();27 loaderMock.Verify(l => l.Execute(), Times.Once);28 }29 [Test]30 public void Execute_LoaderOnly_ReturnsLoadedResultSet()31 {32 var rs = new NBi.Core.ResultSet.ResultSet();33 rs.Load("a;1");34 var loaderMock = new Mock<IResultSetResolver>();35 loaderMock.Setup(l => l.Execute()).Returns(rs);36 var loader = loaderMock.Object;37 var builder = new ResultSetServiceBuilder();38 builder.Setup(loader);39 var service = builder.GetService();40 var result = service.Execute();41 Assert.That(result, Is.EqualTo(rs));42 }43 public class TransformationProviderMockable : TransformationProvider44 {45 public TransformationProviderMockable()46 : base(new NBi.Core.Injection.ServiceLocator(), null) { }47 }48 [Test]49 public void Execute_LoaderAndTransformer_TransformerCalledWithLoaderResult()50 {51 var rs = new NBi.Core.ResultSet.ResultSet();52 rs.Load("a;1");53 var loaderStub = new Mock<IResultSetResolver>();54 loaderStub.Setup(l => l.Execute()).Returns(rs);55 var loader = loaderStub.Object;56 var transformerMock = new Mock<TransformationProviderMockable>();57 transformerMock.Setup(l => l.Transform(rs));58 var transformer = transformerMock.Object;59 var builder = new ResultSetServiceBuilder();60 builder.Setup(loader);61 if (transformer!=null)62 builder.Setup(transformer.Transform);63 var service = builder.GetService();64 service.Execute();65 transformerMock.Verify(t => t.Transform(rs), Times.Once);66 }67 [Test]68 public void Execute_LoaderAndTwoAlters_SecondAlterCalledWithResultOfFirst()69 {70 var rs = new NBi.Core.ResultSet.ResultSet();71 rs.Load("a;1");72 var loaderStub = new Mock<IResultSetResolver>();73 loaderStub.Setup(l => l.Execute()).Returns(It.IsAny<NBi.Core.ResultSet.ResultSet>());74 var loader = loaderStub.Object;75 var transformer1Stub = new Mock<TransformationProviderMockable>();76 transformer1Stub.Setup(l => l.Transform(It.IsAny<NBi.Core.ResultSet.ResultSet>())).Returns(rs);77 var transformer1 = transformer1Stub.Object;78 var transformer2Mock = new Mock<TransformationProviderMockable>();79 transformer2Mock.Setup(l => l.Transform(It.IsAny<NBi.Core.ResultSet.ResultSet>()));80 var transformer2 = transformer2Mock.Object;81 var builder = new ResultSetServiceBuilder();82 builder.Setup(loader);83 builder.Setup(transformer1.Transform);84 builder.Setup(transformer2.Transform);85 var service = builder.GetService();86 service.Execute();87 transformer2Mock.Verify(t => t.Transform(rs), Times.Once);88 }89 }90}...
AbstractResultSetBuilder.cs
Source:AbstractResultSetBuilder.cs
...28 abstract class AbstractResultSetBuilder : AbstractTestCaseBuilder29 {30 protected AbstractSystemUnderTestXml SystemUnderTestXml { get; set; }31 32 public override void Setup(AbstractSystemUnderTestXml sutXml, AbstractConstraintXml ctrXml, IConfiguration config, IDictionary<string, IVariable> variables, ServiceLocator serviceLocator)33 {34 base.Setup(sutXml, ctrXml, config, variables, serviceLocator);35 }36 protected override void BaseSetup(AbstractSystemUnderTestXml sutXml, AbstractConstraintXml ctrXml)37 {38 if (!(sutXml is ExecutionXml || sutXml is ResultSetSystemXml))39 throw new ArgumentException("System-under-test must be a 'ExecutionXml' or 'ResultSetXml'");40 SystemUnderTestXml = sutXml;41 }42 protected override void BaseBuild()43 {44 if (SystemUnderTestXml is ExecutionXml)45 SystemUnderTest = InstantiateSystemUnderTest((ExecutionXml)SystemUnderTestXml);46 else47 SystemUnderTest = InstantiateSystemUnderTest((ResultSetSystemXml)SystemUnderTestXml);48 }49 protected virtual IResultSetService InstantiateSystemUnderTest(ExecutionXml executionXml)50 {51 var queryArgsBuilder = new QueryResolverArgsBuilder(ServiceLocator);52 queryArgsBuilder.Setup(executionXml.Item, executionXml.Settings, Variables);53 queryArgsBuilder.Build();54 var factory = ServiceLocator.GetResultSetResolverFactory();55 var resolver = factory.Instantiate(new QueryResultSetResolverArgs(queryArgsBuilder.GetArgs()));56 var builder = new ResultSetServiceBuilder();57 builder.Setup(resolver);58 var service = builder.GetService();59 return service;60 }61 protected virtual object InstantiateSystemUnderTest(ResultSetSystemXml resultSetXml)62 {63 var builder = new ResultSetServiceBuilder();64 var helper = new ResultSetSystemHelper(ServiceLocator, SettingsXml.DefaultScope.SystemUnderTest, Variables);65 builder.Setup(helper.InstantiateResolver(resultSetXml));66 builder.Setup(helper.InstantiateAlterations(resultSetXml));67 return builder.GetService();68 }69 }70}
Setup
Using AI Code Generation
1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6{7 {8 public void Setup()9 {10 var builder = new NBi.Core.ResultSet.ResultSetServiceBuilder();11 builder.Setup();12 }13 }14}15using System;16using System.Collections.Generic;17using System.Linq;18using System.Text;19using System.Threading.Tasks;20{21 {22 public void Setup()23 {24 var builder = new NBi.Core.ResultSet.ResultSetServiceBuilder();25 builder.Setup();26 }27 }28}29using System;30using System.Collections.Generic;31using System.Linq;32using System.Text;33using System.Threading.Tasks;34{35 {36 public void Setup()37 {38 var builder = new NBi.Core.ResultSet.ResultSetServiceBuilder();39 builder.Setup();40 }41 }42}43using System;44using System.Collections.Generic;45using System.Linq;46using System.Text;47using System.Threading.Tasks;48{49 {50 public void Setup()51 {52 var builder = new NBi.Core.ResultSet.ResultSetServiceBuilder();53 builder.Setup();54 }55 }56}57using System;58using System.Collections.Generic;59using System.Linq;60using System.Text;61using System.Threading.Tasks;62{63 {64 public void Setup()65 {66 var builder = new NBi.Core.ResultSet.ResultSetServiceBuilder();67 builder.Setup();68 }69 }70}71using System;72using System.Collections.Generic;73using System.Linq;74using System.Text;75using System.Threading.Tasks;76{
Setup
Using AI Code Generation
1using NBi.Core.ResultSet;2using NBi.Core;3using System.Data;4using System.Data.SqlClient;5using System;6using System.Collections.Generic;7using System.Linq;8using System.Text;9using System.Threading.Tasks;10using System.IO;11using NBi.Core.ResultSet.Comparer;12using NBi.Core.ResultSet.Equivalence;13using NBi.Core.ResultSet.Lookup;14using NBi.Core.Calculation;15using NBi.Core.Calculation.Grouping;16using NBi.Core.Calculation.Predicate;17using NBi.Core.Calculation.Ranking;18using NBi.Core.Calculation.Ranking.Strategy;19using NBi.Core.Calculation.Ranking.Strategy.Numeric;20using NBi.Core.Calculation.Ranking.Strategy.Text;21using NBi.Core.Calculation.Ranking.Strategy.DateTime;22using NBi.Core.Calculation.Ranking.Strategy.Numeric.TopBottom;23using NBi.Core.Query;24using NBi.Core.ResultSet.Resolver;25using NBi.Core.ResultSet.Resolver.File;26using NBi.Core.ResultSet.Resolver.Fake;27using NBi.Core.ResultSet.Resolver.Csv;28using NBi.Core.ResultSet.Resolver.Xml;29using NBi.Core.ResultSet.Resolver.Db;30using NBi.Core.ResultSet.Resolver.Variables;31using NBi.Core.ResultSet.Resolver.Json;32using NBi.Core.ResultSet.Resolver.Csv;33using NBi.Core.ResultSet.Resolver.Csv.Multidimensional;34using NBi.Core.ResultSet.Resolver.Csv.Ordinals;35using NBi.Core.ResultSet.Resolver.Csv.Header;36using NBi.Core.ResultSet.Resolver.Csv.Quote;37using NBi.Core.ResultSet.Resolver.Csv.Separator;38using NBi.Core.ResultSet.Resolver.Csv.Skip;39using NBi.Core.ResultSet.Resolver.Csv.Tolerance;40using NBi.Core.ResultSet.Resolver.Csv.Encoding;41using NBi.Core.ResultSet.Resolver.Csv.Delimiter;42using NBi.Core.ResultSet.Resolver.Csv.Comment;43using NBi.Core.ResultSet.Resolver.Csv.Trim;44using NBi.Core.ResultSet.Resolver.Csv.DateTimeFormat;45using NBi.Core.ResultSet.Resolver.Csv.NumericFormat;46using NBi.Core.ResultSet.Resolver.Csv.BooleanFormat;47using NBi.Core.ResultSet.Resolver.Csv.NullFormat;48using NBi.Core.ResultSet.Resolver.Csv.TextQualifier;49using NBi.Core.ResultSet.Resolver.Csv.HeaderCaseSensitive;50using NBi.Core.ResultSet.Resolver.Csv.HeaderOrdinal;51using NBi.Core.ResultSet.Resolver.Csv.HeaderName;
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!