From e6e5748d02e49a44140f708288a1f4ace136f11f Mon Sep 17 00:00:00 2001 From: David Pine Date: Mon, 12 Feb 2024 20:29:44 -0600 Subject: [PATCH] Test new API --- .../GlobalUsings.cs | 3 +++ .../PwnedClientTests.cs | 26 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 tests/HaveIBeenPwned.Client.AcceptanceTests/PwnedClientTests.cs diff --git a/tests/HaveIBeenPwned.Client.AcceptanceTests/GlobalUsings.cs b/tests/HaveIBeenPwned.Client.AcceptanceTests/GlobalUsings.cs index 809f9f1..b2511e4 100644 --- a/tests/HaveIBeenPwned.Client.AcceptanceTests/GlobalUsings.cs +++ b/tests/HaveIBeenPwned.Client.AcceptanceTests/GlobalUsings.cs @@ -2,3 +2,6 @@ // Licensed under the MIT License. global using Xunit; + +global using HaveIBeenPwned.Client.Extensions; +global using HaveIBeenPwned.Client.Options; \ No newline at end of file diff --git a/tests/HaveIBeenPwned.Client.AcceptanceTests/PwnedClientTests.cs b/tests/HaveIBeenPwned.Client.AcceptanceTests/PwnedClientTests.cs new file mode 100644 index 0000000..a81305a --- /dev/null +++ b/tests/HaveIBeenPwned.Client.AcceptanceTests/PwnedClientTests.cs @@ -0,0 +1,26 @@ +// Copyright (c) David Pine. All rights reserved. +// Licensed under the MIT License. + +namespace HaveIBeenPwned.Client.AcceptanceTests; + +[Trait("Category", "AcceptanceTests")] +public class PwnedClientTests +{ + private readonly IPwnedClient _pwnedClient; + + public PwnedClientTests() => + _pwnedClient = new PwnedClient( + Environment.GetEnvironmentVariable("HibpOptions__ApiKey")!); + + [Fact] + public async Task GetSubscriptionStatusAsyncReturnsCorrectStatus() + { + var status = + await _pwnedClient.GetSubscriptionStatusAsync(); + + Assert.NotNull(status); + + var actual = status.GetSubscriptionLevel(); + Assert.Equal(HibpSubscriptionLevel.One, actual); + } +}