Example #1
0
        public void Instantiate_QueryExists_ArgumentException()
        {
            var sutXml          = new ExecutionXml();
            var ctrXml          = new ExistsXml();
            var testCaseFactory = new TestCaseFactory();

            Assert.Throws <ArgumentException>(delegate { testCaseFactory.Instantiate(sutXml, ctrXml); });
        }
Example #2
0
        protected override void SpecificSetup(AbstractSystemUnderTestXml sutXml, AbstractConstraintXml ctrXml)
        {
            if (!(ctrXml is ExistsXml))
            {
                throw new ArgumentException("Constraint must be a 'ExistsXml'");
            }

            ConstraintXml = (ExistsXml)ctrXml;
        }
Example #3
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);
        }
Example #4
0
        public void IsHandling_MembersExists_False()
        {
            var sutXml          = new MembersXml();
            var ctrXml          = new ExistsXml();
            var testCaseFactory = new TestCaseFactory();

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

            Assert.That(actual, Is.False);
        }
Example #5
0
        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);
        }
Example #6
0
        public void GetSystemUnderTest_Build_CorrectSystemUnderTest()
        {
            var sutXml = new StructureXml();
            var item   = new PerspectiveXml();

            sutXml.Item           = item;
            item.ConnectionString = ConnectionStringReader.GetAdomd();
            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 <StructureDiscoveryCommand>());
        }
Example #7
0
        public void GetConstraint_Build_CorrectConstraint()
        {
            var sutXml = new StructureXml();
            var item   = new HierarchyXml();

            item.ConnectionString = ConnectionStringReader.GetAdomd();
            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>());
        }
Example #8
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, 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 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();
        }
Example #9
0
        public void GetConstraint_BuildWithoutIgnoreCase_ComparerCaseSensitive()
        {
            var sutXml = new StructureXml();
            var item   = new PerspectiveXml();

            sutXml.Item           = item;
            item.ConnectionString = ConnectionStringReader.GetAdomd();
            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 <Comparer>());
            Assert.That(existsCtr.Comparer.Compare("c", "C"), Is.Not.EqualTo(0));
        }
Example #10
0
        public void GetConstraint_BuildWithIgnoreCase_ComparerCaseInsensitive()
        {
            var sutXml = new StructureXml();
            var item   = new PerspectiveXml();

            sutXml.Item           = item;
            item.ConnectionString = "connectionString";
            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 <NBi.Core.Analysis.Metadata.Field.ComparerByCaption>());
            Assert.That(existsCtr.Comparer.Compare("c", "C"), Is.EqualTo(0));
        }
Example #11
0
        protected global::NUnit.Framework.Constraints.Constraint InstantiateConstraint(ExistsXml ctrXml)
        {
            var ctr = new ExistsConstraint();

            //Ignore-case if requested
            if (ctrXml.IgnoreCase)
            {
                ctr = ctr.IgnoreCase;
            }
            return(ctr);
        }