protected override void BaseSetup(AbstractSystemUnderTestXml sutXml, AbstractConstraintXml ctrXml) { if (!(sutXml is StructureXml)) throw new ArgumentException("System-under-test must be a 'StructureXml'"); SystemUnderTestXml = (StructureXml)sutXml; }
protected NBiConstraint InstantiateConstraint(ExistsXml ctrXml, StructureXml sutXml) { var expected = sutXml.Item.Caption; var ctr = new ExistsConstraint(expected); //Ignore-case if requested if (ctrXml.IgnoreCase) ctr = ctr.IgnoreCase; return ctr; }
public void GetSystemUnderTest_Build_CorrectSystemUnderTest() { var sutXml = new StructureXml(); var item = new PerspectiveXml(); sutXml.Item = item; item.ConnectionString = "connectionString"; item.Caption = "perspective"; var ctrXml = new ExistsXml(); var builder = new StructureExistsBuilder(); builder.Setup(sutXml, ctrXml); builder.Build(); var sut = builder.GetSystemUnderTest(); Assert.That(sut, Is.InstanceOf<MetadataDiscoveryRequest>()); }
public void GetConstraint_Build_CorrectConstraint() { var sutXml = new StructureXml(); var item = new HierarchyXml(); item.ConnectionString = "connectionString"; item.Perspective = "perspective-name"; item.Dimension = "dimension-caption"; item.Caption = "hierarchy-caption"; sutXml.Item = item; 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 GetConstraint_BuildUniqueItem_CorrectConstraint() { //Buiding object used during test var sutXml = new StructureXml(); sutXml.Item = new MeasureGroupsXml(); sutXml.Item.ConnectionString = "ConnectionString"; ((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 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 GetConstraint_BuildWithWithList_CorrectConstraint() { //Buiding object used during test var sutXml = new StructureXml(); sutXml.Item = new MeasureGroupsXml(); sutXml.Item.ConnectionString = "ConnectionString"; ((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 GetConstraint_BuildWithoutIgnoreCase_ComparerCaseSensitive() { var sutXml = new StructureXml(); var item = new PerspectiveXml(); sutXml.Item = item; item.ConnectionString = "connectionString"; item.Caption = "perspective"; var ctrXml = new ExistsXml(); var builder = new StructureExistsBuilder(); builder.Setup(sutXml, ctrXml); builder.Build(); var ctr = builder.GetConstraint(); var existsCtr = (ExistsConstraint)ctr; Assert.That(existsCtr.Comparer, Is.InstanceOf<NBi.Core.Analysis.Metadata.Field.ComparerByCaption>()); Assert.That(existsCtr.Comparer.Compare("c", "C"), Is.Not.EqualTo(0)); }
public void GetConstraint_BuildMultipleItem_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 ContainXml(); ctrXml.Items.Add("Search 1"); ctrXml.Items.Add("Search 2"); ctrXml.Items.Add("Search 3"); var builder = new StructureContainBuilder(); builder.Setup(sutXml, ctrXml); builder.Build(); var ctr = builder.GetConstraint(); Assert.That(ctr, Is.InstanceOf<ContainConstraint>()); }
public void GetSystemUnderTest_ConnectionStringInDefault_CorrectlyInitialized() { //Buiding object used during test var ctrXmlStubFactory = new Mock<ContainXml>(); var ctrXml = ctrXmlStubFactory.Object; var sutXml = new StructureXml(); sutXml.Item = new MeasureGroupsXml(); ((MeasureGroupsXml)sutXml.Item).Perspective = "Perspective"; sutXml.Default = new DefaultXml() { ConnectionString = 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 GetSystemUnderTest_ConnectionStringInDefault_CorrectlyInitialized() { //Buiding object used during test var ctrXmlStubFactory = new Mock<ContainXml>(); var ctrXml = ctrXmlStubFactory.Object; var sutXml = new StructureXml(); sutXml.Item = new MeasureGroupsXml(); ((MeasureGroupsXml)sutXml.Item).Perspective = "Perspective"; sutXml.Default = new DefaultXml() { ConnectionString = "connectionString-default" }; 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<MetadataDiscoveryRequest>()); Assert.That(((MetadataDiscoveryRequest)sut).ConnectionString, Is.EqualTo("connectionString-default")); }
public void GetSystemUnderTest_CorrectPropertyTarget_Success() { //Buiding object used during test var ctrXmlStubFactory = new Mock<ContainXml>(); var ctrXml = ctrXmlStubFactory.Object; var sutXml = new StructureXml(); sutXml.Item = new PropertiesXml(); sutXml.Item.ConnectionString = "ConnectionString"; ((PropertiesXml)sutXml.Item).Perspective = "Perspective"; ((PropertiesXml)sutXml.Item).Dimension = "Dimension"; ((PropertiesXml)sutXml.Item).Hierarchy = "Hierarchy"; ((PropertiesXml)sutXml.Item).Level = "Level"; var builder = new StructureContainBuilder(); builder.Setup(sutXml, ctrXml); builder.Build(); var sut = builder.GetSystemUnderTest(); //Assertion Assert.That(sut, Is.InstanceOf<MetadataDiscoveryRequest>()); }
public void GetSystemUnderTest_InCorrectMeasureGroupTargetWithoutCaption_Success() { //Buiding object used during test var ctrXmlStubFactory = new Mock<ContainXml>(); var ctrXml = ctrXmlStubFactory.Object; var sutXml = new StructureXml(); sutXml.Item = new MeasureGroupsXml(); sutXml.Item.ConnectionString = "ConnectionString"; ((MeasureGroupsXml)sutXml.Item).Perspective = "Perspective"; var builder = new StructureContainBuilder(); builder.Setup(sutXml, ctrXml); builder.Build(); var sut = builder.GetSystemUnderTest(); //Assertion Assert.That(sut, Is.InstanceOf<MetadataDiscoveryRequest>()); }
public void GetSystemUndeTest_CorrectFiltersAppliedOnDescriptionPart2_Success() { //Buiding object used during test var ctrXmlStubFactory = new Mock<EquivalentToXml>(); var ctrXml = ctrXmlStubFactory.Object; var sutXml = new StructureXml(); sutXml.Item = new PropertiesXml(); sutXml.Item.ConnectionString = ConnectionStringReader.GetAdomd(); ((IDimensionFilter)sutXml.Item).Dimension = "Dimension"; ((IHierarchyFilter)sutXml.Item).Hierarchy = "Hierarchy"; ((ILevelFilter)sutXml.Item).Level = "Level"; var builder = new StructureEquivalentToBuilder(); builder.Setup(sutXml, ctrXml); builder.Build(); var sut = builder.GetSystemUnderTest(); //Assertion Assert.That(sut, Is.InstanceOf<OlapCommand>()); var command = sut as OlapCommand; Assert.NotNull(command); Assert.NotNull(command.Description); Assert.IsTrue(command.Description.Filters.Any(f => f.Caption == "Dimension")); Assert.IsTrue(command.Description.Filters.Any(f => f.Caption == "Hierarchy")); Assert.IsTrue(command.Description.Filters.Any(f => f.Caption == "Level")); }
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 = "ConnectionString"; 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<MetadataDiscoveryRequest>()); }
public void Serialize_StructureXml_NoDefaultAndSettings() { var perspectiveXml = new PerspectiveXml(); perspectiveXml.Caption = "My Caption"; perspectiveXml.Default = new DefaultXml() { ApplyTo = SettingsXml.DefaultScope.Assert, ConnectionString = "connStr" }; perspectiveXml.Settings = new SettingsXml() { References = new List<ReferenceXml>() { new ReferenceXml() { Name = "Bob", ConnectionString = "connStr" } } }; var structureXml = new StructureXml() { Item = perspectiveXml }; var serializer = new XmlSerializer(typeof(StructureXml)); var stream = new MemoryStream(); var writer = new StreamWriter(stream, Encoding.UTF8); serializer.Serialize(writer, structureXml); var content = Encoding.UTF8.GetString(stream.ToArray()); writer.Close(); stream.Close(); Debug.WriteLine(content); Assert.That(content, Is.StringContaining("My Caption")); Assert.That(content, Is.Not.StringContaining("efault")); Assert.That(content, Is.Not.StringContaining("eference")); }
protected virtual object InstantiateSystemUnderTest(StructureXml sutXml) { return InstantiateCommand(sutXml.Item); }
public void Instantiate_StructureContains_ArgumentException() { var sutXml = new StructureXml(); var ctrXml = new ContainXml(); var builderMockFactory = new Mock<ITestCaseBuilder>(); builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml, TestConfiguration.Default)); builderMockFactory.Setup(b => b.Build()); builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new object()); builderMockFactory.Setup(b => b.GetConstraint()).Returns(new NBi.NUnit.Structure.ContainConstraint("expected")); var builder = builderMockFactory.Object; var testCaseFactory = new TestCaseFactory(); testCaseFactory.Register(typeof(StructureXml), typeof(ContainXml), builder); var tc = testCaseFactory.Instantiate(sutXml, ctrXml); Assert.That(tc, Is.Not.Null); builderMockFactory.VerifyAll(); }
public void GetSystemUnderTest_CorrectPerspectiveTarget_Success() { //Buiding object used during test var ctrXmlStubFactory = new Mock<EquivalentToXml>(); var ctrXml = ctrXmlStubFactory.Object; var sutXml = new StructureXml(); sutXml.Item = new PerspectivesXml(); sutXml.Item.ConnectionString = "ConnectionString"; var builder = new StructureEquivalentToBuilder(); builder.Setup(sutXml, ctrXml); builder.Build(); var sut = builder.GetSystemUnderTest(); //Assertion Assert.That(sut, Is.InstanceOf<MetadataDiscoveryRequest>()); }
public void Instantiate_StructureOrdered_ArgumentException() { var sutXml = new StructureXml(); var ctrXml = new OrderedXml(); var testCaseFactory = new TestCaseFactory(); Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); }); }
public void Instantiate_StructureExists_TestCase() { var sutXml = new StructureXml(); var ctrXml = new ExistsXml(); var builderMockFactory = new Mock<ITestCaseBuilder>(); builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml, TestConfiguration.Default)); builderMockFactory.Setup(b => b.Build()); builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new object()); builderMockFactory.Setup(b => b.GetConstraint()).Returns(new ExistsConstraint("foo")); var builder = builderMockFactory.Object; var testCaseFactory = new TestCaseFactory(); testCaseFactory.Register(typeof(StructureXml), typeof(ExistsXml), builder); var tc = testCaseFactory.Instantiate(sutXml, ctrXml); Assert.That(tc, Is.Not.Null); builderMockFactory.VerifyAll(); }
public void Instantiate_StructureSyntacticallyCorrect_ArgumentException() { var sutXml = new StructureXml(); var ctrXml = new SyntacticallyCorrectXml(); var testCaseFactory = new TestCaseFactory(); Assert.Throws<ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); }); }
public void GetSystemUnderTest_IncorrectMeasureGroupTargetWithoutPerspective_ThrowException() { //Buiding object used during test var ctrXmlStubFactory = new Mock<ContainXml>(); var ctrXml = ctrXmlStubFactory.Object; var sutXml = new StructureXml(); sutXml.Item = new MeasureGroupsXml(); sutXml.Item.ConnectionString = "ConnectionString"; var builder = new StructureContainBuilder(); builder.Setup(sutXml, ctrXml); //Assertion Assert.Throws<DiscoveryRequestFactoryException>(delegate { builder.Build(); }); }
public void IsHandling_StructureExists_True() { var sutXml = new StructureXml(); var ctrXml = new ExistsXml(); var testCaseFactory = new TestCaseFactory(); var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType()); Assert.That(actual, Is.True); }
public void IsHandling_StructureSyntacticallyCorrect_False() { var sutXml = new StructureXml(); var ctrXml = new SyntacticallyCorrectXml(); var testCaseFactory = new TestCaseFactory(); var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType()); Assert.That(actual, Is.False); }
public void IsHandling_StructureOrdered_True() { var sutXml = new StructureXml(); var ctrXml = new OrderedXml(); var testCaseFactory = new TestCaseFactory(); var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType()); Assert.That(actual, Is.False); }
public void GetSystemUnderTest_InCorrectPropertyTargetWithoutLevel_ThrowException() { //Buiding object used during test var ctrXmlStubFactory = new Mock<ContainXml>(); var ctrXml = ctrXmlStubFactory.Object; var sutXml = new StructureXml(); sutXml.Item = new PropertiesXml(); sutXml.Item.ConnectionString = "ConnectionString"; ((PropertiesXml)sutXml.Item).Perspective = "Perspective"; ((PropertiesXml)sutXml.Item).Dimension = "Dimension"; ((PropertiesXml)sutXml.Item).Hierarchy = "Hierarchy"; var builder = new StructureContainBuilder(); builder.Setup(sutXml, ctrXml); //Assertion Assert.Throws<DiscoveryRequestFactoryException>(delegate { builder.Build(); }); }
public void GetSystemUndeTest_CorrectFiltersAppliedOnDescriptionPart1_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(); ((IPerspectiveFilter)sutXml.Item).Perspective = "Perspective"; ((IMeasureGroupFilter)sutXml.Item).MeasureGroup = "MeasureGroup"; ((IDisplayFolderFilter)sutXml.Item).DisplayFolder = "DisplayFolder"; var builder = new StructureEquivalentToBuilder(); builder.Setup(sutXml, ctrXml); builder.Build(); var sut = builder.GetSystemUnderTest(); //Assertion Assert.That(sut, Is.InstanceOf<OlapCommand>()); var command = sut as OlapCommand; Assert.NotNull(command); Assert.NotNull(command.Description); Assert.IsTrue(command.Description.Filters.Any(f => f.Caption == "Perspective")); Assert.IsTrue(command.Description.Filters.Any(f => f.Caption == "MeasureGroup")); Assert.IsTrue(command.Description.Filters.Any(f => f.Caption == "DisplayFolder")); }
public void GetSystemUnderTest_CorrectPerspectiveTarget_Success() { //Buiding object used during test var ctrXmlStubFactory = new Mock<ContainXml>(); var ctrXml = ctrXmlStubFactory.Object; var sutXml = new StructureXml(); sutXml.Item = new PerspectivesXml(); sutXml.Item.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 GetSystemUnderTest_CorrectDimensionTarget_Success() { //Buiding object used during test var ctrXmlStubFactory = new Mock<EquivalentToXml>(); 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 StructureEquivalentToBuilder(); builder.Setup(sutXml, ctrXml); //Call the method to test builder.Build(); var sut = builder.GetSystemUnderTest(); //Assertion var command = sut as OlapCommand; Assert.NotNull(command); Assert.NotNull(command.Description); Assert.IsTrue(command.Description.Filters.Any(f => f.Caption == "Perspective")); Assert.AreEqual(command.Description.Filters.Count(), 1); }