Exemple #1
0
        public void GetSystemUnderTest_Build_CorrectIDbCommand()
        {
            //Buiding object used during test
            var sutXmlStubFactory  = new Mock <ExecutionXml>();
            var itemXmlStubFactory = new Mock <QueryableXml>();

            itemXmlStubFactory.Setup(i => i.GetQuery()).Returns("query");
            sutXmlStubFactory.Setup(s => s.Item).Returns(itemXmlStubFactory.Object);
            var sutXml = sutXmlStubFactory.Object;

            sutXml.Item = itemXmlStubFactory.Object;

            var ctrXml = new SyntacticallyCorrectXml();

            var builder = new ExecutionSyntacticallyCorrectBuilder();

            builder.Setup(sutXml, ctrXml);
            //Call the method to test
            builder.Build();
            var sut = builder.GetSystemUnderTest();

            //Assertion
            Assert.That(sut, Is.Not.Null);
            Assert.That(sut, Is.InstanceOf <IDbCommand>());
        }
        public void GetSystemUnderTest_Build_CorrectIDbCommandForSProc()
        {
            //Buiding object used during test
            var sutXmlStubFactory  = new Mock <ExecutionXml>();
            var itemXmlStubFactory = new Mock <ReportXml>();

            itemXmlStubFactory.Setup(i => i.GetQuery()).Returns("query");
            itemXmlStubFactory.Setup(i => i.GetCommandType()).Returns(CommandType.StoredProcedure);
            sutXmlStubFactory.Setup(s => s.Item).Returns(itemXmlStubFactory.Object);
            sutXmlStubFactory.Setup(s => s.BaseItem).Returns(itemXmlStubFactory.Object);
            var sutXml = sutXmlStubFactory.Object;

            sutXml.Item = itemXmlStubFactory.Object;

            var ctrXml = new SyntacticallyCorrectXml();

            var builder = new ExecutionSyntacticallyCorrectBuilder();

            builder.Setup(sutXml, ctrXml);
            //Call the method to test
            builder.Build();
            var sut = builder.GetSystemUnderTest();

            //Assertion
            Assert.That(sut, Is.InstanceOf <IDbCommand>());
            Assert.That((sut as IDbCommand).CommandType, Is.EqualTo(CommandType.StoredProcedure));
        }
Exemple #3
0
        public void GetConstraint_Build_CorrectConstraint()
        {
            //Buiding object used during test
            var sutXmlStubFactory  = new Mock <ExecutionXml>();
            var itemXmlStubFactory = new Mock <QueryXml>();

            itemXmlStubFactory.Setup(i => i.InlineQuery).Returns("query");
            itemXmlStubFactory.Setup(i => i.Settings).Returns(SettingsXml.Empty);
            sutXmlStubFactory.Setup(s => s.Item).Returns(itemXmlStubFactory.Object);
            var sutXml = sutXmlStubFactory.Object;

            sutXml.Item = itemXmlStubFactory.Object;

            var ctrXml = new SyntacticallyCorrectXml();

            var builder = new ExecutionSyntacticallyCorrectBuilder();

            builder.Setup(sutXml, ctrXml, null, null, new ServiceLocator());
            //Call the method to test
            builder.Build();
            var ctr = builder.GetConstraint();

            //Assertion
            Assert.That(ctr, Is.InstanceOf <SyntacticallyCorrectConstraint>());
        }