Exemplo n.º 1
0
 public void ExpressionTranslator_Valid_BinaryOperators()
 {
     var translator = new ExpressionTranslator();
     Assert.AreEqual("FirstName() + LastName()", translator.Translate(" FirstName +   LastName "));
     Assert.AreEqual("FirstName() - LastName()", translator.Translate("FirstName-LastName"));
     Assert.AreEqual("FirstName() * LastName()", translator.Translate("FirstName * LastName"));
     Assert.AreEqual("FirstName() / LastName()", translator.Translate("FirstName / LastName"));
     Assert.AreEqual("FirstName() % LastName()", translator.Translate("FirstName % LastName"));
     Assert.AreEqual("FirstName() < LastName()", translator.Translate("FirstName < LastName"));
     Assert.AreEqual("FirstName() <= LastName()", translator.Translate("FirstName <= LastName"));
     Assert.AreEqual("FirstName() > LastName()", translator.Translate("FirstName > LastName"));
     Assert.AreEqual("FirstName() >= LastName()", translator.Translate("FirstName >= LastName"));
     Assert.AreEqual("FirstName() === LastName()", translator.Translate("FirstName == LastName"));
     Assert.AreEqual("FirstName() !== LastName()", translator.Translate("FirstName != LastName"));
     Assert.AreEqual("FirstName() && LastName()", translator.Translate("FirstName && LastName"));
     Assert.AreEqual("FirstName() & LastName()", translator.Translate("FirstName & LastName"));
     Assert.AreEqual("FirstName() || LastName()", translator.Translate("FirstName || LastName"));
     Assert.AreEqual("FirstName() | LastName()", translator.Translate("FirstName | LastName"));
 }
Exemplo n.º 2
0
 public void ExpressionTranslator_Valid_UnaryOperators()
 {
     var translator = new ExpressionTranslator();
     Assert.AreEqual("-FirstName()", translator.Translate("-FirstName"));
     Assert.AreEqual("!FirstName()", translator.Translate("!FirstName"));
 }
Exemplo n.º 3
0
 public void ExpressionTranslator_Valid_StringLiteral()
 {
     var translator = new ExpressionTranslator();
     Assert.AreEqual("IsCompleted() ? \"completed\" : \"\"", translator.Translate("IsCompleted ? \"completed\" : \"\""));
 }
Exemplo n.º 4
0
 public void ExpressionTranslator_Valid_NumericLiteral()
 {
     var translator = new ExpressionTranslator();
     Assert.AreEqual("IsCompleted() ? 1 : 1.64", translator.Translate("IsCompleted ? 1 : 1.64"));
 }
Exemplo n.º 5
0
 public void ExpressionTranslator_Valid_ExpressionWithParenthesis()
 {
     var translator = new ExpressionTranslator();
     Assert.AreEqual("Title() * (FirstName() / LastName())", translator.Translate("Title * (FirstName / LastName)"));
 }
Exemplo n.º 6
0
 public void ExpressionTranslator_Valid_ExpressionWithDots()
 {
     var translator = new ExpressionTranslator();
     Assert.AreEqual("((Customer()||{}).Name()||{}).FirstName", translator.Translate("Customer.Name.FirstName"));
 }