Best NBi code snippet using NBi.Core.Report.ReportDataSetRequest.ReportDataSetRequest
FileReportingParserTest.cs
Source:FileReportingParserTest.cs
...58 }59 [Test]60 public void ExtractQuery_ExistingReportAndDataSet_CorrectQueryReturned()61 {62 var request = new ReportDataSetRequest(63 string.Empty64 , ReportFileDirectory65 , "Currency_List"66 , "Currency"67 );68 var parser = new FileReportingParser();69 var query = parser.ExtractCommand(request);70 Assert.That(query.Text,71 Does.Contain("SELECT").And72 .Contain("[CurrencyAlternateKey]").And73 .Contain("[DimCurrency]"));74 Assert.That(query.CommandType, Is.EqualTo(CommandType.Text));75 }76 [Test]77 public void ExtractQuery_NonExistingDataSetOneExisting_CorrectExceptionReturned()78 {79 var request = new ReportDataSetRequest(80 string.Empty81 , ReportFileDirectory82 , "Currency_List"83 , "Non Existing"84 );85 var parser = new FileReportingParser();86 var ex = Assert.Throws<ArgumentException>(() => parser.ExtractCommand(request));87 Assert.That(ex.Message, Does.Contain("'Currency'"));88 }89 [Test]90 public void ExtractQuery_NonExistingDataSetMoreThanOneExisting_CorrectExceptionReturned()91 {92 var request = new NBi.Core.Report.ReportDataSetRequest(93 string.Empty94 , ReportFileDirectory95 , "Currency_Rates"96 , "Non Existing"97 );98 var parser = new FileReportingParser();99 var ex = Assert.Throws<ArgumentException>(() => parser.ExtractCommand(request));100 Assert.That(ex.Message, Does.Contain("DataSet1").And.Contain("DataSet2"));101 }102 [Test]103 public void ExtractQuery_NonExistingReport_CorrectExceptionReturned()104 {105 var request = new NBi.Core.Report.ReportDataSetRequest(106 string.Empty107 , ReportFileDirectory108 , "Not Existing"109 , "DataSet1"110 );111 var parser = new FileReportingParser();112 var ex = Assert.Throws<ArgumentException>(() => parser.ExtractCommand(request));113 Assert.That(ex.Message, Does.Contain("No report found"));114 }115 [Test]116 public void ExtractQuery_ExistingReportAndSharedDataSet_CorrectQueryReturned()117 {118 var request = new NBi.Core.Report.ReportDataSetRequest(119 string.Empty120 , ReportFileDirectory121 , "Employee_Sales_Summary"122 , "SalesEmployees2008R2"123 );124 var parser = new FileReportingParser();125 var query = parser.ExtractCommand(request);126 Assert.That(query.Text,127 Does.Contain("SELECT").And128 .Contain("[Sales].[SalesPerson]").And129 .Contain("[HumanResources].[Employee]"));130 Assert.That(query.CommandType, Is.EqualTo(CommandType.Text));131 }132 [Test]133 public void ExtractQuery_ExistingSharedDataSet_CorrectQueryReturned()134 {135 var request = new SharedDatasetRequest(136 string.Empty137 , ReportFileDirectory138 , "SalesEmployees"139 );140 var parser = new FileReportingParser();141 var query = parser.ExtractCommand(request);142 Assert.That(query.Text,143 Does.Contain("SELECT").And144 .Contain("[Sales].[SalesPerson]").And145 .Contain("[HumanResources].[Employee]"));146 Assert.That(query.CommandType, Is.EqualTo(CommandType.Text));147 }148 [Test]149 public void ExtractSProc_ExistingReport_CorrectSProcReturned()150 {151 var request = new NBi.Core.Report.ReportDataSetRequest(152 string.Empty153 , ReportFileDirectory154 , "Currency_List - SProc"155 , "Currency"156 );157 var parser = new FileReportingParser();158 var query = parser.ExtractCommand(request);159 Assert.That(query.Text,160 Is.EqualTo("usp_CurrencyGetAll"));161 Assert.That(query.CommandType, Is.EqualTo(CommandType.StoredProcedure));162 }163 }164}...
DatabaseReportingParserTest.cs
Source:DatabaseReportingParserTest.cs
...43 #endregion44 [Test]45 public void ExtractQuery_ExistingReportAndDataSet_CorrectQueryReturned()46 {47 var request = new ReportDataSetRequest( 48 ConnectionStringReader.GetReportServerDatabase()49 , "/AdventureWorks Sample Reports/"50 , "Currency_List"51 ,"Currency" 52 );53 var parser = new DatabaseReportingParser();54 var query = parser.ExtractCommand(request);55 Assert.That(query.Text, 56 Does.Contain("SELECT").And57 .StringContaining("[CurrencyAlternateKey]").And58 .StringContaining("[DimCurrency]"));59 Assert.That(query.CommandType, Is.EqualTo(CommandType.Text));60 }61 [Test]62 public void ExtractQuery_NonExistingDataSetOneExisting_CorrectExceptionReturned()63 {64 var request = new ReportDataSetRequest(65 ConnectionStringReader.GetReportServerDatabase()66 , "/AdventureWorks Sample Reports/"67 , "Currency_List"68 , "Non Existing"69 );70 var parser = new DatabaseReportingParser();71 var ex = Assert.Throws<ArgumentException>(()=> parser.ExtractCommand(request));72 Assert.That(ex.Message, Does.Contain("'Currency_List'"));73 }74 [Test]75 public void ExtractQuery_NonExistingDataSetMoreThanOneExisting_CorrectExceptionReturned()76 {77 var request = new ReportDataSetRequest(78 ConnectionStringReader.GetReportServerDatabase()79 , "/AdventureWorks Sample Reports/"80 , "Currency Rates"81 , "Non Existing"82 );83 var parser = new DatabaseReportingParser();84 var ex = Assert.Throws<ArgumentException>(() => parser.ExtractCommand(request));85 Assert.That(ex.Message, Does.Contain("DataSet1").And.StringContaining("DataSet2"));86 }87 [Test]88 public void ExtractQuery_NonExistingReport_CorrectExceptionReturned()89 {90 var request = new ReportDataSetRequest(91 ConnectionStringReader.GetReportServerDatabase()92 , "/AdventureWorks Sample Reports/"93 , "Not Existing"94 , "DataSet1"95 );96 var parser = new DatabaseReportingParser();97 var ex = Assert.Throws<ArgumentException>(() => parser.ExtractCommand(request));98 Assert.That(ex.Message, Does.Contain("No report found"));99 }100 [Test]101 public void ExtractQuery_SharedDataSetViaReport_CorrectQuery()102 {103 var request = new ReportDataSetRequest(104 ConnectionStringReader.GetReportServerDatabase()105 , "/AdventureWorks Sample Reports/"106 , "Employee_Sales_Summary"107 , "EmpSalesMonth"108 );109 var parser = new DatabaseReportingParser();110 var query = parser.ExtractCommand(request);111 Assert.That(query.Text,112 Does.Contain("SELECT"));113 Assert.That(query.CommandType, Is.EqualTo(CommandType.Text));114 }115 [Test]116 public void ExtractQuery_NonExistingSharedDataSet_CorrectQuery()117 {118 var request = new ReportDataSetRequest(119 ConnectionStringReader.GetReportServerDatabase()120 , "/AdventureWorks Sample Reports/"121 , "Employee_Sales_Summary"122 , "NonExisting"123 );124 var parser = new DatabaseReportingParser();125 var ex = Assert.Throws<ArgumentException>(() => parser.ExtractCommand(request));126 Assert.That(ex.Message, Does.Contain("Quota").And.StringContaining("EmpSalesMonth"));127 }128 [Test]129 public void ExtractQuery_SharedDataSet_CorrectQuery()130 {131 var request = new SharedDatasetRequest(132 ConnectionStringReader.GetReportServerDatabase()...
ReportDataSetQueryResolverTest.cs
Source:ReportDataSetQueryResolverTest.cs
...27 [Test]28 public void Execute_Args_CommandInstantiated()29 {30 var reportingParserStub = new Mock<IReportingParser>();31 reportingParserStub.Setup(x => x.ExtractCommand(It.IsAny<ReportDataSetRequest>())).Returns(32 new ReportingCommand() { Text = "select * from myTable;", CommandType = CommandType.Text });33 var factoryStub = new Mock<ReportingParserFactory>();34 factoryStub.Setup(x => x.Instantiate(It.IsAny<string>())).Returns(reportingParserStub.Object);35 var resolver = new ReportDataSetQueryResolver(BuildArgs(), factoryStub.Object);36 var cmd = resolver.Execute();37 Assert.That(cmd, Is.Not.Null);38 }39 [Test]40 public void Execute_Args_ConnectionStringAssigned()41 {42 var reportingParserStub = new Mock<IReportingParser>();43 reportingParserStub.Setup(x => x.ExtractCommand(It.IsAny<ReportDataSetRequest>())).Returns(44 new ReportingCommand() { Text = "select * from myTable;", CommandType = CommandType.Text });45 var factoryStub = new Mock<ReportingParserFactory>();46 factoryStub.Setup(x => x.Instantiate(It.IsAny<string>())).Returns(reportingParserStub.Object);47 var resolver = new ReportDataSetQueryResolver(BuildArgs(), factoryStub.Object);48 var query = resolver.Execute();49 Assert.That(query.ConnectionString, Is.Not.Null.And.Not.Empty);50 Assert.That(query.ConnectionString, Is.EqualTo(ConnectionStringReader.GetSqlClient()));51 }52 [Test]53 public void Execute_Args_CommandTextAssigned()54 {55 var reportingParserStub = new Mock<IReportingParser>();56 reportingParserStub.Setup(x => x.ExtractCommand(It.IsAny<ReportDataSetRequest>())).Returns(57 new ReportingCommand() { Text = "select * from myTable;", CommandType = CommandType.Text });58 var factoryStub = new Mock<ReportingParserFactory>();59 factoryStub.Setup(x => x.Instantiate(It.IsAny<string>())).Returns(reportingParserStub.Object);60 var resolver = new ReportDataSetQueryResolver(BuildArgs(), factoryStub.Object);61 var query = resolver.Execute();62 Assert.That(query.Statement, Is.EqualTo("select * from myTable;"));63 }64 [Test]65 public void Execute_Args_CommandTypeAssigned()66 {67 var reportingParserStub = new Mock<IReportingParser>();68 reportingParserStub.Setup(x => x.ExtractCommand(It.IsAny<ReportDataSetRequest>())).Returns(69 new ReportingCommand() { Text = "myStoredProcedure", CommandType = CommandType.StoredProcedure });70 var factoryStub = new Mock<ReportingParserFactory>();71 factoryStub.Setup(x => x.Instantiate(It.IsAny<string>())).Returns(reportingParserStub.Object);72 var resolver = new ReportDataSetQueryResolver(BuildArgs(), factoryStub.Object);73 var query = resolver.Execute();74 Assert.That(query.Statement, Is.EqualTo("myStoredProcedure"));75 Assert.That(query.CommandType, Is.EqualTo(CommandType.StoredProcedure));76 }77 public void Execute_Args_ReportingParserCalledOnce()78 {79 var reportingParserMock = new Mock<IReportingParser>();80 reportingParserMock.Setup(x => x.ExtractCommand(It.IsAny<ReportDataSetRequest>())).Returns(81 new ReportingCommand() { Text = "myStoredProcedure", CommandType = CommandType.StoredProcedure });82 var factoryStub = new Mock<ReportingParserFactory>();83 factoryStub.Setup(x => x.Instantiate(It.IsAny<string>())).Returns(reportingParserMock.Object);84 var resolver = new ReportDataSetQueryResolver(BuildArgs(), factoryStub.Object);85 var query = resolver.Execute();86 reportingParserMock.Verify(x => x.ExtractCommand(It.IsAny<ReportDataSetRequest>()), Times.Once);87 }88 [Test]89 public void Execute_Args_ParametersAssigned()90 {91 var reportingParserStub = new Mock<IReportingParser>();92 reportingParserStub.Setup(x => x.ExtractCommand(It.IsAny<ReportDataSetRequest>())).Returns(93 new ReportingCommand() { Text = "select * from myTable;", CommandType = CommandType.Text });94 var factoryStub = new Mock<ReportingParserFactory>();95 factoryStub.Setup(x => x.Instantiate(It.IsAny<string>())).Returns(reportingParserStub.Object);96 var resolver = new ReportDataSetQueryResolver(BuildArgs(), factoryStub.Object);97 var query = resolver.Execute();98 Assert.That(query.Parameters, Has.Count.EqualTo(1));99 }100 }101}...
ReportDataSetRequest
Using AI Code Generation
1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NBi.Core.Report;7using System.Data;8{9 {10 static void Main(string[] args)11 {12 ReportDataSetRequest reportDataSetRequest = new ReportDataSetRequest();13 DataTable dt = reportDataSetRequest.Request("C:\\Users\\Public\\Documents\\Report.rdl", "Table1", "SQL Server", "Server=.;Database=AdventureWorks2012;Trusted_Connection=True;");14 foreach (DataRow dr in dt.Rows)15 {16 foreach (DataColumn dc in dt.Columns)17 {18 Console.WriteLine(dr[dc].ToString());19 }20 }21 Console.ReadLine();22 }23 }24}
ReportDataSetRequest
Using AI Code Generation
1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NBi.Core.Report;7using System.Data;8{9 {10 static void Main(string[] args)11 {12 ReportDataSetRequest reportDataSetRequest = new ReportDataSetRequest();13 reportDataSetRequest.ReportPath = "C:\\Users\\username\\Documents\\Visual Studio 2013\\Projects\\ReportDataSetRequest\\ReportDataSetRequest\\Report1.rdlc";14 reportDataSetRequest.ReportServerCredential = System.Net.CredentialCache.DefaultCredentials;15 reportDataSetRequest.ReportParameters = new Dictionary<string, string>();16 reportDataSetRequest.ReportParameters.Add("startDate", "2014-01-01");17 reportDataSetRequest.ReportParameters.Add("endDate", "2014-12-31");18 reportDataSetRequest.ReportParameters.Add("reportType", "1");19 reportDataSetRequest.ReportParameters.Add("customerID", "1");20 var result = reportDataSetRequest.Execute();21 }22 }23}24using System;25using System.Collections.Generic;26using System.Linq;27using System.Text;28using System.Threading.Tasks;29using NBi.Core.Report;30using System.Data;31{32 {33 static void Main(string[] args)34 {35 ReportDataSetRequest reportDataSetRequest = new ReportDataSetRequest();36 reportDataSetRequest.ReportPath = "C:\\Users\\username\\Documents\\Visual Studio 2013\\Projects\\ReportDataSetRequest\\ReportDataSetRequest\\Report1.rdlc";37 reportDataSetRequest.ReportServerCredential = System.Net.CredentialCache.DefaultCredentials;38 reportDataSetRequest.ReportParameters = new Dictionary<string, string>();39 reportDataSetRequest.ReportParameters.Add("startDate", "2014-01-01");40 reportDataSetRequest.ReportParameters.Add("endDate", "2014-12-31");41 reportDataSetRequest.ReportParameters.Add("reportType", "1");42 reportDataSetRequest.ReportParameters.Add("customerID", "1");43 var result = reportDataSetRequest.Execute();44 foreach (DataTable dt in result.Tables)45 {46 Console.WriteLine(dt.TableName);47 foreach (DataColumn col in dt.Columns
ReportDataSetRequest
Using AI Code Generation
1using NBi.Core.Report;2using System;3using System.Collections.Generic;4using System.Data;5using System.Linq;6using System.Text;7using System.Threading.Tasks;8{9 {10 public string ReportPath { get; set; }11 public string DatasetName { get; set; }12 public IDictionary<string, object> Parameters { get; set; }13 public IDictionary<string, object> Variables { get; set; }14 public string ConnectionString { get; set; }15 public string DataSource { get; set; }16 public string Provider { get; set; }17 public string CommandType { get; set; }18 public string CommandText { get; set; }19 public string CommandTimeout { get; set; }20 public ReportDataSetRequest()21 {22 Parameters = new Dictionary<string, object>();23 Variables = new Dictionary<string, object>();24 }25 public ReportDataSetRequest(string reportPath, string datasetName)26 : this()27 {28 ReportPath = reportPath;29 DatasetName = datasetName;30 }31 public ReportDataSetRequest(string reportPath, string datasetName, IDictionary<string, object> parameters)32 : this(reportPath, datasetName)33 {34 Parameters = parameters;35 }36 public ReportDataSetRequest(string reportPath, string datasetName, IDictionary<string, object> parameters, IDictionary<string, object> variables)37 : this(reportPath, datasetName, parameters)38 {39 Variables = variables;40 }41 public ReportDataSetRequest(string reportPath, string datasetName, IDictionary<string, object> parameters, IDictionary<string, object> variables, string connectionString, string dataSource, string provider, string commandType, string commandText, string commandTimeout)42 : this(reportPath, datasetName, parameters, variables)43 {44 ConnectionString = connectionString;45 DataSource = dataSource;46 Provider = provider;47 CommandType = commandType;48 CommandText = commandText;49 CommandTimeout = commandTimeout;50 }51 }52}53using NBi.Core.Report;54using System;55using System.Collections.Generic;56using System.Data;57using System.Linq;58using System.Text;59using System.Threading.Tasks;60{61 {62 public string ReportPath { get; set; }
ReportDataSetRequest
Using AI Code Generation
1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NBi.Core.Report;7using NBi.Core.Report.DataSet;8using NBi.Core.Report.DataSet.Xml;9using NBi.Core.Report.DataSet.Csv;10using NBi.Core.Report.DataSet.Excel;11using NBi.Core.Report.DataSet.Json;12using NBi.Core.Report.DataSet.SqlServer;13using NBi.Core.Report.DataSet.SqlServerCe;14using NBi.Core.Report.DataSet.Sparql;15using NBi.Core.Report.DataSet.Tsv;16using NBi.Core.Report.DataSet.TsvUnicode;17using NBi.Core.Report.DataSet.TsvUnicodeBom;
ReportDataSetRequest
Using AI Code Generation
1using NBi.Core.Report;2using NBi.Core.Report.Dump;3using NBi.Core.Report.Dump.Providers;4using NBi.Core.Report.Dump.Providers.Powershell;5using System;6using System.Collections.Generic;7using System.Data;8using System.Linq;9using System.Text;10using System.Threading.Tasks;11{12 {13 public string ReportPath { get; set; }14 public string DataSetName { get; set; }15 public string DataSourceName { get; set; }16 public string DataSourceUsername { get; set; }17 public string DataSourcePassword { get; set; }18 public string DataSourceDomain { get; set; }19 public string DataSourceImpersonate { get; set; }20 public string DataSourceImpersonateUsername { get; set; }21 public string DataSourceImpersonatePassword { get; set; }22 public string DataSourceImpersonateDomain { get; set; }23 public string DataSourceImpersonatePasswordType { get; set; }24 public string DataSourceImpersonatePasswordValue { get; set; }25 public string DataSourceImpersonatePasswordPrompt { get; set; }26 public string DataSourceImpersonatePasswordPromptTitle { get; set; }27 public string DataSourceImpersonatePasswordPromptMessage { get; set; }28 public string DataSourceImpersonatePasswordPromptShowUserName { get; set; }29 public string DataSourceImpersonatePasswordPromptShowDomain { get; set; }30 public string DataSourceImpersonatePasswordPromptShowPassword { get; set; }31 public string DataSourceImpersonatePasswordPromptShowSaveCheckBox { get; set; }32 public string DataSourceImpersonatePasswordPromptSaveChecked { get; set; }33 public string DataSourceImpersonatePasswordPromptAlwaysDisplay { get; set; }34 public string DataSourceImpersonatePasswordPromptWindowStyle { get; set; }35 public string DataSourceImpersonatePasswordPromptStartPosition { get; set; }36 public string DataSourceImpersonatePasswordPromptDefaultButton { get; set; }37 public string DataSourceImpersonatePasswordPromptCancelButton { get; set; }38 public string DataSourceImpersonatePasswordPromptHelpButton { get; set; }39 public string DataSourceImpersonatePasswordPromptTimeout { get; set; }
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!!