How to use BuildDirect method of NBi.Core.Analysis.Request.DiscoveryRequestFactory class

Best NBi code snippet using NBi.Core.Analysis.Request.DiscoveryRequestFactory.BuildDirect

ContainConstraintTest.cs

Source:ContainConstraintTest.cs Github

copy

Full Screen

...14 [Test]15 public void Matches_GivenDiscoveryRequest_FactoryCalledOnceWithParametersComingFromRequest()16 {17 var exp = "Expected hierarchy";18 var request = new DiscoveryRequestFactory().BuildDirect(19 "connectionString",20 DiscoveryTarget.Dimensions,21 new List<IFilter>()22 {23 new CaptionFilter("perspective-name", DiscoveryTarget.Perspectives)24 , new CaptionFilter("dimension-caption", DiscoveryTarget.Dimensions)25 });2627 var elStub = new Mock<IField>();28 var el1 = elStub.Object;29 var el2 = elStub.Object;30 var elements = new List<IField>();31 elements.Add(el1);32 elements.Add(el2);3334 var commandStub = new Mock<AdomdDiscoveryCommand>("connectionString");35 commandStub.Setup(f => f.Execute())36 .Returns(elements);3738 var factoryMock = new Mock<AdomdDiscoveryCommandFactory>();39 factoryMock.Setup(f => f.BuildExact(request))40 .Returns(commandStub.Object);41 var factory = factoryMock.Object;4243 var containsConstraint = new ContainConstraint(exp) { CommandFactory = factory };4445 //Method under test46 containsConstraint.Matches(request);4748 //Test conclusion 49 factoryMock.Verify(f => f.BuildExact(request), Times.Once());50 }5152 [Test]53 public void Matches_GivenDiscoveryRequest_CommandCalledOnceWithParametersComingFromDiscoveryCommand()54 {55 var exp = "Expected measure";56 var request = new DiscoveryRequestFactory().BuildDirect(57 "connectionString",58 DiscoveryTarget.MeasureGroups,59 new List<IFilter>()60 {61 new CaptionFilter("perspective-name", DiscoveryTarget.Perspectives)62 , new CaptionFilter("measure-group", DiscoveryTarget.MeasureGroups)63 });646566 var elStub = new Mock<IField>();67 var el1 = elStub.Object;68 var el2 = elStub.Object;69 var elements = new List<IField>();70 elements.Add(el1);71 elements.Add(el2);7273 var commandMock = new Mock<AdomdDiscoveryCommand>("connectionString");74 commandMock.Setup(f => f.Execute())75 .Returns(elements);7677 var factoryStub = new Mock<AdomdDiscoveryCommandFactory>();78 factoryStub.Setup(f => f.BuildExact(request))79 .Returns(commandMock.Object);80 var factory = factoryStub.Object;8182 var containsConstraint = new ContainConstraint(exp) { CommandFactory = factory };8384 //Method under test85 containsConstraint.Matches(request);8687 //Test conclusion 88 commandMock.Verify(c => c.Execute(), Times.Once());89 }9091 [Test]92 public void WriteTo_FailingAssertionForOneDimension_TextContainsFewKeyInfo()93 {94 var exp = "Expected hierarchy";95 var request = new DiscoveryRequestFactory().BuildDirect(96 "connectionString",97 DiscoveryTarget.Dimensions,98 new List<IFilter>()99 {100 new CaptionFilter("perspective-name", DiscoveryTarget.Perspectives)101 , new CaptionFilter("dimension-caption", DiscoveryTarget.Dimensions)102 });103104105 var elStub = new Mock<IField>();106 var el1 = elStub.Object;107 var el2 = elStub.Object;108 var elements = new List<IField>();109 elements.Add(el1);110 elements.Add(el2);111112 var commandStub = new Mock<AdomdDiscoveryCommand>("connectionString");113 commandStub.Setup(f => f.Execute())114 .Returns(elements);115116 var factoryStub = new Mock<AdomdDiscoveryCommandFactory>();117 factoryStub.Setup(f => f.BuildExact(request))118 .Returns(commandStub.Object);119 var factory = factoryStub.Object;120121 var containsConstraint = new ContainConstraint(exp) { CommandFactory = factory };122123 //Method under test124 string assertionText = null;125 try126 {127 Assert.That(request, containsConstraint);128 }129 catch (AssertionException ex)130 {131 assertionText = ex.Message;132 }133134 //Test conclusion 135 Assert.That(assertionText, Is.StringContaining("perspective-name").And136 .StringContaining("dimension-caption").And137 .StringContaining("Expected hierarchy"));138 }139140 [Test]141 public void WriteTo_FailingAssertionForOneMeasureGroup_TextContainsFewKeyInfo()142 {143 var exp = "Expected measure";144 var request = new DiscoveryRequestFactory().BuildDirect(145 "connectionString",146 DiscoveryTarget.MeasureGroups,147 new List<IFilter>()148 {149 new CaptionFilter("perspective-name", DiscoveryTarget.Perspectives)150 , new CaptionFilter("measure-group-caption", DiscoveryTarget.MeasureGroups)151 });152153154 var elStub = new Mock<IField>();155 var el1 = elStub.Object;156 var el2 = elStub.Object;157 var elements = new List<IField>();158 elements.Add(el1);159 elements.Add(el2);160161 var commandStub = new Mock<AdomdDiscoveryCommand>("connectionString");162 commandStub.Setup(f => f.Execute())163 .Returns(elements);164165 var factoryStub = new Mock<AdomdDiscoveryCommandFactory>();166 factoryStub.Setup(f => f.BuildExact(request))167 .Returns(commandStub.Object);168 var factory = factoryStub.Object;169170 var containsConstraint = new ContainConstraint(exp) { CommandFactory = factory };171172 //Method under test173 string assertionText = null;174 try175 {176 Assert.That(request, containsConstraint);177 }178 catch (AssertionException ex)179 {180 assertionText = ex.Message;181 }182183 //Test conclusion 184 Assert.That(assertionText, Is.StringContaining("perspective-name").And185 .StringContaining("measure-group-caption").And186 .StringContaining("Expected measure"));187 }188189 [Test]190 public void WriteTo_FailingAssertionForOneHierarchy_TextContainsFewKeyInfo()191 {192 var exp = "Expected level";193 var request = new DiscoveryRequestFactory().BuildDirect(194 "connectionString",195 DiscoveryTarget.Hierarchies,196 new List<IFilter>()197 {198 new CaptionFilter("perspective-name", DiscoveryTarget.Perspectives)199 , new CaptionFilter("dimension-caption", DiscoveryTarget.Dimensions)200 , new CaptionFilter("hierarchy-caption", DiscoveryTarget.Hierarchies)201 });202203204 var elStub = new Mock<IField>();205 var el1 = elStub.Object;206 var el2 = elStub.Object;207 var elements = new List<IField>();208 elements.Add(el1);209 elements.Add(el2);210211 var commandStub = new Mock<AdomdDiscoveryCommand>("connectionString");212 commandStub.Setup(f => f.Execute())213 .Returns(elements);214215 var factoryStub = new Mock<AdomdDiscoveryCommandFactory>();216 factoryStub.Setup(f => f.BuildExact(request))217 .Returns(commandStub.Object);218 var factory = factoryStub.Object;219220 var containsConstraint = new ContainConstraint(exp) { CommandFactory = factory };221222 //Method under test223 string assertionText = null;224 try225 {226 Assert.That(request, containsConstraint);227 }228 catch (AssertionException ex)229 {230 assertionText = ex.Message;231 }232233 //Test conclusion 234 Assert.That(assertionText, Is.StringContaining("perspective-name").And235 .StringContaining("dimension-caption").And236 .StringContaining("hierarchy-caption").And237 .StringContaining("Expected level"));238 }239240 [Test]241 public void WriteTo_FailingAssertionForMultipleHierarchies_TextContainsFewKeyInfo()242 {243 var exp = new List<string>();244 exp.Add("Expected h1");245 exp.Add("Expected h2");246247 var request = new DiscoveryRequestFactory().BuildDirect(248 "connectionString",249 DiscoveryTarget.Hierarchies,250 new List<IFilter>()251 {252 new CaptionFilter("perspective-name", DiscoveryTarget.Perspectives)253 , new CaptionFilter("dimension-caption", DiscoveryTarget.Dimensions)254 });255256257 var elStub = new Mock<IField>();258 var el1 = elStub.Object;259 var el2 = elStub.Object;260 var elements = new List<IField>();261 elements.Add(el1); ...

Full Screen

Full Screen

AdomdDiscoveryCommandTest.cs

Source:AdomdDiscoveryCommandTest.cs Github

copy

Full Screen

...13 {14 [Test]15 public void Execute_DateDimensionWithHeighTeenHierarchies_ListStructureContainingHeighTeenElements()16 {17 var disco = new DiscoveryRequestFactory().BuildDirect(18 ConnectionStringReader.GetAdomd(),19 DiscoveryTarget.Hierarchies,20 new List<IFilter>() { 21 new CaptionFilter("Adventure Works", DiscoveryTarget.Perspectives),22 new CaptionFilter("Date", DiscoveryTarget.Dimensions)23 });2425 var factory = new AdomdDiscoveryCommandFactory();26 var cmd = factory.BuildExact(disco);2728 var structs = cmd.Execute();2930 Assert.That(structs.Count(), Is.EqualTo(18));31 }3233 [Test]34 public void Execute_TabularDateDimensionWithHeighTeenHierarchies_ListStructureContainingSevenTeenElements()35 {36 var disco = new DiscoveryRequestFactory().BuildDirect(37 ConnectionStringReader.GetAdomdTabular(),38 DiscoveryTarget.Hierarchies,39 new List<IFilter>() { 40 new CaptionFilter("Internet Operation", DiscoveryTarget.Perspectives),41 new CaptionFilter("Date", DiscoveryTarget.Dimensions)42 });4344 var factory = new AdomdDiscoveryCommandFactory();45 var cmd = factory.BuildExact(disco);4647 var structs = cmd.Execute();4849 Assert.That(structs.Count(), Is.EqualTo(17));50 }5152 [Test]53 public void GetPartialMetadata_CalendarHierarchyWithSixLevels_ListStructureContainingSixElements()54 {55 var disco = new DiscoveryRequestFactory().BuildDirect(56 ConnectionStringReader.GetAdomd(),57 DiscoveryTarget.Levels,58 new List<IFilter>() { 59 new CaptionFilter("Adventure Works", DiscoveryTarget.Perspectives),60 new CaptionFilter("Date", DiscoveryTarget.Dimensions),61 new CaptionFilter("Calendar", DiscoveryTarget.Hierarchies)62 });6364 var factory = new AdomdDiscoveryCommandFactory();65 var cmd = factory.BuildExact(disco);6667 var structs = cmd.Execute();6869 Assert.That(structs.Count(), Is.EqualTo(6));70 }7172 [Test]73 public void GetPartialMetadata_TabularCalendarHierarchyWithSixLevels_ListStructureContainingSixElements()74 {75 var disco = new DiscoveryRequestFactory().BuildDirect(76 ConnectionStringReader.GetAdomdTabular(),77 DiscoveryTarget.Levels,78 new List<IFilter>() { 79 new CaptionFilter("Internet Operation", DiscoveryTarget.Perspectives),80 new CaptionFilter("Date", DiscoveryTarget.Dimensions),81 new CaptionFilter("Calendar", DiscoveryTarget.Hierarchies)82 });8384 var factory = new AdomdDiscoveryCommandFactory();85 var cmd = factory.BuildExact(disco);8687 var structs = cmd.Execute();8889 Assert.That(structs.Count(), Is.EqualTo(6));90 }9192 [Test]93 public void GetPartialMetadata_MonthLevelWithTwoProperties_ListStructureContainingTwoElements()94 {95 var disco = new DiscoveryRequestFactory().BuildDirect(96 ConnectionStringReader.GetAdomd(),97 DiscoveryTarget.Properties,98 new List<IFilter>() { 99 new CaptionFilter("Adventure Works", DiscoveryTarget.Perspectives),100 new CaptionFilter("Date", DiscoveryTarget.Dimensions),101 new CaptionFilter("Calendar", DiscoveryTarget.Hierarchies),102 new CaptionFilter("Month", DiscoveryTarget.Levels)103 });104105 var factory = new AdomdDiscoveryCommandFactory();106 var cmd = factory.BuildExact(disco);107108 var structs = cmd.Execute();109110 Assert.That(structs.Count(), Is.EqualTo(2));111 }112113 [Test]114 public void GetPartialMetadata_TabularMonthLevelWithTwoProperties_ListStructureContainingNoElement()115 {116 var disco = new DiscoveryRequestFactory().BuildDirect(117 ConnectionStringReader.GetAdomdTabular(),118 DiscoveryTarget.Properties,119 new List<IFilter>() { 120 new CaptionFilter("Internet Operations", DiscoveryTarget.Perspectives),121 new CaptionFilter("Date", DiscoveryTarget.Dimensions),122 new CaptionFilter("Calendar", DiscoveryTarget.Hierarchies),123 new CaptionFilter("Month", DiscoveryTarget.Levels)124 });125126 var factory = new AdomdDiscoveryCommandFactory();127 var cmd = factory.BuildExact(disco);128129 var structs = cmd.Execute();130131 Assert.That(structs.Count(), Is.EqualTo(0));132 }133134 [Test]135 public void GetPartialMetadata_MeasureGroupsForCubeFinance_OneElement()136 {137 var disco = new DiscoveryRequestFactory().BuildDirect(138 ConnectionStringReader.GetAdomd(),139 DiscoveryTarget.MeasureGroups,140 new List<IFilter>() { 141 new CaptionFilter("Finance", DiscoveryTarget.Perspectives),142 });143144 var factory = new AdomdDiscoveryCommandFactory();145 var cmd = factory.BuildExact(disco);146147 var structs = cmd.Execute();148149 Assert.That(structs.Count(), Is.EqualTo(2));150 }151152 [Test]153 public void GetPartialMetadata_TabularMeasureGroupsForInternetOperation_ThreeElements()154 {155 var disco = new DiscoveryRequestFactory().BuildDirect(156 ConnectionStringReader.GetAdomdTabular(),157 DiscoveryTarget.MeasureGroups,158 new List<IFilter>() { 159 new CaptionFilter("Internet Operation", DiscoveryTarget.Perspectives),160 });161162 var factory = new AdomdDiscoveryCommandFactory();163 var cmd = factory.BuildExact(disco);164165 var structs = cmd.Execute();166167 Assert.That(structs.Count(), Is.EqualTo(3));168 }169 ...

Full Screen

Full Screen

SubsetOfConstraintTest.cs

Source:SubsetOfConstraintTest.cs Github

copy

Full Screen

...4142 [Test, Category("Olap cube")]43 public void Matches_ActualEqualToExpectation_Success()44 {45 var discovery = new DiscoveryRequestFactory().BuildDirect(46 ConnectionStringReader.GetAdomd()47 , DiscoveryTarget.Perspectives48 , new List<IFilter>());4950 var expected = new string[] { "Adventure Works", "Channel Sales", "Direct Sales", "Finance", "Mined Customers", "Sales Summary", "Sales Targets" };51 var ctr = new SubsetOfConstraint(expected);5253 //Method under test54 Assert.That(discovery, ctr);5556 }5758 [Test, Category("Olap cube")]59 public void Matches_ActualEqualToExpectationCaseNonMatching_Success()60 {61 var discovery = new DiscoveryRequestFactory().BuildDirect(62 ConnectionStringReader.GetAdomd()63 , DiscoveryTarget.Perspectives64 , new List<IFilter>());6566 var expected = new string[] { "Adventure Works".ToUpper(), "Channel Sales".ToLower(), "Direct Sales", "Finance", "Mined Customers", "Sales Summary", "Sales Targets" };67 var ctr = new SubsetOfConstraint(expected);68 ctr = ctr.IgnoreCase;6970 //Method under test71 Assert.That(discovery, ctr);7273 }7475 [Test, Category("Olap cube")]76 public void Matches_ActualMoreThanExpectation_Failure()77 {78 var discovery = new DiscoveryRequestFactory().BuildDirect(79 ConnectionStringReader.GetAdomd()80 , DiscoveryTarget.Perspectives81 , new List<IFilter>());8283 var expectedStrings = new string[] { "Adventure Works", "Channel Sales", "Direct Sales", "Finance", "Mined Customers", "Sales Summary", "Sales Targets" };84 var expected = new List<string>();85 expected.AddRange(expectedStrings);86 expected.RemoveAt(0);87 var ctr = new SubsetOfConstraint(expected);8889 //Method under test90 Assert.That(ctr.Matches(discovery), Is.False);9192 }9394 [Test, Category("Olap cube")]95 public void Matches_ActualSubsetOfExpectation_Sucess()96 {97 var discovery = new DiscoveryRequestFactory().BuildDirect(98 ConnectionStringReader.GetAdomd()99 , DiscoveryTarget.Perspectives100 , new List<IFilter>());101102 var expectedStrings = new string[] { "Adventure Works", "Channel Sales", "Direct Sales", "Finance", "Mined Customers", "Sales Summary", "Sales Targets" };103 var expected = new List<string>();104 expected.AddRange(expectedStrings);105 expected.Add("New perspective");106 var ctr = new SubsetOfConstraint(expected);107108 //Method under test109 Assert.That(ctr.Matches(discovery), Is.True);110111 } ...

Full Screen

Full Screen

BuildDirect

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NBi.Core.Analysis.Request;7using NBi.Core.Analysis.Metadata;8using NBi.Core.Analysis.Member;9using NBi.Core.Analysis.Member.Alias;10using NBi.Core.Analysis.Member.Factory;11using NBi.Core.Analysis.Metadata.Adomd;12using NBi.Core.Analysis.Request.Adomd;13using NBi.Xml.Items;14using NBi.Xml.Items.Calculation;15using NBi.Xml.Items.ResultSet;16using NBi.Xml.Settings;17{18 {19 public static DiscoveryRequest BuildDirect(DiscoveryRequestXml requestXml)20 {21 var request = new DiscoveryRequest();22 var connectionString = new AdomdConnectionStringBuilder();23 connectionString.ConnectionString = requestXml.ConnectionString;24 request.ConnectionString = connectionString;25 request.Metadata = BuildMetadata(requestXml);26 request.Filters = BuildFilters(requestXml);27 request.Members = BuildMembers(requestXml);28 request.Calculations = BuildCalculations(requestXml);29 request.ResultSet = BuildResultSet(requestXml);30 request.Settings = BuildSettings(requestXml);31 return request;32 }33 private static DiscoveryRequestMetadata BuildMetadata(DiscoveryRequestXml requestXml)34 {35 var metadata = new DiscoveryRequestMetadata();36 metadata.Cube = requestXml.CubeName;37 metadata.Dimension = requestXml.DimensionName;38 return metadata;39 }40 private static DiscoveryRequestFilters BuildFilters(DiscoveryRequestXml requestXml)41 {42 var filters = new DiscoveryRequestFilters();43 if (requestXml.Filters != null)44 foreach (var filterXml in requestXml.Filters)45 {46 var filter = new DiscoveryRequestFilter();47 filter.Type = filterXml.Type;48 filter.Operator = filterXml.Operator;49 filter.Value = filterXml.Value;50 filter.IsCaseSensitive = filterXml.IsCaseSensitive;51 filter.IsRegex = filterXml.IsRegex;52 filters.Add(filter);53 }54 return filters;55 }56 private static DiscoveryRequestMembers BuildMembers(DiscoveryRequestXml requestXml)57 {58 var members = new DiscoveryRequestMembers();59 if (requestXml.Members != null)60 foreach (var memberXml

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run NBi automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in DiscoveryRequestFactory

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful