Fix coreclr registry and file system related tests
This commit is contained in:
parent
5e65a9fc59
commit
29e87e314a
|
|
@ -13,6 +13,7 @@ using Microsoft.AspNet.Testing.xunit;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
using Microsoft.Extensions.OptionsModel;
|
using Microsoft.Extensions.OptionsModel;
|
||||||
|
using Microsoft.Extensions.PlatformAbstractions;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
|
|
@ -259,7 +260,7 @@ namespace Microsoft.AspNet.DataProtection
|
||||||
|
|
||||||
private class ConditionalRunTestOnlyIfHkcuRegistryAvailable : Attribute, ITestCondition
|
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.";
|
public string SkipReason { get; } = "HKCU registry couldn't be opened.";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ namespace Microsoft.AspNet.DataProtection.Repositories
|
||||||
[ConditionalRunTestOnlyIfLocalAppDataAvailable]
|
[ConditionalRunTestOnlyIfLocalAppDataAvailable]
|
||||||
public void DefaultKeyStorageDirectory_Property()
|
public void DefaultKeyStorageDirectory_Property()
|
||||||
{
|
{
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var defaultDirInfo = FileSystemXmlRepository.DefaultKeyStorageDirectory;
|
var defaultDirInfo = FileSystemXmlRepository.DefaultKeyStorageDirectory;
|
||||||
|
|
||||||
|
|
@ -160,7 +159,7 @@ namespace Microsoft.AspNet.DataProtection.Repositories
|
||||||
private static string GetLocalApplicationData()
|
private static string GetLocalApplicationData()
|
||||||
{
|
{
|
||||||
#if DNXCORE50
|
#if DNXCORE50
|
||||||
return Environment.ExpandEnvironmentVariables("%LOCALAPPDATA%");
|
return Environment.GetEnvironmentVariable("LOCALAPPDATA");
|
||||||
#else
|
#else
|
||||||
return Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
return Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using Microsoft.AspNet.Testing.xunit;
|
using Microsoft.AspNet.Testing.xunit;
|
||||||
|
using Microsoft.Extensions.PlatformAbstractions;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
|
|
@ -158,7 +159,7 @@ namespace Microsoft.AspNet.DataProtection.Repositories
|
||||||
|
|
||||||
private class ConditionalRunTestOnlyIfHkcuRegistryAvailable : Attribute, ITestCondition
|
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.";
|
public string SkipReason { get; } = "HKCU registry couldn't be opened.";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue