Skip to content

Commit 1b54aeb

Browse files
committed
Added a tests for variables and functions with names containing Unicode characters
1 parent 694d2eb commit 1b54aeb

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

build/common.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Copyright>Copyright © 2012-2018 Andrey Taritsyn</Copyright>
44
</PropertyGroup>
55

6-
<PropertyGroup Condition=" '$(TargetFramework)' == 'net40-client' Or '$(TargetFramework)' == 'net45' Or '$(TargetFramework)' == 'net451' ">
6+
<PropertyGroup Condition=" '$(TargetFramework)' == 'net40-client' Or '$(TargetFramework)' == 'net45' Or '$(TargetFramework)' == 'net451' Or '$(TargetFramework)' == 'net46' ">
77
<DefineConstants>$(DefineConstants);NETFULL</DefineConstants>
88
</PropertyGroup>
99

test/MsieJavaScriptEngine.Test.Common/CommonTestsBase.cs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,29 @@ public virtual void CallingOfFunctionWithManyParametersAndUnicodeStringResultIsC
638638
Assert.AreEqual("Привет, Петя!", output);
639639
}
640640

641+
[Test]
642+
public virtual void CallingOfFunctionWithNameContainingUnicodeCharactersIsCorrect()
643+
{
644+
// Arrange
645+
const string functionCode = @"function сумма(число1, число2) {
646+
var результат = число1 + число2;
647+
648+
return результат;
649+
}";
650+
651+
// Act
652+
int output;
653+
654+
using (var jsEngine = CreateJsEngine())
655+
{
656+
jsEngine.Execute(functionCode);
657+
output = jsEngine.CallFunction<int>("сумма", 678, 711);
658+
}
659+
660+
// Assert
661+
Assert.AreEqual(1389, output);
662+
}
663+
641664
#endregion
642665

643666
#region Getting, setting and removing variables
@@ -916,6 +939,30 @@ public virtual void RemovingVariableIsCorrect()
916939
Assert.IsFalse(variableAfterRemovingExists);
917940
}
918941

942+
[Test]
943+
public virtual void RemovingVariableWithNameContainingUnicodeCharactersIsCorrect()
944+
{
945+
// Arrange
946+
const string variableName = "цена";
947+
const double input = 6780.00;
948+
949+
// Act
950+
bool variableBeforeRemovingExists;
951+
bool variableAfterRemovingExists;
952+
953+
using (var jsEngine = CreateJsEngine())
954+
{
955+
jsEngine.SetVariableValue(variableName, input);
956+
variableBeforeRemovingExists = jsEngine.HasVariable(variableName);
957+
jsEngine.RemoveVariable(variableName);
958+
variableAfterRemovingExists = jsEngine.HasVariable(variableName);
959+
}
960+
961+
// Assert
962+
Assert.IsTrue(variableBeforeRemovingExists);
963+
Assert.IsFalse(variableAfterRemovingExists);
964+
}
965+
919966
#endregion
920967

921968
#region Script interruption

0 commit comments

Comments
 (0)