Esempio n. 1
0
        public void GetConstraint_BuildWithQuery_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 ctrXmlStubFactory = new Mock <SupersetOfXml>();

            ctrXmlStubFactory.SetupGet(i => i.BaseItem).Returns(new QueryXml()
            {
                InlineQuery = "select * from Table;", ConnectionString = "connStr"
            });
            ctrXmlStubFactory.SetupGet(i => i.Settings).Returns(SettingsXml.Empty);
            var ctrXml = ctrXmlStubFactory.Object;

            var builder = new ResultSetSupersetOfBuilder();

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

            Assert.That(ctr, Is.InstanceOf <SupersetOfConstraint>());
        }
Esempio n. 2
0
        public void GetConstraint_BuildWithTolerance_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 ctrXmlStubFactory = new Mock <SupersetOfXml>();

            ctrXmlStubFactory.SetupGet(i => i.BaseItem).Returns(new QueryXml()
            {
                InlineQuery = "select * from Table;", ConnectionString = "connStr"
            });
            ctrXmlStubFactory.SetupGet(i => i.Settings).Returns(SettingsXml.Empty);
            ctrXmlStubFactory.SetupGet(i => i.Tolerance).Returns("10");
            var ctrXml  = ctrXmlStubFactory.Object;
            var builder = new ResultSetSupersetOfBuilder();

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

            Assert.That(ctr, Is.InstanceOf <SupersetOfConstraint>());
            //Get the tolerance for the column with 1 (and not 0) to avoid to get the tolerance on a key.
            var settings = ((SupersetOfConstraint)ctr).Engine.Settings as SettingsOrdinalResultSet;

            Assert.That(settings.GetTolerance(1).ValueString, Is.EqualTo("10"));
        }
Esempio n. 3
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 SupersetOfXml(SettingsXml.Empty)
            {
                ResultSetOld = new ResultSetXml()
            };

            var builder = new ResultSetSupersetOfBuilder();

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

            Assert.That(ctr, Is.InstanceOf <SupersetOfConstraint>());
        }
Esempio n. 4
0
        public void GetConstraint_BuildWithParallel_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 ctrXmlStubFactory = new Mock <SupersetOfXml>();

            ctrXmlStubFactory.SetupGet(i => i.Settings).Returns(SettingsXml.Empty);
            ctrXmlStubFactory.SetupGet(i => i.ResultSet).Returns(new ResultSetXml());
            var ctrXml = ctrXmlStubFactory.Object;

            var builder = new ResultSetSupersetOfBuilder();

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

            Assert.That(ctr, Is.InstanceOf <SupersetOfConstraint>());
            Assert.That(((SupersetOfConstraint)ctr).IsParallelizeQueries(), Is.True);
        }
        public void GetConstraint_SingleRow_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 columnDef = Mock.Of <ColumnDefinitionXml>
                            (
                c => c.Index == 1 &&
                c.Role == ColumnRole.Value &&
                c.Type == ColumnType.Text
                            );

            var ctrXml = new SupersetOfXml(true);

            ctrXml.Behavior          = SupersetOfXml.ComparisonBehavior.SingleRow;
            ctrXml.Query             = new QueryXml();
            ctrXml.Query.InlineQuery = "select * from Table;";

            var builder = new ResultSetSupersetOfBuilder();

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

            Assert.That(ctr, Is.InstanceOf <SupersetOfConstraint>());
            Assert.That(((SupersetOfConstraint)ctr).Engine, Is.InstanceOf <SingleRowComparer>());
            Assert.That(((SupersetOfConstraint)ctr).Engine.Settings, Is.InstanceOf <SettingsSingleRowComparison>());
        }
        public void GetSystemUnderTest_Build_CorrectDiscoveryCommand()
        {
            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 SupersetOfXml(SettingsXml.Empty);

            ctrXml.Query = new Items.QueryXml()
            {
                InlineQuery = "query"
            };

            var builder = new ResultSetSupersetOfBuilder();

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

            Assert.That(sut, Is.InstanceOf <IDbCommand>());
        }
        public void GetConstraint_BuildWithTolerance_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 SupersetOfXml(SettingsXml.Empty);

            ctrXml.Query = new Items.QueryXml()
            {
                InlineQuery = "query"
            };
            ctrXml.Tolerance = "10";

            var builder = new ResultSetSupersetOfBuilder();

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

            Assert.That(ctr, Is.InstanceOf <SupersetOfConstraint>());
            //Get the tolerance for the column with 1 (and not 0) to avoid to get the tolerance on a key.
            var settings = ((SupersetOfConstraint)ctr).Engine.Settings as SettingsResultSetComparisonByIndex;

            Assert.That(settings.GetTolerance(1).ValueString, Is.EqualTo("10"));
        }
        public void GetConstraint_Transformer_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 transformation = Mock.Of <TransformationXml>
                                 (
                t => t.Language == LanguageType.CSharp &&
                t.OriginalType == ColumnType.Text &&
                t.Code == "value.Substring(2)"
                                 );

            var columnDef = Mock.Of <ColumnDefinitionXml>
                            (
                c => c.Index == 1 &&
                c.Role == ColumnRole.Value &&
                c.Type == ColumnType.Text &&
                c.TransformationInner == transformation
                            );

            var ctrXml = new SupersetOfXml(true);

            ctrXml.Query             = new QueryXml();
            ctrXml.Query.InlineQuery = "select * from Table;";
            Assert.That(ctrXml.ColumnsDef.Count, Is.EqualTo(0));
            ctrXml.columnsDef.Add(columnDef);
            Assert.That(ctrXml.ColumnsDef.Count, Is.EqualTo(1));

            var builder = new ResultSetSupersetOfBuilder();

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

            Assert.That(ctr, Is.InstanceOf <SupersetOfConstraint>());
            Assert.That(((SupersetOfConstraint)ctr).TransformationProvider, Is.Not.Null);
        }