simple xml data source to be used as a replacement to sql server for a poor
Xml Data Source
simple xml data source to be used as a replacement to sql server for a poor
Project Description
The framework will be used for creating easy and simple xml data source to be used as a replacement to sql server for a poor, simple, non-complicated environment. All Access to the data is done via simple sql queries as "select" "insert" "update" and "delete". All queries are executed with simplistic assumptions and best try to return results without any exceptions.
[Test]
public void TestCreateTable3()
{
XmlParsedCommand command = SqlParserWrapper.ParseCommandBeta("create table users (id,firstname)");
Assert.IsTrue(command.Type == XmlParsedCommand.CommandType.Create, "command type");
Assert.IsTrue(command.TableName == "users", "table name");
Assert.IsTrue(command.Fields.Contains("id"));
Assert.IsTrue(command.Fields.Contains("firstname"));
}
DropTable
[Test]
public void TestDropTable1()
{
XmlParsedCommand command = SqlParserWrapper.ParseCommandBeta("drop table users");
Assert.IsTrue(command.Type == XmlParsedCommand.CommandType.Drop, "command type");
Assert.IsTrue(command.TableName == "users", "table name");
}
Insert
[Test]
public void TestInsert2()
{
XmlParsedCommand command = SqlParserWrapper.ParseCommandBeta("insert into users (id) values (3)");
Assert.IsTrue(command.Type == XmlParsedCommand.CommandType.Insert, "command type");
Assert.IsTrue(command.TableName == "users", "table name");
Assert.IsTrue(command.KeysValues["id"] == "3");
}
Update
[Test]
public void TestUpdate2()
{
XmlParsedCommand command = SqlParserWrapper.ParseCommandBeta("Update users set username='tal'");
Assert.IsTrue(command.Type == XmlParsedCommand.CommandType.Update, "command type");
Assert.IsTrue(command.TableName == "users", "table name");
Assert.IsTrue(command.KeysValues["username"] == "tal");
}
Delete
[Test]
public void TestDelete5()
{
XmlParsedCommand command = SqlParserWrapper.ParseCommandBeta("delete from users where id='3' and username='tal' and age=31");
Assert.IsTrue(command.Type == XmlParsedCommand.CommandType.Delete, "command type");
Assert.IsTrue(command.TableName == "users", "table name");
Debug.WriteLine(command.Filter["id"]);
Assert.IsTrue(command.Filter["id"] == "3", "bad filter : id");
Debug.WriteLine(command.Filter["username"]);
Assert.IsTrue(command.Filter["username"] == "tal", "bad filter : username");
Assert.IsTrue(command.Filter["age"] == "31", "bad filter : age");
}
Select
[Test]
public void TestSelect4()
{
XmlParsedCommand command = SqlParserWrapper.ParseCommandBeta("select id,firstname,age from users where id=3");
Assert.IsTrue(command.Type == XmlParsedCommand.CommandType.Select, "command type");
Assert.IsTrue(command.TableName == "users", "table name");
Assert.IsTrue(command.Fields.Contains("id"));
Assert.IsTrue(command.Fields.Contains("firstname"));
Assert.IsTrue(command.Fields.Contains("age"));
Assert.IsTrue(command.Filter["id"] == "3");
}
http://www.codeplex.com/XmlData