public void GetSystemUnderTest_CorrectMeasureTarget_Success() { //Buiding object used during test var ctrXmlStubFactory = new Mock <EquivalentToXml>(); var ctrXml = ctrXmlStubFactory.Object; var sutXml = new StructureXml(); sutXml.Item = new MeasuresXml(); sutXml.Item.ConnectionString = ConnectionStringReader.GetAdomd(); ((MeasuresXml)sutXml.Item).Perspective = "Perspective"; ((MeasuresXml)sutXml.Item).MeasureGroup = "MeasureGroup"; var builder = new StructureEquivalentToBuilder(); builder.Setup(sutXml, ctrXml); builder.Build(); var sut = builder.GetSystemUnderTest(); //Assertion Assert.That(sut, Is.InstanceOf <OlapCommand>()); }
public void Matches_MdxQueryAndSqlQueryWithCorrectSettings_Matching() { //Buiding object used during test var expectedQuery = "SELECT 'CY 2005', 1874469 UNION "; expectedQuery += " SELECT 'CY 2006', 4511243 UNION "; expectedQuery += " SELECT 'CY 2007', 4709851 UNION "; expectedQuery += " SELECT 'CY 2008', 1513940 "; var expectedCmd = new SqlCommand(expectedQuery, new SqlConnection(ConnectionStringReader.GetSqlClient())); var ctr = new EqualToConstraint(expectedCmd); ctr.Using( new SettingsResultSetComparisonByIndex( SettingsResultSetComparisonByIndex.KeysChoice.AllExpectLast, SettingsResultSetComparisonByIndex.ValuesChoice.Last, new List <IColumnDefinition>() { new Column() { Index = 1, Role = ColumnRole.Value, Type = ColumnType.Numeric, Tolerance = "5" } } ) ); var query = "SELECT [Measures].[Amount] ON 0, NON EMPTY([Date].[Calendar].[Calendar Year]) ON 1 FROM [Adventure Works]"; var cmd = new AdomdCommand(query, new AdomdConnection(ConnectionStringReader.GetAdomd())); //Call the method to test var actual = ctr.Matches(cmd); //Assertion Assert.That(actual, Is.True); }
public void GetConstraint_BuildWithWithList_CorrectConstraint() { //Buiding object used during test var sutXml = new StructureXml(); sutXml.Item = new MeasureGroupsXml(); sutXml.Item.ConnectionString = ConnectionStringReader.GetAdomd(); ((MeasureGroupsXml)sutXml.Item).Perspective = "Perspective"; var ctrXml = new EquivalentToXml(); ctrXml.Items.Add("Search"); ctrXml.Items.Add("Search 2"); var builder = new StructureEquivalentToBuilder(); builder.Setup(sutXml, ctrXml); builder.Build(); var ctr = builder.GetConstraint(); Assert.That(ctr, Is.InstanceOf <EquivalentToConstraint>()); }
public void GetSystemUnderTest_CorrectPerspectiveTarget_Success() { //Buiding object used during test var ctrXmlStubFactory = new Mock <ContainXml>(); var ctrXml = ctrXmlStubFactory.Object; var sutXml = new StructureXml { Item = new PerspectivesXml { ConnectionString = ConnectionStringReader.GetAdomd() } }; var builder = new StructureContainBuilder(); builder.Setup(sutXml, ctrXml); builder.Build(); var sut = builder.GetSystemUnderTest(); //Assertion Assert.That(sut, Is.InstanceOf <OlapCommand>()); }
public void Matches_MdxQueryAndResulSetCsvFile_Matching() { //Buiding object used during test var filename = DiskOnFile.CreatePhysicalFile("NonEmptyAmountByYear.csv", "NBi.Testing.Integration.NUnit.Resources.NonEmptyAmountByYear.csv"); var resolver = new CsvResultSetResolver(new CsvResultSetResolverArgs(new LiteralScalarResolver <string>(filename), string.Empty, CsvProfile.SemiColumnDoubleQuote)); var builder = new ResultSetServiceBuilder(); builder.Setup(resolver); var ctr = new EqualToConstraint(builder.GetService()); var mdx = "SELECT [Measures].[Amount] ON 0, NON EMPTY([Date].[Calendar].[Calendar Year]) ON 1 FROM [Adventure Works]"; var query = new NBi.Core.Query.Query(mdx, ConnectionStringReader.GetAdomd()); var actualBuilder = new ResultSetServiceBuilder(); actualBuilder.Setup(new FakeQueryResultSetResolver(query, serviceLocator)); var actual = actualBuilder.GetService(); //Assertion Assert.That(ctr.Matches(actual)); }
public void GetConstraint_BuildUniqueItem_CorrectConstraint() { //Buiding object used during test var sutXml = new StructureXml(); sutXml.Item = new MeasureGroupsXml(); sutXml.Item.ConnectionString = ConnectionStringReader.GetAdomd(); ((MeasureGroupsXml)sutXml.Item).Perspective = "Perspective"; sutXml.Item.Caption = "MeasureGroup"; var ctrXml = new ContainXml(); ctrXml.Caption = "Search"; var builder = new StructureContainBuilder(); builder.Setup(sutXml, ctrXml); builder.Build(); var ctr = builder.GetConstraint(); Assert.That(ctr, Is.InstanceOf <ContainConstraint>()); }
public void GetSystemUnderTest_CorrectLevelTarget_Success() { //Buiding object used during test var ctrXmlStubFactory = new Mock <ContainXml>(); var ctrXml = ctrXmlStubFactory.Object; var sutXml = new StructureXml(); sutXml.Item = new LevelsXml(); sutXml.Item.ConnectionString = ConnectionStringReader.GetAdomd(); ((LevelsXml)sutXml.Item).Perspective = "Perspective"; ((LevelsXml)sutXml.Item).Dimension = "Dimension"; ((LevelsXml)sutXml.Item).Hierarchy = "Hierarchy"; var builder = new StructureContainBuilder(); builder.Setup(sutXml, ctrXml); builder.Build(); var sut = builder.GetSystemUnderTest(); //Assertion Assert.That(sut, Is.InstanceOf <OlapCommand>()); }
public void GetConstraint_Build_CorrectConstraint() { var sutXml = new StructureXml() { Item = new HierarchyXml() { ConnectionString = ConnectionStringReader.GetAdomd(), Perspective = "perspective-name", Dimension = "dimension-caption", Caption = "hierarchy-caption", } }; var ctrXml = new ExistsXml(); var builder = new StructureExistsBuilder(); builder.Setup(sutXml, ctrXml); builder.Build(); var ctr = builder.GetConstraint(); Assert.That(ctr, Is.InstanceOf <ExistsConstraint>()); }
public void Matches_MdxQueryAndResulSetWithoutKeyValuesInfo_Matching() { //Buiding object used during test var rs = new ResultSet(); var objs = new List <object[]>(); objs.Add(new object[] { "CY 2005", "1874469.00" }); objs.Add(new object[] { "CY 2006", "4511243.0" }); objs.Add(new object[] { "CY 2007", "4709851" }); objs.Add(new object[] { "CY 2008", "1513940" }); rs.Load(objs); var ctr = new EqualToConstraint(rs); var query = "SELECT [Measures].[Amount] ON 0, NON EMPTY([Date].[Calendar].[Calendar Year]) ON 1 FROM [Adventure Works]"; var cmd = new AdomdCommand(query, new AdomdConnection(ConnectionStringReader.GetAdomd())); //Call the method to test var actual = ctr.Matches(cmd); //Assertion Assert.That(actual, Is.True); }
public void Matches_MdxQueryAndSameQueryWithCorrectSettings_Matching() { //Buiding object used during test var expectedQuery = "SELECT [Measures].[Amount] ON 0, NON EMPTY([Date].[Calendar].[Calendar Year]) ON 1 FROM [Adventure Works]"; var expectedCmd = new AdomdCommand(expectedQuery, new AdomdConnection(ConnectionStringReader.GetAdomd())); var ctr = new EqualToConstraint(expectedCmd); ctr.Using(new SettingsResultSetComparisonByIndex( SettingsResultSetComparisonByIndex.KeysChoice.First, SettingsResultSetComparisonByIndex.ValuesChoice.Last, NumericAbsoluteTolerance.None) ); var query = "SELECT [Measures].[Amount] ON 0, NON EMPTY([Date].[Calendar].[Calendar Year]) ON 1 FROM [Adventure Works]"; var cmd = new AdomdCommand(query, new AdomdConnection(ConnectionStringReader.GetAdomd())); //Call the method to test var actual = ctr.Matches(cmd); //Assertion Assert.That(actual, Is.True); }
public void GetSystemUnderTest_CorrectDimensionTarget_Success() { //Buiding object used during test var ctrXmlStubFactory = new Mock <ContainXml>(); var ctrXml = ctrXmlStubFactory.Object; var sutXml = new StructureXml(); var dim = new DimensionsXml(); dim.ConnectionString = ConnectionStringReader.GetAdomd(); dim.Perspective = "Perspective"; sutXml.Item = dim; var builder = new StructureContainBuilder(); builder.Setup(sutXml, ctrXml); //Call the method to test builder.Build(); var sut = builder.GetSystemUnderTest(); //Assertion Assert.That(sut, Is.InstanceOf <OlapCommand>()); }
public void GetConstraint_BuildWithIgnoreCase_ComparerCaseInsensitive() { var sutXml = new StructureXml(); var item = new PerspectiveXml(); sutXml.Item = item; item.ConnectionString = ConnectionStringReader.GetAdomd(); item.Caption = "perspective"; var ctrXml = new ExistsXml(); ctrXml.IgnoreCase = true; var builder = new StructureExistsBuilder(); builder.Setup(sutXml, ctrXml); builder.Build(); var ctr = builder.GetConstraint(); var existsCtr = (ExistsConstraint)ctr; Assert.That(existsCtr.Comparer, Is.InstanceOf <CaseInsensitiveComparer>()); Assert.That(existsCtr.Comparer.Compare("c", "C"), Is.EqualTo(0)); }
public void GetSystemUnderTest_ConnectionStringInDefault_CorrectlyInitialized() { //Buiding object used during test var ctrXmlStubFactory = new Mock <ContainXml>(); var ctrXml = ctrXmlStubFactory.Object; var sutXml = new StructureXml() { Item = new MeasureGroupsXml() { Perspective = "Perspective", Settings = new SettingsXml() { Defaults = new List <DefaultXml>() { new DefaultXml() { ConnectionString = new ConnectionStringXml() { Inline = ConnectionStringReader.GetAdomd() } } } } } }; var builder = new StructureContainBuilder(); builder.Setup(sutXml, ctrXml); //Call the method to test builder.Build(); var sut = builder.GetSystemUnderTest(); //Assertion Assert.That(sut, Is.InstanceOf <OlapCommand>()); }
public void Matches_MdxQueryAndResulSetWithCorrectSettings_Matching() { //Buiding object used during test var objs = new List <object[]>() { new object[] { "CY 2005", "1874469.00" }, new object[] { "CY 2006", "4511243.0" }, new object[] { "CY 2007", "4709851" }, new object[] { "CY 2008", "1513940" } }; var resolver = new ObjectsResultSetResolver(new ObjectsResultSetResolverArgs(objs.ToArray())); var builder = new ResultSetServiceBuilder(); builder.Setup(resolver); var ctr = new EqualToConstraint(builder.GetService()); ctr.Using(new SettingsOrdinalResultSet( SettingsOrdinalResultSet.KeysChoice.First, SettingsOrdinalResultSet.ValuesChoice.Last, new NumericAbsoluteTolerance(500, SideTolerance.Both) ) ); var mdx = "SELECT [Measures].[Amount] ON 0, NON EMPTY([Date].[Calendar].[Calendar Year]) ON 1 FROM [Adventure Works]"; var query = new NBi.Core.Query.Query(mdx, ConnectionStringReader.GetAdomd()); var actualBuilder = new ResultSetServiceBuilder(); actualBuilder.Setup(new FakeQueryResultSetResolver(query, serviceLocator)); var actual = actualBuilder.GetService(); //Assertion Assert.That(ctr.Matches(actual)); }