Пример #1
0
        public void GetConstraint_BuildWithQuery_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 EqualToXml(SettingsXml.Empty);

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

            var builder = new ResultSetEqualToBuilder();

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

            Assert.That(ctr, Is.InstanceOf <EqualToConstraint>());
        }
Пример #2
0
        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 EqualToXml(SettingsXml.Empty);

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

            var builder = new ResultSetEqualToBuilder();

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

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

            Assert.That(settings.GetTolerance(1).ValueString, Is.EqualTo("10"));
        }
Пример #3
0
        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 EqualToXml(true);

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

            var builder = new ResultSetEqualToBuilder();

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

            Assert.That(ctr, Is.InstanceOf <EqualToConstraint>());
            Assert.That(((EqualToConstraint)ctr).Engine, Is.InstanceOf <SingleRowComparer>());
            Assert.That(((EqualToConstraint)ctr).Engine.Settings, Is.InstanceOf <SettingsSingleRowComparison>());
        }
Пример #4
0
        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 EqualToXml(SettingsXml.Empty);

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

            var builder = new ResultSetEqualToBuilder();

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

            Assert.That(sut, Is.InstanceOf <IDbCommand>());
        }
Пример #5
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 ctrXmlStubFactory = new Mock <EqualToXml>();

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

            var builder = new ResultSetEqualToBuilder();

            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 GetSystemUnderTest_ResultSetSystemXml_IResultSetService()
        {
            var sutXmlStub = new Mock <Systems.ResultSetSystemXml>();

            sutXmlStub.Setup(s => s.File.Path).Returns("myFile.csv");
            var sutXml = sutXmlStub.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 ResultSetEqualToBuilder();

            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>());
        }
Пример #7
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 ctrXml = new EqualToXml(true)
            {
                ResultSet = new ResultSetXml()
            };

            var builder = new ResultSetEqualToBuilder();

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

            Assert.That(ctr, Is.InstanceOf <EqualToConstraint>());
            Assert.That(((EqualToConstraint)ctr).IsParallelizeQueries(), Is.True);
        }
Пример #8
0
        public void GetConstraint_BuildWithQuery_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 <EqualToXml>();

            ctrXmlStubFactory.Setup(i => i.GetCommand()).Returns(new SqlCommand());
            ctrXmlStubFactory.SetupGet(i => i.BaseItem).Returns(new QueryXml()
            {
                InlineQuery = "query", ConnectionString = "connStr"
            });
            ctrXmlStubFactory.SetupGet(i => i.Settings).Returns(SettingsXml.Empty);
            var ctrXml = ctrXmlStubFactory.Object;

            var builder = new ResultSetEqualToBuilder();

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

            Assert.That(ctr, Is.InstanceOf <EqualToConstraint>());
        }
Пример #9
0
        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 ctrXmlStubFactory = new Mock <EqualToXml>();

            ctrXmlStubFactory.Setup(i => i.GetCommand()).Returns(new SqlCommand());
            ctrXmlStubFactory.SetupGet(i => i.BaseItem).Returns(new QueryXml()
            {
                InlineQuery = "query", ConnectionString = "connStr"
            });
            ctrXmlStubFactory.SetupGet(i => i.Settings).Returns(SettingsXml.Empty);
            ctrXmlStubFactory.SetupGet(i => i.Tolerance).Returns("10");
            var ctrXml = ctrXmlStubFactory.Object;

            var builder = new ResultSetEqualToBuilder();

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

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

            Assert.That(settings.GetTolerance(1).ValueString, Is.EqualTo("10"));
        }
        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 SupersetOfXml(SettingsXml.Empty)
            {
                Query = new QueryXml()
                {
                    InlineQuery = "query"
                }
            };

            var builder = new ResultSetEqualToBuilder();

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

            Assert.That(sut, Is.Not.Null);
            Assert.That(sut, Is.InstanceOf <IResultSetService>());
        }
Пример #11
0
        public void GetConstraint_BuildWithResultSet_CorrectConstraint()
        {
            var sutXmlStubFactory  = new Mock <Systems.ExecutionXml>();
            var itemXmlStubFactory = new Mock <QueryXml>();

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

            sutXml.Item = itemXmlStubFactory.Object;

            var ctrXml = new EqualToXml(SettingsXml.Empty)
            {
                ResultSetOld = new ResultSetXml()
            };

            var builder = new ResultSetEqualToBuilder();

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

            Assert.That(ctr, Is.InstanceOf <EqualToConstraint>());
        }
Пример #12
0
        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 EqualToXml(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 ResultSetEqualToBuilder();

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

            Assert.That(ctr, Is.InstanceOf <EqualToConstraint>());
            Assert.That(((EqualToConstraint)ctr).TransformationProvider, Is.Not.Null);
        }
Пример #13
0
        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 ctrXmlStubFactory = new Mock <EqualToXml>();

            ctrXmlStubFactory.Setup(i => i.GetCommand()).Returns(new SqlCommand());
            ctrXmlStubFactory.SetupGet(i => i.BaseItem).Returns(new QueryXml()
            {
                InlineQuery = "select top(1) * from Table;"
            });
            ctrXmlStubFactory.SetupGet(i => i.Settings).Returns(SettingsXml.Empty);
            ctrXmlStubFactory.SetupGet(i => i.Behavior).Returns(EqualToXml.ComparisonBehavior.SingleRow);
            var ctrXml = ctrXmlStubFactory.Object;

            var builder = new ResultSetEqualToBuilder();

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

            Assert.That(ctr, Is.InstanceOf <EqualToConstraint>());
            Assert.That(((EqualToConstraint)ctr).Engine, Is.InstanceOf <SingleRowEquivaler>());
            Assert.That(((EqualToConstraint)ctr).Engine.Settings, Is.InstanceOf <SettingsSingleRowResultSet>());
        }
        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 SupersetOfXml(SettingsXml.Empty)
            {
                Query = new QueryXml()
                {
                    InlineQuery = "select * from query"
                }
            };

            var builder = new ResultSetEqualToBuilder();

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

            Assert.That(sut, Is.Not.Null);
            Assert.That(sut, Is.InstanceOf <IResultSetService>());
        }