-
-
Save arielmagbanuazeald/b83633ec055478bc2ba8b0e0742e8dbf to your computer and use it in GitHub Desktop.
Test Class for IbsQueryBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
namespace ConsoleNancySelfHostedNetTest | |
{ | |
[TestClass] | |
public class TestIbsQueryBuilder | |
{ | |
public class MyModel : IbsQueryBuilder | |
{ | |
} | |
[TestMethod] | |
public void TestQueryBuilder() | |
{ | |
MyModel model = new MyModel(); | |
string query1 = model.Where("name", "Ariel Magbanua") | |
.Where("age", ">", "28") | |
.Where("gender", "M") | |
.ToQuery(); | |
string query2 = model.WhereRaw("foo=[bar] and max=3 or status=[active]") | |
.Where("age", ">", "30") | |
.ToQuery(); | |
string query3 = model.WhereRaw("foo=[bar] and max=3 or status=[active]") | |
.Where("age", ">", "30") | |
.OrWhere("role", "!=", "1") | |
.OrWhere("company", "Zeald") | |
.ToQuery(); | |
string query4 = model.Where("id", ">", "1") | |
.OrWhere("post_code", "8000") | |
.OrWhereRaw("city=[DAVAO] and bday=[1988-04-23]") | |
.ToQuery(); | |
Assert.AreEqual("name=[Ariel Magbanua] and age>28 and gender=[M]", query1); | |
Assert.AreEqual("foo=[bar] and max=3 or status=[active] and age>30", query2); | |
Assert.AreEqual("foo=[bar] and max=3 or status=[active] and age>30 or role!=1 or company=[Zeald]", query3); | |
Assert.AreEqual("id>1 or post_code=8000 or city=[DAVAO] and bday=[1988-04-23]", query4); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment