-
Notifications
You must be signed in to change notification settings - Fork 10.4k
[blazor] Use JSImport for loading satellite assemblies #46477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
82b1279
faf6a1d
7c9c461
631dd40
e5fec45
2dcb6fd
8dca4e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,6 @@ | |
using System.Globalization; | ||
using Microsoft.AspNetCore.Components.WebAssembly.Services; | ||
using Microsoft.AspNetCore.Testing; | ||
using Microsoft.JSInterop; | ||
using Moq; | ||
using static Microsoft.AspNetCore.Components.WebAssembly.Hosting.WebAssemblyCultureProvider; | ||
|
||
namespace Microsoft.AspNetCore.Components.WebAssembly.Hosting; | ||
|
||
|
@@ -27,54 +24,6 @@ public void GetCultures_ReturnsCultureClosure(string cultureName, string[] expec | |
Assert.Equal(expected, actual); | ||
} | ||
|
||
[Fact] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that it's fine to remove these tests since they were tied to the old implementation of Thankfully, it looks like this was one of the only cases where we were mocking The one exception to this is This isn't really a PR suggestion, just some ideas about the future. |
||
public async Task LoadCurrentCultureResourcesAsync_ReadsAssemblies() | ||
{ | ||
// Arrange | ||
using var cultureReplacer = new CultureReplacer("en-GB"); | ||
var invoker = new Mock<IJSUnmarshalledRuntime>(); | ||
#pragma warning disable CS0618 // Type or member is obsolete | ||
invoker.Setup(i => i.InvokeUnmarshalled<string[], object, object, Task<object>>(GetSatelliteAssemblies, new[] { "en-GB", "en" }, null, null)) | ||
.Returns(Task.FromResult<object>(1)) | ||
.Verifiable(); | ||
|
||
invoker.Setup(i => i.InvokeUnmarshalled<object, object, object, object[]>(ReadSatelliteAssemblies, null, null, null)) | ||
.Returns(new object[] { File.ReadAllBytes(GetType().Assembly.Location) }) | ||
.Verifiable(); | ||
#pragma warning restore CS0618 // Type or member is obsolete | ||
|
||
var loader = new WebAssemblyCultureProvider(invoker.Object, CultureInfo.CurrentCulture, CultureInfo.CurrentUICulture); | ||
|
||
// Act | ||
await loader.LoadCurrentCultureResourcesAsync(); | ||
|
||
// Assert | ||
invoker.Verify(); | ||
} | ||
|
||
[Fact] | ||
public async Task LoadCurrentCultureResourcesAsync_DoesNotReadAssembliesWhenThereAreNone() | ||
{ | ||
// Arrange | ||
using var cultureReplacer = new CultureReplacer("en-GB"); | ||
var invoker = new Mock<IJSUnmarshalledRuntime>(); | ||
#pragma warning disable CS0618 // Type or member is obsolete | ||
invoker.Setup(i => i.InvokeUnmarshalled<string[], object, object, Task<object>>(GetSatelliteAssemblies, new[] { "en-GB", "en" }, null, null)) | ||
.Returns(Task.FromResult<object>(0)) | ||
.Verifiable(); | ||
#pragma warning restore CS0618 // Type or member is obsolete | ||
|
||
var loader = new WebAssemblyCultureProvider(invoker.Object, CultureInfo.CurrentCulture, CultureInfo.CurrentUICulture); | ||
|
||
// Act | ||
await loader.LoadCurrentCultureResourcesAsync(); | ||
|
||
#pragma warning disable CS0618 // Type or member is obsolete | ||
// Assert | ||
invoker.Verify(i => i.InvokeUnmarshalled<object, object, object, object[]>(ReadSatelliteAssemblies, null, null, null), Times.Never()); | ||
#pragma warning restore CS0618 // Type or member is obsolete | ||
} | ||
|
||
[Fact] | ||
public void ThrowIfCultureChangeIsUnsupported_ThrowsIfCulturesAreDifferentAndICUShardingIsUsed() | ||
{ | ||
|
Uh oh!
There was an error while loading. Please reload this page.