public void GetConstraint_BuildWithQuery_ConstraintBuilt()
        {
            var sutXml = new MembersXml();

            sutXml.ChildrenOf = "memberCaption";
            var item = new LevelXml();

            sutXml.Item           = item;
            item.ConnectionString = "connectionString";
            item.Perspective      = "perspective";
            item.Dimension        = "dimension";
            item.Hierarchy        = "hierarchy";
            item.Caption          = "level";

            var ctrXml = new OrderedXml();
            var query  = new QueryXml();

            query.InlineQuery = "select label from myTable order by sortOrder";
            ctrXml.Query      = query;

            var builder = new MembersOrderedBuilder();

            builder.Setup(sutXml, ctrXml);
            builder.Build();
            var ctr = builder.GetConstraint();

            Assert.That(ctr, Is.InstanceOf <OrderedConstraint>());
        }
        public void GetConstraint_Build_CorrectConstraint()
        {
            var sutXml = new MembersXml()
            {
                Item = new HierarchyXml()
                {
                    ConnectionString = "connStr"
                }
            };
            var ctrXml = new OrderedXml();

            var discoFactoStubFactory = new Mock <DiscoveryRequestFactory>();

            discoFactoStubFactory.Setup(dfs =>
                                        dfs.Build(
                                            It.IsAny <string>(),
                                            It.IsAny <string>(),
                                            It.IsAny <List <string> >(),
                                            It.IsAny <List <PatternValue> >(),
                                            It.IsAny <string>(),
                                            It.IsAny <string>(),
                                            It.IsAny <string>(),
                                            It.IsAny <string>()))
            .Returns(new MembersDiscoveryRequest());
            var discoFactoStub = discoFactoStubFactory.Object;

            var builder = new MembersOrderedBuilder(discoFactoStub);

            builder.Setup(sutXml, ctrXml);
            builder.Build();
            var ctr = builder.GetConstraint();

            Assert.That(ctr, Is.InstanceOf <OrderedConstraint>());
        }
        public void GetSystemUnderTest_ConnectionStringInDefault_CorrectlyInitialized()
        {
            var sutXml = new MembersXml();

            var item = new HierarchyXml()
            {
                Perspective = "perspective",
                Dimension   = "dimension",
                Caption     = "hierarchy",
                Settings    = new SettingsXml()
                {
                    Defaults = new List <DefaultXml>()
                    {
                        new DefaultXml()
                        {
                            ApplyTo          = SettingsXml.DefaultScope.SystemUnderTest,
                            ConnectionString = new ConnectionStringXml()
                            {
                                Inline = "connectionString-default"
                            }
                        }
                    }
                }
            };

            sutXml.Item = item;

            var ctrXml = new OrderedXml();

            var discoFactoMockFactory = new Mock <DiscoveryRequestFactory>();

            discoFactoMockFactory.Setup(dfs =>
                                        dfs.Build(
                                            It.IsAny <string>(),
                                            It.IsAny <string>(),
                                            It.IsAny <List <string> >(),
                                            It.IsAny <List <PatternValue> >(),
                                            It.IsAny <string>(),
                                            It.IsAny <string>(),
                                            It.IsAny <string>(),
                                            It.IsAny <string>()))
            .Returns(new MembersDiscoveryRequest());
            var discoFactoMock = discoFactoMockFactory.Object;

            var builder = new MembersOrderedBuilder(discoFactoMock);

            builder.Setup(sutXml, ctrXml);
            builder.Build();
            var sut = builder.GetSystemUnderTest();

            Assert.That(sut, Is.InstanceOf <MembersDiscoveryRequest>());
            discoFactoMockFactory.Verify(dfm => dfm.Build("connectionString-default", It.IsAny <string>(), It.IsAny <List <string> >(), It.IsAny <List <PatternValue> >(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), null));
        }
        public void GetSystemUnderTest_BuildWithLevel_CorrectCallToDiscoverFactory()
        {
            var sutXml = new MembersXml();

            sutXml.ChildrenOf = "memberCaption";
            var item = new LevelXml();

            sutXml.Item           = item;
            item.ConnectionString = "connectionString";
            item.Perspective      = "perspective";
            item.Dimension        = "dimension";
            item.Hierarchy        = "hierarchy";
            item.Caption          = "level";
            var ctrXml = new OrderedXml();

            var discoFactoMockFactory = new Mock <DiscoveryRequestFactory>();

            discoFactoMockFactory.Setup(dfs =>
                                        dfs.Build(
                                            It.IsAny <string>(),
                                            It.IsAny <string>(),
                                            It.IsAny <List <string> >(),
                                            It.IsAny <List <PatternValue> >(),
                                            It.IsAny <string>(),
                                            It.IsAny <string>(),
                                            It.IsAny <string>(),
                                            It.IsAny <string>()))
            .Returns(new MembersDiscoveryRequest());
            var discoFactoMock = discoFactoMockFactory.Object;

            var builder = new MembersOrderedBuilder(discoFactoMock);

            builder.Setup(sutXml, ctrXml);
            builder.Build();
            var sut = builder.GetSystemUnderTest();

            Assert.That(sut, Is.InstanceOf <MembersDiscoveryRequest>());
            discoFactoMockFactory.Verify(dfm => dfm.Build("connectionString", "memberCaption", It.IsAny <List <string> >(), It.IsAny <List <PatternValue> >(), "perspective", "dimension", "hierarchy", "level"));
        }