Ejemplo n.º 1
0
        public void Execute_Edge_DataSetFilled()
        {
            SqlClient           session          = new SqlClientFactory().Instantiate(ConnectionStringReader.GetLocaleSql()) as SqlClient;
            var                 statement        = Mock.Of <IQuery>(x => x.Statement == "SELECT * FROM FoF f WHERE f.label='knows'");
            SqlCommandOperation commandOperation = new SqlCommandFactory().Instantiate(session, statement).Implementation as SqlCommandOperation;

            var engine = new SqlExecutionEngine(session.CreateClientOperation(), commandOperation);

            var ds = engine.Execute();

            Assert.That(ds.Tables, Has.Count.EqualTo(1));
            Assert.That(ds.Tables[0].Rows, Has.Count.EqualTo(3));

            Assert.That(ds.Tables[0].Columns, Has.Count.EqualTo(12));
            Assert.That(ds.Tables[0].Columns.Cast <DataColumn>().Select(x => x.ColumnName), Has.Member("id"));
            Assert.That(ds.Tables[0].Columns.Cast <DataColumn>().Select(x => x.ColumnName), Has.Member("label"));
            Assert.That(ds.Tables[0].Columns.Cast <DataColumn>().Select(x => x.ColumnName), Has.Member("_sink"));
            Assert.That(ds.Tables[0].Columns.Cast <DataColumn>().Select(x => x.ColumnName), Has.Member("_vertexId"));
            Assert.That(ds.Tables[0].Columns.Cast <DataColumn>().Select(x => x.ColumnName), Has.Member("_sinkLabel"));
            Assert.That(ds.Tables[0].Columns.Cast <DataColumn>().Select(x => x.ColumnName), Has.Member("_vertexLabel"));

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                Assert.That(row["id"], Is.Not.Null.Or.Empty);
                Assert.That(row["_vertexLabel"], Is.EqualTo("person"));
                Assert.That(row["_sinkLabel"], Is.EqualTo("person"));
                Assert.That(row["_isEdge"], Is.True);
            }
        }
Ejemplo n.º 2
0
        public void Execute_WaitFor3SecondsTimeoutSetTo0_NoTimeOut()
        {
            var query = "WAITFOR DELAY '00:00:03';";
            var cmd   = new SqlCommand(query, new SqlConnection(ConnectionStringReader.GetSqlClient()))
            {
                CommandTimeout = 0
            };

            var qe = new SqlExecutionEngine(cmd.Connection, cmd);

            Assert.DoesNotThrow(delegate { qe.Execute(); });
        }
Ejemplo n.º 3
0
        public void Execute_ValidQuery_DataSetFilled()
        {
            var query = "select * from [Sales].[Currency];";
            var cmd   = new SqlCommand(query, new SqlConnection(ConnectionStringReader.GetSqlClient()))
            {
                CommandTimeout = 0
            };

            var qe = new SqlExecutionEngine(cmd.Connection, cmd);
            var ds = qe.Execute();

            Assert.That(ds.Tables, Has.Count.EqualTo(1));
            Assert.That(ds.Tables[0].Columns, Has.Count.EqualTo(3));
            Assert.That(ds.Tables[0].Rows, Has.Count.EqualTo(105));
        }
Ejemplo n.º 4
0
        public void Execute_ProjectionOfObjects_DataSetFilled()
        {
            SqlClient           session          = new SqlClientFactory().Instantiate(ConnectionStringReader.GetLocaleSql()) as SqlClient;
            var                 statement        = Mock.Of <IQuery>(x => x.Statement == "SELECT p.firstName[0]._value as FirstName, p.age[0]._value as Age FROM ROOT p WHERE p.label = 'person'");
            SqlCommandOperation commandOperation = new SqlCommandFactory().Instantiate(session, statement).Implementation as SqlCommandOperation;

            var engine = new SqlExecutionEngine(session.CreateClientOperation(), commandOperation);

            var ds = engine.Execute();

            Assert.That(ds.Tables, Has.Count.EqualTo(1));
            Assert.That(ds.Tables[0].Rows, Has.Count.EqualTo(4));

            Assert.That(ds.Tables[0].Columns, Has.Count.EqualTo(2));
            Assert.That(ds.Tables[0].Columns.Cast <DataColumn>().Select(x => x.ColumnName), Has.Member("FirstName"));
            Assert.That(ds.Tables[0].Columns.Cast <DataColumn>().Select(x => x.ColumnName), Has.Member("Age"));

            var firstNames = new List <object>();
            var ages       = new List <object>();

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
                {
                    if (row.Table.Columns[i].ColumnName == "FirstName")
                    {
                        firstNames.Add(row.ItemArray[i]);
                    }
                    else if (row.Table.Columns[i].ColumnName == "Age")
                    {
                        ages.Add(row.ItemArray[i]);
                    }
                }
            }

            foreach (var expectedFirstName in new[] { "Thomas", "Mary", "Ben", "Robin" })
            {
                Assert.That(firstNames, Has.Member(expectedFirstName));
            }

            foreach (var expectedAge in new object[] { 44, 39 })
            {
                Assert.That(ages, Has.Member(expectedAge));
            }
        }
Ejemplo n.º 5
0
        public void Execute_Vertex_DataSetFilled()
        {
            SqlClient           client           = new SqlClientFactory().Instantiate(ConnectionStringReader.GetLocaleSql()) as SqlClient;
            var                 statement        = Mock.Of <IQuery>(x => x.Statement == "SELECT * FROM FoF f WHERE f.label='person'");
            SqlCommandOperation commandOperation = new SqlCommandFactory().Instantiate(client, statement).Implementation as SqlCommandOperation;

            var engine = new SqlExecutionEngine(client.CreateClientOperation(), commandOperation);

            var ds = engine.Execute();

            Assert.That(ds.Tables, Has.Count.EqualTo(1));
            Assert.That(ds.Tables[0].Rows, Has.Count.EqualTo(4));

            Assert.That(ds.Tables[0].Columns.Cast <DataColumn>().Select(x => x.ColumnName), Has.Member("id"));
            Assert.That(ds.Tables[0].Columns.Cast <DataColumn>().Select(x => x.ColumnName), Has.Member("label"));
            Assert.That(ds.Tables[0].Columns.Cast <DataColumn>().Select(x => x.ColumnName), Has.Member("firstName"));
            Assert.That(ds.Tables[0].Columns.Cast <DataColumn>().Select(x => x.ColumnName), Has.Member("age"));
        }