From 59bae4e432ba2f95815ebe3613e53d1f1d47a230 Mon Sep 17 00:00:00 2001 From: tr00d Date: Tue, 19 Sep 2023 09:13:01 +0200 Subject: [PATCH] Replace computed property by method --- Vonage.Test.Unit/TestBase.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Vonage.Test.Unit/TestBase.cs b/Vonage.Test.Unit/TestBase.cs index a7ca8305e..96f88f627 100644 --- a/Vonage.Test.Unit/TestBase.cs +++ b/Vonage.Test.Unit/TestBase.cs @@ -24,8 +24,10 @@ public class TestBase protected readonly string RestUrl = Configuration.Instance.Settings["appSettings:Vonage.Url.Rest"]; protected readonly string ApiKey = Environment.GetEnvironmentVariable("VONAGE_API_KEY") ?? "testkey"; protected readonly string ApiSecret = Environment.GetEnvironmentVariable("VONAGE_API_Secret") ?? "testSecret"; + protected readonly string AppId = Environment.GetEnvironmentVariable("APPLICATION_ID") ?? "afed99d2-ae38-487c-bb5a-fe2518febd44"; + protected readonly string PrivateKey = Environment.GetEnvironmentVariable("PRIVATE_KEY") ?? Environment.GetEnvironmentVariable("Vonage.Test.RsaPrivateKey"); @@ -43,15 +45,12 @@ protected Credentials BuildCredentialsForBasicAuthentication() => protected Credentials BuildCredentialsForBearerAuthentication() => Credentials.FromAppIdAndPrivateKey(this.AppId, this.PrivateKey); - private static string AssemblyDirectory + private static string GetAssemblyDirectory() { - get - { - var codeBase = ThisAssembly.CodeBase; - var uri = new UriBuilder(codeBase); - var path = Uri.UnescapeDataString(uri.Path); - return Path.GetDirectoryName(path); - } + var codeBase = ThisAssembly.CodeBase; + var uri = new UriBuilder(codeBase); + var path = Uri.UnescapeDataString(uri.Path); + return Path.GetDirectoryName(path); } protected void Setup(string uri, string responseContent, string requestContent = null, @@ -98,7 +97,7 @@ protected string GetResponseJson([CallerMemberName] string name = null) if (ns != null) { var projectFolder = ns.Substring(TestAssemblyName.Length); - var path = Path.Combine(AssemblyDirectory, projectFolder, "Data", type, $"{name}-response.json"); + var path = Path.Combine(GetAssemblyDirectory(), projectFolder, "Data", type, $"{name}-response.json"); if (!File.Exists(path)) { throw new FileNotFoundException($"File not found at {path}."); @@ -112,7 +111,8 @@ protected string GetResponseJson([CallerMemberName] string name = null) return string.Empty; } - protected string GetResponseJson(Dictionary parameters, [CallerMemberName] string name = null) => + protected string GetResponseJson(Dictionary parameters, + [CallerMemberName] string name = null) => TokenReplacementRegEx.Replace(this.GetResponseJson(name), match => parameters[match.Groups[1].Value]); protected string GetRequestJson([CallerMemberName] string name = null) @@ -122,7 +122,7 @@ protected string GetRequestJson([CallerMemberName] string name = null) if (ns != null) { var projectFolder = ns.Substring(TestAssemblyName.Length); - var path = Path.Combine(AssemblyDirectory, projectFolder, "Data", type, $"{name}-request.json"); + var path = Path.Combine(GetAssemblyDirectory(), projectFolder, "Data", type, $"{name}-request.json"); if (!File.Exists(path)) { throw new FileNotFoundException($"File not found at {path}.");