Exemplo n.º 1
0
        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>());
        }
Exemplo n.º 2
0
        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>());
        }
Exemplo n.º 3
0
        protected NBiConstraint InstantiateConstraint(OrderedXml ctrXml)
        {
            var ctr = new NBi.NUnit.Member.OrderedConstraint();

            if (ctrXml.Descending)
            {
                ctr = ctr.Descending;
            }

            switch (ctrXml.Rule)
            {
            case OrderedXml.Order.Alphabetical:
                ctr = ctr.Alphabetical;
                break;

            case OrderedXml.Order.Chronological:
                ctr = ctr.Chronological;
                break;

            case OrderedXml.Order.Numerical:
                ctr = ctr.Numerical;
                break;

            case OrderedXml.Order.Specific:
                ctr = ctr.Specific(ctrXml.Definition);
                break;

            default:
                break;
            }

            return(ctr);
        }
Exemplo n.º 4
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); });
        }
Exemplo n.º 5
0
        protected override void SpecificSetup(AbstractSystemUnderTestXml sutXml, AbstractConstraintXml ctrXml)
        {
            if (!(ctrXml is OrderedXml))
            {
                throw new ArgumentException("Constraint must be a 'OrderedXml'");
            }

            ConstraintXml = (OrderedXml)ctrXml;
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
        public void IsHandling_MembersOrdered_True()
        {
            var sutXml          = new MembersXml();
            var ctrXml          = new OrderedXml();
            var testCaseFactory = new TestCaseFactory();

            var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());

            Assert.That(actual, Is.True);
        }
Exemplo n.º 8
0
        public void IsHandling_QueryOrdered_False()
        {
            var sutXml          = new ExecutionXml();
            var ctrXml          = new OrderedXml();
            var testCaseFactory = new TestCaseFactory();

            var actual = testCaseFactory.IsHandling(sutXml.GetType(), ctrXml.GetType());

            Assert.That(actual, Is.False);
        }
Exemplo n.º 9
0
        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));
        }
Exemplo n.º 10
0
        public void Instantiate_MembersOrdered_ArgumentException()
        {
            var sutXml = new MembersXml();
            var ctrXml = new OrderedXml();

            var builderMockFactory = new Mock <ITestCaseBuilder>();

            builderMockFactory.Setup(b => b.Setup(sutXml, ctrXml, TestConfiguration.Default, It.IsAny <Dictionary <string, ITestVariable> >()));
            builderMockFactory.Setup(b => b.Build());
            builderMockFactory.Setup(b => b.GetSystemUnderTest()).Returns(new object());
            builderMockFactory.Setup(b => b.GetConstraint()).Returns(new OrderedConstraint());
            var builder = builderMockFactory.Object;

            var testCaseFactory = new TestCaseFactory();

            testCaseFactory.Register(typeof(MembersXml), typeof(OrderedXml), builder);

            var tc = testCaseFactory.Instantiate(sutXml, ctrXml);

            Assert.That(tc, Is.Not.Null);
            builderMockFactory.VerifyAll();
        }
Exemplo n.º 11
0
        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"));
        }