FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ClearScript/ClearScriptTest/VBScriptCoreEngineTest.Windows.cs at master · r2d2m/ClearScript · GitHub
r2d2m
/
ClearScript
Public
forked from
ClearFoundry/ClearScript
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
ClearScript
/
ClearScriptTest
/
VBScriptCoreEngineTest.Windows.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
79 lines (66 loc) · 2.99 KB
Breadcrumbs
ClearScript
/
ClearScriptTest
/
VBScriptCoreEngineTest.Windows.cs
Copy path
File metadata and controls
79 lines (66 loc) · 2.99 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using
System
;
using
System
.
Threading
;
using
System
.
Windows
.
Threading
;
using
Microsoft
.
ClearScript
.
Windows
.
Core
;
using
Microsoft
.
VisualStudio
.
TestTools
.
UnitTesting
;
namespace
Microsoft
.
ClearScript
.
Test
{
public
partial
class
VBScriptCoreEngineTest
{
#region test methods
[
TestMethod
,
TestCategory
(
"VBScriptCoreEngine"
)
]
public
void
VBScriptCoreEngine_AddCOMType_XMLHTTP
(
)
{
var
status
=
0
;
string
data
=
null
;
var
thread
=
new
Thread
(
(
)
=>
{
using
(
var
testEngine
=
new
VBScriptEngine
(
Windows
.
WindowsScriptEngineFlags
.
EnableDebugging
,
NullSyncInvoker
.
Instance
)
)
{
using
(
var
helperEngine
=
new
JScriptEngine
(
Windows
.
WindowsScriptEngineFlags
.
EnableStandardsMode
,
NullSyncInvoker
.
Instance
)
)
{
// ReSharper disable AccessToDisposedClosure
testEngine
.
Script
.
onComplete
=
new
Action
<
int
,
string
>
(
(
xhrStatus
,
xhrData
)
=>
{
status
=
xhrStatus
;
data
=
xhrData
;
Dispatcher
.
ExitAllFrames
(
)
;
}
)
;
testEngine
.
Script
.
getData
=
new
Func
<
string
,
string
>
(
responseText
=>
helperEngine
.
Script
.
JSON
.
parse
(
responseText
)
.
data
)
;
Dispatcher
.
CurrentDispatcher
.
BeginInvoke
(
new
Action
(
(
)
=>
{
testEngine
.
AddCOMType
(
"XMLHttpRequest"
,
"MSXML2.XMLHTTP"
)
;
testEngine
.
Script
.
host
=
new
HostFunctions
(
)
;
testEngine
.
Execute
(
@"
sub onreadystatechange
if xhr.readyState = 4 then
call onComplete(xhr.status, getData(xhr.responseText))
end if
end sub
xhr = host.newObj(XMLHttpRequest)
call xhr.open(""POST"", ""http://httpbin.org/post"", true)
xhr.onreadystatechange = GetRef(""onreadystatechange"")
call xhr.send(""Hello, world!"")
"
)
;
}
)
)
;
Dispatcher
.
Run
(
)
;
// ReSharper restore AccessToDisposedClosure
}
}
}
)
;
thread
.
SetApartmentState
(
ApartmentState
.
STA
)
;
thread
.
Start
(
)
;
if
(
!
thread
.
Join
(
TimeSpan
.
FromSeconds
(
5
)
)
)
{
Assert
.
Inconclusive
(
"The Httpbin service request timed out"
)
;
}
Assert
.
AreEqual
(
200
,
status
)
;
Assert
.
AreEqual
(
"Hello, world!"
,
data
)
;
}
#endregion
}
}
Back
|
FazBrowse Home
|
New Git URL