Skip to content

Commit c13223b

Browse files
committed
Fix Microsoft.JSInterop tests
1 parent c6934f6 commit c13223b

File tree

5 files changed

+52
-10
lines changed

5 files changed

+52
-10
lines changed

src/JSInterop/Microsoft.JSInterop/test/Infrastructure/DotNetDispatcherTest.cs

+14-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
#nullable disable
5+
using System.Diagnostics.CodeAnalysis;
56
using System.Text.Json;
67
using Microsoft.AspNetCore.InternalTesting;
78

@@ -1088,16 +1089,26 @@ protected override void BeginInvokeJS(JSInvocationInfo invocationInfo)
10881089
_nextInvocationTcs = new TaskCompletionSource();
10891090
}
10901091

1091-
protected override string InvokeJS(string identifier, string argsJson, JSCallResultType resultType, long targetInstanceId)
1092+
protected override void BeginInvokeJS(long taskId, string identifier, [StringSyntax("Json")] string argsJson, JSCallResultType resultType, long targetInstanceId)
1093+
{
1094+
throw new NotImplementedException();
1095+
}
1096+
1097+
protected override string InvokeJS(JSInvocationInfo invocationInfo)
10921098
{
10931099
LastInvocationAsyncHandle = default;
1094-
LastInvocationIdentifier = identifier;
1095-
LastInvocationArgsJson = argsJson;
1100+
LastInvocationIdentifier = invocationInfo.Identifier;
1101+
LastInvocationArgsJson = invocationInfo.ArgsJson;
10961102
_nextInvocationTcs.SetResult();
10971103
_nextInvocationTcs = new TaskCompletionSource();
10981104
return null;
10991105
}
11001106

1107+
protected override string InvokeJS(string identifier, string argsJson, JSCallResultType resultType, long targetInstanceId)
1108+
{
1109+
throw new NotImplementedException();
1110+
}
1111+
11011112
protected internal override void EndInvokeDotNet(DotNetInvocationInfo invocationInfo, in DotNetInvocationResult invocationResult)
11021113
{
11031114
LastCompletionCallId = invocationInfo.CallId;

src/JSInterop/Microsoft.JSInterop/test/JSInProcessRuntimeTest.cs

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Diagnostics.CodeAnalysis;
45
using Microsoft.JSInterop.Infrastructure;
56

67
namespace Microsoft.JSInterop;
@@ -91,22 +92,24 @@ class TestDTO
9192

9293
class TestJSInProcessRuntime : JSInProcessRuntime
9394
{
94-
public List<InvokeArgs> InvokeCalls { get; set; } = new List<InvokeArgs>();
95+
public List<JSInvocationInfo> InvokeCalls { get; set; } = [];
9596

9697
public string? NextResultJson { get; set; }
9798

9899
protected override string? InvokeJS(string identifier, string? argsJson, JSCallResultType resultType, long targetInstanceId)
99100
{
100-
InvokeCalls.Add(new InvokeArgs { Identifier = identifier, ArgsJson = argsJson });
101-
return NextResultJson;
101+
throw new NotImplementedException();
102102
}
103103

104-
public class InvokeArgs
104+
protected override string? InvokeJS(JSInvocationInfo invocationInfo)
105105
{
106-
public string? Identifier { get; set; }
107-
public string? ArgsJson { get; set; }
106+
InvokeCalls.Add(invocationInfo);
107+
return NextResultJson;
108108
}
109109

110+
protected override void BeginInvokeJS(long taskId, string identifier, [StringSyntax("Json")] string? argsJson, JSCallResultType resultType, long targetInstanceId)
111+
=> throw new NotImplementedException("This test only covers sync calls");
112+
110113
protected override void BeginInvokeJS(JSInvocationInfo invocationInfo)
111114
=> throw new NotImplementedException("This test only covers sync calls");
112115

src/JSInterop/Microsoft.JSInterop/test/JSObjectReferenceTest.cs

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Diagnostics.CodeAnalysis;
45
using Microsoft.JSInterop.Implementation;
56
using Microsoft.JSInterop.Infrastructure;
67

@@ -74,6 +75,11 @@ protected override void BeginInvokeJS(JSInvocationInfo invocationInfo)
7475
BeginInvokeJSInvocationCount++;
7576
}
7677

78+
protected override void BeginInvokeJS(long taskId, string identifier, [StringSyntax("Json")] string? argsJson, JSCallResultType resultType, long targetInstanceId)
79+
{
80+
throw new NotImplementedException();
81+
}
82+
7783
protected internal override void EndInvokeDotNet(DotNetInvocationInfo invocationInfo, in DotNetInvocationResult invocationResult)
7884
{
7985
}
@@ -87,13 +93,23 @@ protected override void BeginInvokeJS(JSInvocationInfo invocationInfo)
8793
{
8894
}
8995

90-
protected override string? InvokeJS(string identifier, string? argsJson, JSCallResultType resultType, long targetInstanceId)
96+
protected override void BeginInvokeJS(long taskId, string identifier, [StringSyntax("Json")] string? argsJson, JSCallResultType resultType, long targetInstanceId)
97+
{
98+
throw new NotImplementedException();
99+
}
100+
101+
protected override string? InvokeJS(JSInvocationInfo invocationInfo)
91102
{
92103
InvokeJSInvocationCount++;
93104

94105
return null;
95106
}
96107

108+
protected override string? InvokeJS(string identifier, string? argsJson, JSCallResultType resultType, long targetInstanceId)
109+
{
110+
throw new NotImplementedException();
111+
}
112+
97113
protected internal override void EndInvokeDotNet(DotNetInvocationInfo invocationInfo, in DotNetInvocationResult invocationResult)
98114
{
99115
}

src/JSInterop/Microsoft.JSInterop/test/JSRuntimeTest.cs

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Diagnostics;
5+
using System.Diagnostics.CodeAnalysis;
56
using System.Text;
67
using System.Text.Json;
78
using Microsoft.JSInterop.Implementation;
@@ -475,6 +476,11 @@ protected internal override void EndInvokeDotNet(DotNetInvocationInfo invocation
475476
});
476477
}
477478

479+
protected override void BeginInvokeJS(long taskId, string identifier, [StringSyntax("Json")] string? argsJson, JSCallResultType resultType, long targetInstanceId)
480+
{
481+
throw new NotImplementedException();
482+
}
483+
478484
protected override void BeginInvokeJS(JSInvocationInfo invocationInfo)
479485
{
480486
BeginInvokeCalls.Add(invocationInfo);

src/JSInterop/Microsoft.JSInterop/test/TestJSRuntime.cs

+6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Diagnostics.CodeAnalysis;
45
using Microsoft.JSInterop.Infrastructure;
56

67
namespace Microsoft.JSInterop;
78

89
internal class TestJSRuntime : JSRuntime
910
{
11+
protected override void BeginInvokeJS(long taskId, string identifier, [StringSyntax("Json")] string? argsJson, JSCallResultType resultType, long targetInstanceId)
12+
{
13+
throw new NotImplementedException();
14+
}
15+
1016
protected override void BeginInvokeJS(JSInvocationInfo invocationInfo)
1117
{
1218
throw new NotImplementedException();

0 commit comments

Comments
 (0)