public void GetSystemUnderTest_BuildWithHierarchy_CorrectCallToDiscoverFactory()
        {
            var sutXml = new MembersXml();
            sutXml.ChildrenOf = "memberCaption";
            var item = new HierarchyXml();
            sutXml.Item = item;
            item.ConnectionString = "connectionString";
            item.Perspective = "perspective";
            item.Dimension = "dimension";
            item.Caption = "hierarchy";
            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", null));
        }
Exemple #2
0
        protected override void SpecificSetup(AbstractSystemUnderTestXml sutXml, AbstractConstraintXml ctrXml)
        {
            if (!(ctrXml is OrderedXml))
                throw new ArgumentException("Constraint must be a 'OrderedXml'");

            ConstraintXml = (OrderedXml)ctrXml;
        }
        public void GetConstraint_Build_CorrectConstraint()
        {
            var sutXml = new MembersXml();
            var item = new HierarchyXml();
            sutXml.Item = item;
            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>());
        }
Exemple #4
0
        protected global::NUnit.Framework.Constraints.Constraint 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;
        }
        public void GetSystemUnderTest_ConnectionStringInDefault_CorrectlyInitialized()
        {
            var sutXml = new MembersXml();

            var item = new HierarchyXml();
            sutXml.Item = item;
            item.Perspective = "perspective";
            item.Dimension = "dimension";
            item.Caption = "hierarchy";

            var defXml = new DefaultXml();
            defXml.ConnectionString = "connectionString-default";
            sutXml.Default = defXml;

            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 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 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);
        }
        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);
        }
        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_MembersOrdered_ArgumentException()
        {
            var sutXml = new MembersXml();
            var ctrXml = new OrderedXml();

            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 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();
        }