Пример #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"));
 }
Пример #2
0
 public void ExpressionTranslator_Valid_UnaryOperators()
 {
     var translator = new ExpressionTranslator();
     Assert.AreEqual("-FirstName()", translator.Translate("-FirstName"));
     Assert.AreEqual("!FirstName()", translator.Translate("!FirstName"));
 }
Пример #3
0
 public void ExpressionTranslator_Valid_StringLiteral()
 {
     var translator = new ExpressionTranslator();
     Assert.AreEqual("IsCompleted() ? \"completed\" : \"\"", translator.Translate("IsCompleted ? \"completed\" : \"\""));
 }
Пример #4
0
 public void ExpressionTranslator_Valid_NumericLiteral()
 {
     var translator = new ExpressionTranslator();
     Assert.AreEqual("IsCompleted() ? 1 : 1.64", translator.Translate("IsCompleted ? 1 : 1.64"));
 }
Пример #5
0
 public void ExpressionTranslator_Valid_ExpressionWithParenthesis()
 {
     var translator = new ExpressionTranslator();
     Assert.AreEqual("Title() * (FirstName() / LastName())", translator.Translate("Title * (FirstName / LastName)"));
 }
Пример #6
0
 public void ExpressionTranslator_Valid_ExpressionWithDots()
 {
     var translator = new ExpressionTranslator();
     Assert.AreEqual("((Customer()||{}).Name()||{}).FirstName", translator.Translate("Customer.Name.FirstName"));
 }