How to use ColumnAggregationArgs class of NBi.Core.ResultSet.Alteration.Summarization package

Best NBi code snippet using NBi.Core.ResultSet.Alteration.Summarization.ColumnAggregationArgs

SummarizeEngineTest.cs

Source:SummarizeEngineTest.cs Github

copy

Full Screen

...41 public void Execute_SingleKeySingleAggregation_ExpectedResultSet()42 {43 var rs = Build();44 var args = new SummarizeArgs(45 new List<ColumnAggregationArgs>()46 { new ColumnAggregationArgs(new ColumnNameIdentifier("valueColumn"), AggregationFunctionType.Sum, ColumnType.Numeric, null) },47 new List<IColumnDefinitionLight>()48 { Mock.Of<IColumnDefinitionLight>(x => x.Identifier == new ColumnNameIdentifier("keyColumn") && x.Type == ColumnType.Text) }49 );50 var summarize = new SummarizeEngine(args);51 var result = summarize.Execute(rs);52 Assert.That(result, Is.Not.Null);53 Assert.That(result.Columns.Count, Is.EqualTo(2));54 Assert.That(result.Rows.Cast<DataRow>().Any(x => x["keyColumn"] as string == "alpha"));55 Assert.That(result.Rows.Cast<DataRow>().Any(x => x["keyColumn"] as string == "beta"));56 Assert.That(result.Rows.Count, Is.EqualTo(2));57 Assert.That(Convert.ToInt32(result.Rows.Cast<DataRow>().Single(x => x["keyColumn"] as string == "alpha")["valueColumn"]) == 7);58 Assert.That(Convert.ToInt32(result.Rows.Cast<DataRow>().Single(x => x["keyColumn"] as string == "beta")["valueColumn"]) == 3);59 }60 [Test]61 public void Execute_MultipleKeySingleAggregation_ExpectedResultSet()62 {63 var rs = new ObjectsResultSetResolver(64 new ObjectsResultSetResolverArgs(65 new[] { new object[] { "alpha", "foo", 1 }, new object[] { "alpha", "foo", 2 }, new object[] { "beta", "foo", 3 }, new object[] { "alpha", "bar", 4 } })66 ).Execute();67 rs.Columns[0].ColumnName = "ColumnA";68 rs.Columns[1].ColumnName = "ColumnB";69 rs.Columns[2].ColumnName = "valueColumn";70 var args = new SummarizeArgs(71 new List<ColumnAggregationArgs>()72 { new ColumnAggregationArgs(new ColumnNameIdentifier("valueColumn"), AggregationFunctionType.Sum, ColumnType.Numeric, null) },73 new List<IColumnDefinitionLight>()74 {75 Mock.Of<IColumnDefinitionLight>(x => x.Identifier == new ColumnNameIdentifier("ColumnA") && x.Type == ColumnType.Text),76 Mock.Of<IColumnDefinitionLight>(x => x.Identifier == new ColumnNameIdentifier("ColumnB") && x.Type == ColumnType.Text)77 }78 );79 var summarize = new SummarizeEngine(args);80 var result = summarize.Execute(rs);81 Assert.That(result, Is.Not.Null);82 Assert.That(result.Columns.Count, Is.EqualTo(3));83 Assert.That(result.Rows.Cast<DataRow>().Any(x => x["ColumnA"] as string == "alpha" && x["ColumnB"] as string == "foo"));84 Assert.That(result.Rows.Cast<DataRow>().Any(x => x["ColumnA"] as string == "beta" && x["ColumnB"] as string == "foo"));85 Assert.That(result.Rows.Cast<DataRow>().Any(x => x["ColumnA"] as string == "alpha" && x["ColumnB"] as string == "bar"));86 Assert.That(result.Rows.Count, Is.EqualTo(3));87 }88 [Test]89 public void Execute_MultipleKeyNonAlphabeticalOrderSingleAggregation_ExpectedResultSet()90 {91 var rs = new ObjectsResultSetResolver(92 new ObjectsResultSetResolverArgs(93 new[] { new object[] { "alpha", "foo", 1 }, new object[] { "alpha", "foo", 2 }, new object[] { "beta", "foo", 3 }, new object[] { "alpha", "bar", 4 } })94 ).Execute();95 rs.Columns[0].ColumnName = "ColumnB";96 rs.Columns[1].ColumnName = "ColumnA";97 rs.Columns[2].ColumnName = "valueColumn";98 var args = new SummarizeArgs(99 new List<ColumnAggregationArgs>()100 { new ColumnAggregationArgs(new ColumnNameIdentifier("valueColumn"), AggregationFunctionType.Sum, ColumnType.Numeric, null) },101 new List<IColumnDefinitionLight>()102 {103 Mock.Of<IColumnDefinitionLight>(x => x.Identifier == new ColumnNameIdentifier("ColumnB") && x.Type == ColumnType.Text),104 Mock.Of<IColumnDefinitionLight>(x => x.Identifier == new ColumnNameIdentifier("ColumnA") && x.Type == ColumnType.Text),105 }106 );107 var summarize = new SummarizeEngine(args);108 var result = summarize.Execute(rs);109 Assert.That(result, Is.Not.Null);110 Assert.That(result.Columns.Count, Is.EqualTo(3));111 Assert.That(result.Rows.Cast<DataRow>().Any(x => x["ColumnB"] as string == "alpha" && x["ColumnA"] as string == "foo"));112 Assert.That(result.Rows.Cast<DataRow>().Any(x => x["ColumnB"] as string == "beta" && x["ColumnA"] as string == "foo"));113 Assert.That(result.Rows.Cast<DataRow>().Any(x => x["ColumnB"] as string == "alpha" && x["ColumnA"] as string == "bar"));114 Assert.That(result.Rows.Count, Is.EqualTo(3));115 }116 [Test]117 public void Execute_SingleKeyMultipleAggregations_ExpectedResultSet()118 {119 var rs = Build();120 var args = new SummarizeArgs(121 new List<ColumnAggregationArgs>()122 {123 new ColumnAggregationArgs(new ColumnNameIdentifier("valueColumn"), AggregationFunctionType.Sum, ColumnType.Numeric, null),124 new ColumnAggregationArgs(new ColumnNameIdentifier("valueColumn"), AggregationFunctionType.Min, ColumnType.Numeric, null),125 new ColumnAggregationArgs(new ColumnNameIdentifier("valueColumn"), AggregationFunctionType.Max, ColumnType.Numeric, null),126 },127 new List<IColumnDefinitionLight>()128 { Mock.Of<IColumnDefinitionLight>(x => x.Identifier == new ColumnNameIdentifier("keyColumn") && x.Type == ColumnType.Text) }129 );130 var summarize = new SummarizeEngine(args);131 var result = summarize.Execute(rs);132 Assert.That(result, Is.Not.Null);133 Assert.That(result.Columns.Count, Is.EqualTo(4));134 Assert.That(result.Rows.Cast<DataRow>().Any(x => x["keyColumn"] as string == "alpha"));135 Assert.That(result.Rows.Cast<DataRow>().Any(x => x["keyColumn"] as string == "beta"));136 Assert.That(result.Rows.Count, Is.EqualTo(2));137 Assert.That(Convert.ToInt32(result.Rows.Cast<DataRow>().Single(x => x["keyColumn"] as string == "alpha")["valueColumn_Sum"]) == 7);138 Assert.That(Convert.ToInt32(result.Rows.Cast<DataRow>().Single(x => x["keyColumn"] as string == "alpha")["valueColumn_Min"]) == 1);139 Assert.That(Convert.ToInt32(result.Rows.Cast<DataRow>().Single(x => x["keyColumn"] as string == "alpha")["valueColumn_Max"]) == 4);140 Assert.That(Convert.ToInt32(result.Rows.Cast<DataRow>().Single(x => x["keyColumn"] as string == "beta").ItemArray.Skip(1).Distinct().Single()) == 3);141 }142 [Test]143 public void Execute_NoKeySingleAggregations_ExpectedResultSet()144 {145 var rs = Build();146 var args = new SummarizeArgs(147 new List<ColumnAggregationArgs>()148 {149 new ColumnAggregationArgs(new ColumnNameIdentifier("valueColumn"), AggregationFunctionType.Sum, ColumnType.Numeric, null),150 },151 new List<IColumnDefinitionLight>()152 );153 var summarize = new SummarizeEngine(args);154 var result = summarize.Execute(rs);155 Assert.That(result, Is.Not.Null);156 Assert.That(result.Columns.Count, Is.EqualTo(1));157 Assert.That(result.Rows.Count, Is.EqualTo(1));158 Assert.That(Convert.ToInt32(result.Rows[0][0]) == 10);159 }160 [Test]161 public void Execute_NoKeyMultipleAggregations_ExpectedResultSet()162 {163 var rs = Build();164 var args = new SummarizeArgs(165 new List<ColumnAggregationArgs>()166 {167 new ColumnAggregationArgs(new ColumnNameIdentifier("valueColumn"), AggregationFunctionType.Sum, ColumnType.Numeric, null),168 new ColumnAggregationArgs(new ColumnNameIdentifier("valueColumn"), AggregationFunctionType.Min, ColumnType.Numeric, null),169 new ColumnAggregationArgs(new ColumnNameIdentifier("valueColumn"), AggregationFunctionType.Max, ColumnType.Numeric, null),170 },171 new List<IColumnDefinitionLight>()172 );173 var summarize = new SummarizeEngine(args);174 var result = summarize.Execute(rs);175 Assert.That(result, Is.Not.Null);176 Assert.That(result.Columns.Count, Is.EqualTo(3));177 Assert.That(result.Rows.Count, Is.EqualTo(1));178 Assert.That(Convert.ToInt32(result.Rows[0][0]) == 10);179 Assert.That(Convert.ToInt32(result.Rows[0][1]) == 1);180 Assert.That(Convert.ToInt32(result.Rows[0][2]) == 4);181 }182 [Test]183 [TestCase(100)]184 [TestCase(1000)]185 [TestCase(10000)]186 [TestCase(100000)]187 [Retry(3)]188 public void Execute_LargeResultSet_ExpectedPerformance(int count)189 {190 var rs = BuildLarge(count);191 var args = new SummarizeArgs(192 new List<ColumnAggregationArgs>()193 {194 new ColumnAggregationArgs(new ColumnNameIdentifier("valueColumn"), AggregationFunctionType.Sum, ColumnType.Numeric, null),195 new ColumnAggregationArgs(new ColumnNameIdentifier("valueColumn"), AggregationFunctionType.Min, ColumnType.Numeric, null),196 new ColumnAggregationArgs(new ColumnNameIdentifier("valueColumn"), AggregationFunctionType.Max, ColumnType.Numeric, null),197 },198 new List<IColumnDefinitionLight>()199 { Mock.Of<IColumnDefinitionLight>(x => x.Identifier == new ColumnNameIdentifier("keyColumn") && x.Type == ColumnType.Text) }200 );201 var summarize = new SummarizeEngine(args);202 var stopWatch = new Stopwatch();203 stopWatch.Start();204 var result = summarize.Execute(rs);205 stopWatch.Stop();206 Assert.That(stopWatch.Elapsed.TotalSeconds, Is.LessThan(10));207 }208 }209}...

