diff --git a/test/Microsoft.AspNetCore.DataProtection.Test/RegistryPolicyResolverTests.cs b/test/Microsoft.AspNetCore.DataProtection.Test/RegistryPolicyResolverTests.cs index 667f443e14..1bf706dda2 100644 --- a/test/Microsoft.AspNetCore.DataProtection.Test/RegistryPolicyResolverTests.cs +++ b/test/Microsoft.AspNetCore.DataProtection.Test/RegistryPolicyResolverTests.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Security.Cryptography; using System.Xml.Linq; using Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption; @@ -13,7 +14,6 @@ using Microsoft.AspNetCore.Testing.xunit; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; -using Microsoft.Extensions.PlatformAbstractions; using Microsoft.Win32; using Xunit; @@ -260,7 +260,7 @@ namespace Microsoft.AspNetCore.DataProtection private class ConditionalRunTestOnlyIfHkcuRegistryAvailable : Attribute, ITestCondition { - public bool IsMet => (PlatformServices.Default.Runtime.OperatingSystem == "Windows" && LazyHkcuTempKey.Value != null); + public bool IsMet => (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && LazyHkcuTempKey.Value != null); public string SkipReason { get; } = "HKCU registry couldn't be opened."; } diff --git a/test/Microsoft.AspNetCore.DataProtection.Test/Repositories/RegistryXmlRepositoryTests.cs b/test/Microsoft.AspNetCore.DataProtection.Test/Repositories/RegistryXmlRepositoryTests.cs index e7d7e62a86..92c16a782c 100644 --- a/test/Microsoft.AspNetCore.DataProtection.Test/Repositories/RegistryXmlRepositoryTests.cs +++ b/test/Microsoft.AspNetCore.DataProtection.Test/Repositories/RegistryXmlRepositoryTests.cs @@ -3,9 +3,9 @@ using System; using System.Linq; +using System.Runtime.InteropServices; using System.Xml.Linq; using Microsoft.AspNetCore.Testing.xunit; -using Microsoft.Extensions.PlatformAbstractions; using Microsoft.Win32; using Xunit; @@ -159,7 +159,7 @@ namespace Microsoft.AspNetCore.DataProtection.Repositories private class ConditionalRunTestOnlyIfHkcuRegistryAvailable : Attribute, ITestCondition { - public bool IsMet => (PlatformServices.Default.Runtime.OperatingSystem == "Windows" && LazyHkcuTempKey.Value != null); + public bool IsMet => (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && LazyHkcuTempKey.Value != null); public string SkipReason { get; } = "HKCU registry couldn't be opened."; } diff --git a/test/Microsoft.AspNetCore.DataProtection.Test/project.json b/test/Microsoft.AspNetCore.DataProtection.Test/project.json index 78bc5b2c7d..d7e723dcce 100644 --- a/test/Microsoft.AspNetCore.DataProtection.Test/project.json +++ b/test/Microsoft.AspNetCore.DataProtection.Test/project.json @@ -1,5 +1,6 @@ { "dependencies": { + "System.Runtime.InteropServices.RuntimeInformation": "4.0.0-*", "dotnet-test-xunit": "1.0.0-*", "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.DataProtection": "1.0.0-*",