Skip to content

Commit 637ca96

Browse files
author
maddieclayton
committed
Merge branch 'master' of https://github.com/Azure/azure-powershell into mergerelease
2 parents 7218948 + e7ca141 commit 637ca96

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/ResourceManager/KeyVault/Commands.KeyVault.Test/Models/UtilitiesTests.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using System;
2020
using System.IO;
2121
using System.Linq;
22+
using System.Reflection;
2223
using Xunit;
2324
using Xunit.Abstractions;
2425

@@ -63,10 +64,12 @@ public void GetWebKeyFromByok()
6364
public void GetWebKeyFromCertificate()
6465
{
6566
string password = "123";
66-
string path = Path.Combine(Directory.GetCurrentDirectory(), "Resources", "pshtest.pfx");
67+
// This allows the test to run in Visual Studio and in the console runner. The file will exist in one of the two locations depending on the environment.
68+
var consolePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? String.Empty, "Resources", "pshtest.pfx");
69+
var vsPath = Path.Combine(Directory.GetCurrentDirectory(), "Resources", "pshtest.pfx");
6770

6871
IWebKeyConverter converters = WebKeyConverterFactory.CreateConverterChain();
69-
var webKey = converters.ConvertKeyFromFile(new FileInfo(path), password.ConvertToSecureString());
72+
var webKey = converters.ConvertKeyFromFile(new FileInfo(File.Exists(consolePath) ? consolePath : vsPath), password.ConvertToSecureString());
7073

7174
Assert.True(webKey.HasPrivateKey());
7275
Assert.True(webKey.IsValid());

0 commit comments

Comments
 (0)