Exemple #1
0
        //"PATCH/Resources//Name='Milan'/Name='Marko'"
        public void TestGeneratePatch()
        {
            Request        request  = new Request("PATCH", "Resources/", "Name='Milan'", "Name='Marko'");
            string         json     = JsonConvert.SerializeObject(request, Newtonsoft.Json.Formatting.Indented);
            XmlToDBAdapter adapter  = new XmlToDBAdapter();
            string         sql      = adapter.Convert(JsonConvert.DeserializeXNode(json, "Request"));
            string         expected = "UPDATE Resources SET Name='Marko' WHERE Name='Milan';";

            Assert.AreEqual(sql, expected);
        }
Exemple #2
0
        //DELETE/Resources//Name='Milan';Description='opis'
        public void TestGenerateDelete()
        {
            Request        request  = new Request("DELETE", "Resources/", "Name='Milan';Description='opis", null);
            string         json     = JsonConvert.SerializeObject(request, Newtonsoft.Json.Formatting.Indented);
            XmlToDBAdapter adapter  = new XmlToDBAdapter();
            string         sql      = adapter.Convert(JsonConvert.DeserializeXNode(json, "Request"));
            string         expected = "DELETE FROM Resources WHERE Name='Milan' and Description='opis;";

            Assert.AreEqual(sql, expected);
        }
Exemple #3
0
        //GET/Resources//Name='Petar';Description='opis'/Name;Description
        public void TestGenerateGet2()
        {
            Request        request  = new Request("GET", "Resources/", "Name='Petar';Description='opis'", "Name;Description");
            string         json     = JsonConvert.SerializeObject(request, Newtonsoft.Json.Formatting.Indented);
            XmlToDBAdapter adapter  = new XmlToDBAdapter();
            string         sql      = adapter.Convert(JsonConvert.DeserializeXNode(json, "Request"));
            string         expected = "SELECT Name,Description FROM Resources WHERE Name='Petar' and Description='opis';";

            Assert.AreEqual(sql, expected);
        }
Exemple #4
0
        //POST/Resources//Name;Description/'Milan';'Description'
        public void TestGeneratePost()
        {
            Request        request  = new Request("POST", "Resources/", "Name;Description", "'Milan';'Description'");
            string         json     = JsonConvert.SerializeObject(request, Newtonsoft.Json.Formatting.Indented);
            XmlToDBAdapter adapter  = new XmlToDBAdapter();
            string         sql      = adapter.Convert(JsonConvert.DeserializeXNode(json, "Request"));
            string         expected = "INSERT Into Resources (Name, Description) VALUES ('Milan', 'Description');";

            Assert.AreEqual(sql, expected);
        }
Exemple #5
0
        //GET/Resources/1
        public void TestGenerateGet()
        {
            Request        request  = new Request("GET", "Resurs/1", null, null);
            string         json     = JsonConvert.SerializeObject(request);
            XmlToDBAdapter adapter  = new XmlToDBAdapter();
            string         sql      = adapter.Convert(JsonConvert.DeserializeXNode(json, "Request"));
            string         expected = "SELECT * FROM Resources WHERE Id = 1;";

            Assert.AreEqual(sql, expected);
        }