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 GetSystemUnderTest_ConnectionStringInDefault_CorrectlyInitialized()
        {
            //Buiding object used during test
            var ctrXmlStubFactory = new Mock<EquivalentToXml>();
            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 StructureEquivalentToBuilder();
            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<EquivalentToXml>();
            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 StructureEquivalentToBuilder();
            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_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 = "ConnectionString";
            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
            Assert.That(sut, Is.InstanceOf<MetadataDiscoveryRequest>());
        }
        public void GetSystemUnderTest_IncorrectMeasureGroupTargetWithoutPerspective_ThrowException()
        {
            //Buiding object used during test
            var ctrXmlStubFactory = new Mock<EquivalentToXml>();
            var ctrXml = ctrXmlStubFactory.Object;

            var sutXml = new StructureXml();
            sutXml.Item = new MeasureGroupsXml();
            sutXml.Item.ConnectionString = "ConnectionString";

            var builder = new StructureEquivalentToBuilder();
            builder.Setup(sutXml, ctrXml);
            //Assertion
            Assert.Throws<DiscoveryRequestFactoryException>(delegate { builder.Build(); });
        }
        public void GetSystemUnderTest_InCorrectMeasureGroupTargetWithoutCaption_Success()
        {
            //Buiding object used during test
            var ctrXmlStubFactory = new Mock<EquivalentToXml>();
            var ctrXml = ctrXmlStubFactory.Object;

            var sutXml = new StructureXml();
            sutXml.Item = new MeasureGroupsXml();
            sutXml.Item.ConnectionString = "ConnectionString";
            ((MeasureGroupsXml)sutXml.Item).Perspective = "Perspective";
            var builder = new StructureEquivalentToBuilder();
            builder.Setup(sutXml, ctrXml);
            builder.Build();
            var sut = builder.GetSystemUnderTest();

            //Assertion
            Assert.That(sut, Is.InstanceOf<MetadataDiscoveryRequest>());
        }
        public void GetSystemUnderTest_InCorrectLevelTargetWithoutLevel_ThrowException()
        {
            //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 = "ConnectionString";
            ((PropertiesXml)sutXml.Item).Perspective = "Perspective";
            ((PropertiesXml)sutXml.Item).Dimension = "Dimension";
            ((PropertiesXml)sutXml.Item).Hierarchy = "Hierarchy";

            var builder = new StructureEquivalentToBuilder();
            builder.Setup(sutXml, ctrXml);
            //Assertion
            Assert.Throws<DiscoveryRequestFactoryException>(delegate { builder.Build(); });
        }
        public void GetSystemUnderTest_CorrectPropertyTarget_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 = "ConnectionString";
            ((PropertiesXml)sutXml.Item).Perspective = "Perspective";
            ((PropertiesXml)sutXml.Item).Dimension = "Dimension";
            ((PropertiesXml)sutXml.Item).Hierarchy = "Hierarchy";
            ((PropertiesXml)sutXml.Item).Level = "Level";
            var builder = new StructureEquivalentToBuilder();
            builder.Setup(sutXml, ctrXml);
            builder.Build();
            var sut = builder.GetSystemUnderTest();

            //Assertion
            Assert.That(sut, Is.InstanceOf<MetadataDiscoveryRequest>());
        }
        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);
        }
        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 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<EquivalentToXml>();
            var ctrXml = ctrXmlStubFactory.Object;

            var sutXml = new StructureXml();
            sutXml.Item = new PerspectivesXml();
            sutXml.Item.ConnectionString = ConnectionStringReader.GetAdomd();
            var builder = new StructureEquivalentToBuilder();
            builder.Setup(sutXml, ctrXml);
            builder.Build();
            var sut = builder.GetSystemUnderTest();

            //Assertion
            Assert.That(sut, Is.InstanceOf<OlapCommand>());
        }