コード例 #1
0
        public void GetConstraint_BuildWithResultSet_CorrectConstraint()
        {
            var sutXmlStubFactory  = new Mock <Systems.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 AllRowsXml
            {
                Predication = new PredicationXml()
                {
                    Predicate = new MoreThanXml()
                    {
                        Value = "100"
                    },
                    Operand = "#0"
                }
            };

            var builder = new ResultSetAllRowsBuilder();

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

            Assert.That(ctr, Is.InstanceOf <AllRowsConstraint>());
            var allRows = ctr as AllRowsConstraint;

            Assert.That(allRows.Differed, Is.Null);
        }
コード例 #2
0
        public void GetSystemUnderTest_ExecutionXml_IResultSetService()
        {
            var sutXmlStubFactory  = new Mock <Systems.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 AllRowsXml()
            {
                Predication = new PredicationXml()
                {
                    Predicate = new MoreThanXml()
                    {
                        Value = "10"
                    },
                    Operand = "#0"
                }
            };

            var builder = new ResultSetAllRowsBuilder();

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

            Assert.That(sut, Is.Not.Null);
            Assert.That(sut, Is.InstanceOf <IResultSetService>());
        }
コード例 #3
0
        public void GetSystemUnderTest_ResultSetSystemXml_IResultSetService()
        {
            var sutXmlStub = new Mock <Systems.ResultSetSystemXml>();

            sutXmlStub.Setup(s => s.File).Returns("myFile.csv");
            var sutXml = sutXmlStub.Object;

            var ctrXml = new AllRowsXml()
            {
                Predication = new PredicationXml()
                {
                    Predicate = new MoreThanXml()
                    {
                        Value = "10"
                    },
                    Operand = "#0"
                }
            };

            var builder = new ResultSetAllRowsBuilder();

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

            Assert.That(sut, Is.Not.Null);
            Assert.That(sut, Is.InstanceOf <IResultSetService>());
        }
コード例 #4
0
        public void GetConstraint_BuildWithResultSet_CorrectConstraint()
        {
            var sutXmlStubFactory  = new Mock <Systems.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 AllRowsXml
            {
                Predication = new SinglePredicationXml()
                {
                    Predicate = new MoreThanXml()
                    {
                        Reference = "100"
                    },
                    Operand = new ColumnOrdinalIdentifier(0)
                }
            };

            var builder = new ResultSetAllRowsBuilder();

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

            Assert.That(ctr, Is.InstanceOf <AllRowsConstraint>());
            var allRows = ctr as AllRowsConstraint;

            Assert.That(allRows.Differed, Is.Null);
        }
コード例 #5
0
        public void GetSystemUnderTest_ExecutionXml_IResultSetService()
        {
            var sutXmlStubFactory  = new Mock <Systems.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 AllRowsXml()
            {
                Predication = new SinglePredicationXml()
                {
                    Predicate = new MoreThanXml()
                    {
                        Reference = "10"
                    },
                    Operand = new ColumnOrdinalIdentifier(0)
                }
            };

            var builder = new ResultSetAllRowsBuilder();

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

            Assert.That(sut, Is.Not.Null);
            Assert.That(sut, Is.InstanceOf <IResultSetService>());
        }
コード例 #6
0
        public void GetConstraint_BuildWithVariables_DontEvaluateThem()
        {
            var sutXmlStubFactory  = new Mock <Systems.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 AllRowsXml
            {
                Predication = new SinglePredicationXml()
                {
                    Predicate = new MoreThanXml()
                    {
                        Reference = "@year"
                    },
                    Operand = new ColumnOrdinalIdentifier(0)
                }
            };

            var yearResolverMock = new Mock <ITestVariable>();

            yearResolverMock.Setup(x => x.GetValue()).Returns(2017);
            var notUsedResolverMock = new Mock <ITestVariable>();

            notUsedResolverMock.Setup(x => x.GetValue());

            var variables = new Dictionary <string, ITestVariable>()
            {
                { "year", yearResolverMock.Object },
                { "NotUsed", notUsedResolverMock.Object }
            };

            var builder = new ResultSetAllRowsBuilder();

            builder.Setup(sutXml, ctrXml, null, variables, new ServiceLocator());
            builder.Build();

            notUsedResolverMock.Verify(x => x.GetValue(), Times.Never);
        }
コード例 #7
0
        public void GetConstraint_BuildWithVariables_DontEvaluateThem()
        {
            var sutXmlStubFactory  = new Mock <Systems.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 AllRowsXml
            {
                Predication = new PredicationXml()
                {
                    Predicate = new MoreThanXml()
                    {
                        Value = "@year"
                    },
                    Operand = "#0"
                }
            };

            var yearResolverMock = new Mock <ITestVariable>();

            yearResolverMock.Setup(x => x.GetValue()).Returns(2017);
            var notUsedResolverMock = new Mock <ITestVariable>();

            notUsedResolverMock.Setup(x => x.GetValue());

            var variables = new Dictionary <string, ITestVariable>()
            {
                { "year", yearResolverMock.Object },
                { "NotUsed", notUsedResolverMock.Object }
            };

            var builder = new ResultSetAllRowsBuilder();

            builder.Setup(sutXml, ctrXml, null, variables);
            builder.Build();

            notUsedResolverMock.Verify(x => x.GetValue(), Times.Never);
        }
コード例 #8
0
        public void GetConstraint_Build_DontEvaluateVariable()
        {
            var sutXmlStubFactory  = new Mock <Systems.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 AllRowsXml
            {
                Predication = new PredicationXml()
                {
                    Predicate = new MoreThanXml {
                        Value = "@year"
                    },
                    Operand = new ColumnOrdinalIdentifier(0)
                }
            };

            var yearResolverMock = new Mock <ITestVariable>();

            yearResolverMock.Setup(x => x.GetValue()).Returns(2017);
            yearResolverMock.Setup(x => x.IsEvaluated()).Returns(false);

            var variables = new Dictionary <string, ITestVariable>()
            {
                { "year", yearResolverMock.Object }
            };

            var builder = new ResultSetAllRowsBuilder();

            builder.Setup(sutXml, ctrXml, null, variables, new ServiceLocator());
            builder.Build();

            //The variable is not evaluated during the build of constraint (introduced in 1.19)
            yearResolverMock.Verify(x => x.GetValue(), Times.Never);
        }