Skip to content

Commit b18100c

Browse files
committed
test: 更新单元测试
1 parent 476a189 commit b18100c

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/UnitTest/Extensions/JSModuleExtensionsTest.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ public async Task LoadModule_Ok()
2121

2222
var jsRuntime2 = new JSExceptionJSRuntime();
2323
await Assert.ThrowsAsync<JSException>(() => jsRuntime2.LoadModule("./mock.js", "test"));
24+
25+
var jsRuntime3 = new JSDisconnectedExceptionJSRuntime();
26+
Assert.NotNull(jsRuntime3.LoadModule("./mock.js", "test"));
27+
28+
var jsRuntime4 = new ObjectDisposedExceptionJSRuntime();
29+
Assert.NotNull(jsRuntime4.LoadModule("./mock.js", "test"));
2430
}
2531

2632
[Fact]
@@ -119,4 +125,30 @@ class JSExceptionJSRuntime : IJSRuntime
119125
throw new JSException("test-js-exception");
120126
}
121127
}
128+
129+
class JSDisconnectedExceptionJSRuntime : IJSRuntime
130+
{
131+
public ValueTask<TValue> InvokeAsync<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicFields | DynamicallyAccessedMemberTypes.PublicProperties)] TValue>(string identifier, object?[]? args)
132+
{
133+
throw new JSDisconnectedException("test-js-exception");
134+
}
135+
136+
public ValueTask<TValue> InvokeAsync<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicFields | DynamicallyAccessedMemberTypes.PublicProperties)] TValue>(string identifier, CancellationToken cancellationToken, object?[]? args)
137+
{
138+
throw new JSDisconnectedException("test-js-exception");
139+
}
140+
}
141+
142+
class ObjectDisposedExceptionJSRuntime : IJSRuntime
143+
{
144+
public ValueTask<TValue> InvokeAsync<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicFields | DynamicallyAccessedMemberTypes.PublicProperties)] TValue>(string identifier, object?[]? args)
145+
{
146+
throw new ObjectDisposedException("test-js-exception");
147+
}
148+
149+
public ValueTask<TValue> InvokeAsync<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicFields | DynamicallyAccessedMemberTypes.PublicProperties)] TValue>(string identifier, CancellationToken cancellationToken, object?[]? args)
150+
{
151+
throw new ObjectDisposedException("test-js-exception");
152+
}
153+
}
122154
}

0 commit comments

Comments
 (0)