public void SparqlResultSetToDataTable9()
        {
            SparqlResultSet results = new SparqlResultSet();

            try
            {
                DataTable table = results.ToDataTable();
                Assert.True(false, "Should have thrown an InvalidCastException");
            }
            catch (InvalidCastException ex)
            {
                Assert.Equal(SparqlResultsType.Unknown, results.ResultsType);
                Console.WriteLine("Errored as expected");
                Console.WriteLine();
                TestTools.ReportError("Invalid Cast", ex);
            }
        }
        public void SparqlResultSetToDataTable8()
        {
            SparqlResultSet rset = new SparqlResultSet(false);

            DataTable table = rset.ToDataTable();

            Assert.True(rset.ResultsType == SparqlResultsType.Boolean);
            Assert.Equal(table.Columns.Count, 1);
            Assert.Equal(table.Rows.Count, 1);
            Assert.False((bool)table.Rows[0]["ASK"], "Should be false");

            foreach (DataRow row in table.Rows)
            {
                foreach (DataColumn col in table.Columns)
                {
                    Object temp = row[col];
                    Console.Write(col.ColumnName + " = " + ((temp != null) ? temp.ToString() : String.Empty) + " , ");
                }
                Console.WriteLine();
            }
        }
        public void SparqlResultSetToDataTable6()
        {
            String            query  = "ASK WHERE {?s <http://example.org/noSuchPredicate> ?o}";
            SparqlQueryParser parser = new SparqlQueryParser();
            SparqlQuery       q      = parser.ParseFromString(query);

            Graph g = new Graph();

            FileLoader.Load(g, "resources\\InferenceTest.ttl");

            Object results = g.ExecuteQuery(q);

            if (results is SparqlResultSet)
            {
                SparqlResultSet rset = (SparqlResultSet)results;

                DataTable table = rset.ToDataTable();

                Assert.True(rset.ResultsType == SparqlResultsType.Boolean);
                Assert.Equal(table.Columns.Count, 1);
                Assert.Equal(table.Rows.Count, 1);
                Assert.False((bool)table.Rows[0]["ASK"], "Should be false");

                foreach (DataRow row in table.Rows)
                {
                    foreach (DataColumn col in table.Columns)
                    {
                        Object temp = row[col];
                        Console.Write(col.ColumnName + " = " + ((temp != null) ? temp.ToString() : String.Empty) + " , ");
                    }
                    Console.WriteLine();
                }
            }
            else
            {
                Assert.True(false, "Query should have returned a Result Set");
            }
        }
        public void SparqlResultSetToDataTable4()
        {
            String            query  = "PREFIX ex: <http://example.org/vehicles/> SELECT * WHERE {?s a ex:Car . OPTIONAL { ?s ex:Speed ?speed }}";
            SparqlQueryParser parser = new SparqlQueryParser();
            SparqlQuery       q      = parser.ParseFromString(query);

            Graph g = new Graph();

            FileLoader.Load(g, "resources\\InferenceTest.ttl");

            Object results = g.ExecuteQuery(q);

            if (results is SparqlResultSet)
            {
                SparqlResultSet rset = (SparqlResultSet)results;

                DataTable table = rset.ToDataTable();

                Assert.Equal(rset.Variables.Count(), table.Columns.Count);
                Assert.Equal(rset.Count, table.Rows.Count);

                foreach (DataRow row in table.Rows)
                {
                    foreach (DataColumn col in table.Columns)
                    {
                        Object temp = row[col];
                        Console.Write(col.ColumnName + " = " + ((temp != null) ? temp.ToString() : String.Empty) + " , ");
                    }
                    Console.WriteLine();
                }
            }
            else
            {
                Assert.True(false, "Query should have returned a Result Set");
            }
        }