forked from Taritsyn/JavaScriptEngineSwitcher
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInteropTests.cs
More file actions
98 lines (67 loc) · 1.76 KB
/
InteropTests.cs
File metadata and controls
98 lines (67 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using System;
using Xunit;
using JavaScriptEngineSwitcher.Tests.Interop;
namespace JavaScriptEngineSwitcher.Tests.Jurassic
{
public class InteropTests : InteropTestsBase
{
protected override string EngineName
{
get { return "JurassicJsEngine"; }
}
#region Embedding of objects
#region Objects with fields
public override void EmbeddingOfInstanceOfCustomValueTypeWithReadonlyField()
{
// Arrange
var age = new Age(1979);
const string updateCode = "age.Year = 1982;";
const string input = "age.Year";
const int targetOutput = 1982;
// Act
int output;
using (var jsEngine = CreateJsEngine())
{
jsEngine.EmbedHostObject("age", age);
jsEngine.Execute(updateCode);
output = jsEngine.Evaluate<int>(input);
}
// Assert
Assert.Equal(targetOutput, output);
}
#endregion
#region Objects with properties
public override void EmbeddingOfInstanceOfAnonymousTypeWithProperties()
{ }
#endregion
#region Delegates
public override void EmbeddingOfInstanceOfDelegateAndCallingItWithMissingParameter()
{
// Arrange
var sumFunc = new Func<int, int, int>((a, b) => a + b);
const string input = "sum(678)";
const int targetOutput = 678;
// Act
int output;
using (var jsEngine = CreateJsEngine())
{
jsEngine.EmbedHostObject("sum", sumFunc);
output = jsEngine.Evaluate<int>(input);
}
// Assert
Assert.Equal(targetOutput, output);
}
#endregion
#endregion
#region Embedding of types
#region Types with constants
public override void EmbeddingOfBuiltinReferenceTypeWithConstants()
{ }
public override void EmbeddingOfCustomValueTypeWithConstants()
{ }
public override void EmbeddingOfCustomReferenceTypeWithConstant()
{ }
#endregion
#endregion
}
}