diff --git a/test/Microsoft.AspNet.DataProtection.Test/RegistryPolicyResolverTests.cs b/test/Microsoft.AspNet.DataProtection.Test/RegistryPolicyResolverTests.cs index 79bb5ee555..91811515d6 100644 --- a/test/Microsoft.AspNet.DataProtection.Test/RegistryPolicyResolverTests.cs +++ b/test/Microsoft.AspNet.DataProtection.Test/RegistryPolicyResolverTests.cs @@ -13,6 +13,7 @@ using Microsoft.AspNet.Testing.xunit; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.OptionsModel; +using Microsoft.Extensions.PlatformAbstractions; using Microsoft.Win32; using Xunit; @@ -259,7 +260,7 @@ namespace Microsoft.AspNet.DataProtection private class ConditionalRunTestOnlyIfHkcuRegistryAvailable : Attribute, ITestCondition { - public bool IsMet => (LazyHkcuTempKey.Value != null); + public bool IsMet => (PlatformServices.Default.Runtime.OperatingSystem == "Windows" && LazyHkcuTempKey.Value != null); public string SkipReason { get; } = "HKCU registry couldn't be opened."; } diff --git a/test/Microsoft.AspNet.DataProtection.Test/Repositories/FileSystemXmlRepositoryTests.cs b/test/Microsoft.AspNet.DataProtection.Test/Repositories/FileSystemXmlRepositoryTests.cs index 7a56490ea2..f175b00283 100644 --- a/test/Microsoft.AspNet.DataProtection.Test/Repositories/FileSystemXmlRepositoryTests.cs +++ b/test/Microsoft.AspNet.DataProtection.Test/Repositories/FileSystemXmlRepositoryTests.cs @@ -16,7 +16,6 @@ namespace Microsoft.AspNet.DataProtection.Repositories [ConditionalRunTestOnlyIfLocalAppDataAvailable] public void DefaultKeyStorageDirectory_Property() { - // Act var defaultDirInfo = FileSystemXmlRepository.DefaultKeyStorageDirectory; @@ -160,7 +159,7 @@ namespace Microsoft.AspNet.DataProtection.Repositories private static string GetLocalApplicationData() { #if DNXCORE50 - return Environment.ExpandEnvironmentVariables("%LOCALAPPDATA%"); + return Environment.GetEnvironmentVariable("LOCALAPPDATA"); #else return Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); #endif diff --git a/test/Microsoft.AspNet.DataProtection.Test/Repositories/RegistryXmlRepositoryTests.cs b/test/Microsoft.AspNet.DataProtection.Test/Repositories/RegistryXmlRepositoryTests.cs index 206b804fab..3e5cfae000 100644 --- a/test/Microsoft.AspNet.DataProtection.Test/Repositories/RegistryXmlRepositoryTests.cs +++ b/test/Microsoft.AspNet.DataProtection.Test/Repositories/RegistryXmlRepositoryTests.cs @@ -5,6 +5,7 @@ using System; using System.Linq; using System.Xml.Linq; using Microsoft.AspNet.Testing.xunit; +using Microsoft.Extensions.PlatformAbstractions; using Microsoft.Win32; using Xunit; @@ -158,7 +159,7 @@ namespace Microsoft.AspNet.DataProtection.Repositories private class ConditionalRunTestOnlyIfHkcuRegistryAvailable : Attribute, ITestCondition { - public bool IsMet => (LazyHkcuTempKey.Value != null); + public bool IsMet => (PlatformServices.Default.Runtime.OperatingSystem == "Windows" && LazyHkcuTempKey.Value != null); public string SkipReason { get; } = "HKCU registry couldn't be opened."; }