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;
        }
示例#3
0
        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>());
        }
示例#4
0
        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>());
        }
示例#5
0
        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>());
        }
示例#8
0
        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>());
        }
示例#11
0
        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"));
        }
示例#12
0
        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>());
        }
示例#13
0
        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"));
        }
示例#15
0
        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>());
        }
示例#16
0
        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);
 }
示例#18
0
        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>());
        }
示例#20
0
        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); });
        }
示例#21
0
        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();
        }
示例#22
0
        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); });
        }
示例#23
0
        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(); });
        }
示例#24
0
        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);
        }
示例#25
0
        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);
        }
示例#26
0
        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);
        }
示例#27
0
        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);
        }