Full Screen

Full Screen

ColumnAggregationArgs.cs

Source:ColumnAggregationArgs.cs Github

copy

Full Screen

...6using System.Text;7using System.Threading.Tasks;8namespace NBi.Core.ResultSet.Alteration.Summarization9{10 public class ColumnAggregationArgs : AggregationArgs11 {12 public IColumnIdentifier Identifier { get; }13 public ColumnAggregationArgs(IColumnIdentifier identifier, AggregationFunctionType function, ColumnType columnType, IList<IScalarResolver> parameters)14 : base(function, columnType, parameters)15 => (Identifier) = (identifier);16 }17}...

Full Screen

Full Screen

SummarizeArgs.cs

Source:SummarizeArgs.cs Github

copy

Full Screen

...8{9 public class SummarizeArgs : ISummarizationArgs10 {11 public IEnumerable<IColumnDefinitionLight> GroupBys { get; set; }12 public IEnumerable<ColumnAggregationArgs> Aggregations { get; set; }13 public SummarizeArgs(IEnumerable<ColumnAggregationArgs> aggregations, IEnumerable<IColumnDefinitionLight> groupBys)14 => (Aggregations, GroupBys) = (aggregations, groupBys);15 }16}...

Full Screen

Full Screen

ColumnAggregationArgs

