From 4ac2c69eb48ab30bfe7525493e66721c33e8af03 Mon Sep 17 00:00:00 2001 From: Jon M Date: Thu, 1 Aug 2024 11:39:20 +0100 Subject: [PATCH] Refactor errors tests --- Mailosaur.Test/ErrorsTests.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Mailosaur.Test/ErrorsTests.cs b/Mailosaur.Test/ErrorsTests.cs index 863d540..11e03d1 100644 --- a/Mailosaur.Test/ErrorsTests.cs +++ b/Mailosaur.Test/ErrorsTests.cs @@ -6,10 +6,13 @@ namespace Mailosaur.Test { public class ErrorsTests { + private static string s_ApiKey = Environment.GetEnvironmentVariable("MAILOSAUR_API_KEY"); + private string s_BaseUrl = Environment.GetEnvironmentVariable("MAILOSAUR_BASE_URL") ?? "https://mailosaur.com/"; + [Fact] public void UnauthorizedTest() { - using (var client = new MailosaurClient("invalid_key", Environment.GetEnvironmentVariable("MAILOSAUR_BASE_URL"))) + using (var client = new MailosaurClient("invalid_key", s_BaseUrl)) { var ex = Assert.Throws(delegate { @@ -23,7 +26,7 @@ public void UnauthorizedTest() [Fact] public void NotFoundTest() { - using (var client = new MailosaurClient(Environment.GetEnvironmentVariable("MAILOSAUR_API_KEY"))) + using (var client = new MailosaurClient(s_ApiKey, s_BaseUrl)) { var ex = Assert.Throws(delegate { @@ -37,7 +40,7 @@ public void NotFoundTest() [Fact] public void BadRequestTest() { - using (var client = new MailosaurClient(Environment.GetEnvironmentVariable("MAILOSAUR_API_KEY"))) + using (var client = new MailosaurClient(s_ApiKey, s_BaseUrl)) { var options = new ServerCreateOptions(""); var ex = Assert.Throws(delegate