Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentoub committed Jul 7, 2021
1 parent f012e49 commit 0e0ade5
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/libraries/System.Runtime/tests/System/Text/EncodingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Collections.Generic;
using System.Linq;
using Microsoft.DotNet.RemoteExecutor;
using Moq;
using Xunit;

Expand Down Expand Up @@ -106,6 +107,25 @@ public void GetEncodings_FromProvider_DoesNotContainDisallowedEncodings(string e
});
}

[ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
public void RegisterProvider_EncodingsAreUsable()
{
RemoteExecutor.Invoke(() =>
{
for (int i = 0; i < 10; i++)
{
Encoding.RegisterProvider(new NullEncodingProvider());
Assert.Same(Encoding.UTF8, Encoding.GetEncoding(65001));
}
}).Dispose();
}

private sealed class NullEncodingProvider : EncodingProvider
{
public override Encoding GetEncoding(int codepage) => null;
public override Encoding GetEncoding(string name) => null;
}

private sealed class ThreadStaticEncodingProvider : EncodingProvider
{
private static readonly object _globalRegistrationLockObj = new object();
Expand Down

0 comments on commit 0e0ade5

Please sign in to comment.