Using AI Code Generation

copy

Full Screen

1using NBi.Core.ResultSet.Alteration.Summarization;2using System;3using System.Collections.Generic;4using System.Linq;5using System.Text;6using System.Threading.Tasks;7{8 {9 static void Main(string[] args)10 {11 ColumnAggregationArgs columnAggregationArgs = new ColumnAggregationArgs();12 columnAggregationArgs.ColumnName = "Sales";13 columnAggregationArgs.AggregationMethod = AggregationMethod.Average;14 columnAggregationArgs.AggregationLabel = "Average Sales";15 columnAggregationArgs.AggregationType = AggregationType.Double;16 columnAggregationArgs.AggregationFormat = "N2";17 columnAggregationArgs.AggregationPosition = AggregationPosition.Last;18 columnAggregationArgs.AggregationScope = AggregationScope.Column;19 columnAggregationArgs.AggregationTarget = AggregationTarget.Column;20 columnAggregationArgs.AggregationTargetName = "Sales";21 columnAggregationArgs.AggregationTargetPosition = 1;22 Console.WriteLine("Column Name = " + columnAggregationArgs.ColumnName);23 Console.WriteLine("Aggregation Method = " + columnAggregationArgs.AggregationMethod);24 Console.WriteLine("Aggregation Label = " + columnAggregationArgs.AggregationLabel);25 Console.WriteLine("Aggregation Type = " + columnAggregationArgs.AggregationType);26 Console.WriteLine("Aggregation Format = " + columnAggregationArgs.AggregationFormat);27 Console.WriteLine("Aggregation Position = " + columnAggregationArgs.AggregationPosition);28 Console.WriteLine("Aggregation Scope = " + columnAggregationArgs.AggregationScope);29 Console.WriteLine("Aggregation Target = " + columnAggregationArgs.AggregationTarget);30 Console.WriteLine("Aggregation Target

Full Screen

Full Screen

ColumnAggregationArgs

Using AI Code Generation

copy

Full Screen

1var rs = new ResultSet();2var column = new Column("Column1", new object[] { 1, 2, 3, 4 });3rs.Load(column);4var alteration = new ColumnAggregationArgs("Column1", "Sum");5var alterer = new ColumnAggregation();6var altered = alterer.Execute(rs, alteration);7var rs = new ResultSet();8var column = new Column("Column1", new object[] { 1, 2, 3, 4 });9rs.Load(column);10var alteration = new ColumnAggregationArgs("Column1", "Average");11var alterer = new ColumnAggregation();12var altered = alterer.Execute(rs, alteration);13var rs = new ResultSet();14var column = new Column("Column1", new object[] { 1, 2, 3, 4 });15rs.Load(column);16var alteration = new ColumnAggregationArgs("Column1", "Min");17var alterer = new ColumnAggregation();18var altered = alterer.Execute(rs, alteration);19var rs = new ResultSet();20var column = new Column("Column1", new object[] { 1, 2, 3, 4 });21rs.Load(column);22var alteration = new ColumnAggregationArgs("Column1", "Max");23var alterer = new ColumnAggregation();24var altered = alterer.Execute(rs, alteration);25var rs = new ResultSet();26var column = new Column("Column1", new object[] { 1, 2, 3,

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 methods in ColumnAggregationArgs

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful