From 7e3e7583a1d79a0a731ad3870e26ef7ac876a743 Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Fri, 6 Dec 2024 12:10:33 -0300 Subject: [PATCH] Update `Tests` --- CHANGELOG.md | 3 + ricaun.Nuke.Tests/AzureKeyVaultConfigTests.cs | 56 +++++++++++++++++++ .../{TestsNet.cs => NuGetExtensionTests.cs} | 6 +- ricaun.Nuke.Tests/ricaun.Nuke.Tests.csproj | 4 +- 4 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 ricaun.Nuke.Tests/AzureKeyVaultConfigTests.cs rename ricaun.Nuke.Tests/{TestsNet.cs => NuGetExtensionTests.cs} (90%) diff --git a/CHANGELOG.md b/CHANGELOG.md index db04867..65ac584 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Add `NuGetKeyVaultSignTool` for nuke version `8.*`. - Add `AzureKeyVaultConfig` with json file with `Azure Key Vault` without secrets. - Add `build` with `.targets` to install packages `AzureSignTool` and `NuGetKeyVaultSignTool`. +### Tests +- Update `NuGetExtensionTests` +- Add `AzureKeyVaultConfigTests` ## [1.8.2] / 2024-11-20 ### Updates diff --git a/ricaun.Nuke.Tests/AzureKeyVaultConfigTests.cs b/ricaun.Nuke.Tests/AzureKeyVaultConfigTests.cs new file mode 100644 index 0000000..fef486b --- /dev/null +++ b/ricaun.Nuke.Tests/AzureKeyVaultConfigTests.cs @@ -0,0 +1,56 @@ +using NUnit.Framework; +using ricaun.Nuke.Tools; + +namespace Nuke.NuGetKeyVaultSignTool +{ + public class AzureKeyVaultConfigTests + { + [Test] + public void JsonIsNotValidTest() + { + var content = """ + { + "AzureKeyVaultCertificate": "", + "AzureKeyVaultUrl": "", + "AzureKeyVaultClientId": "", + "AzureKeyVaultTenantId": "" + } + """; + + var azureKeyVaultFile = AzureKeyVaultConfig.Create(content); + Assert.IsNotNull(azureKeyVaultFile); + Assert.IsFalse(azureKeyVaultFile.IsValid()); + } + + [Test] + public void JsonIsNullTest() + { + var content = ""; + + var azureKeyVaultFile = AzureKeyVaultConfig.Create(content); + Assert.IsNull(azureKeyVaultFile); + } + + [Test] + public void JsonIsValidTest() + { + var content = """ + { + "AzureKeyVaultCertificate": "AzureKeyVaultCertificate", + "AzureKeyVaultUrl": "AzureKeyVaultUrl", + "AzureKeyVaultClientId": "AzureKeyVaultClientId", + "AzureKeyVaultTenantId": "AzureKeyVaultTenantId" + } + """; + + var azureKeyVaultFile = AzureKeyVaultConfig.Create(content); + Assert.IsNotNull(azureKeyVaultFile); + Assert.IsTrue(azureKeyVaultFile.IsValid()); + Assert.AreEqual("AzureKeyVaultCertificate", azureKeyVaultFile.AzureKeyVaultCertificate); + Assert.AreEqual("AzureKeyVaultUrl", azureKeyVaultFile.AzureKeyVaultUrl); + Assert.AreEqual("AzureKeyVaultClientId", azureKeyVaultFile.AzureKeyVaultClientId); + Assert.AreEqual("AzureKeyVaultTenantId", azureKeyVaultFile.AzureKeyVaultTenantId); + } + } + +} \ No newline at end of file diff --git a/ricaun.Nuke.Tests/TestsNet.cs b/ricaun.Nuke.Tests/NuGetExtensionTests.cs similarity index 90% rename from ricaun.Nuke.Tests/TestsNet.cs rename to ricaun.Nuke.Tests/NuGetExtensionTests.cs index 699414c..f50c629 100644 --- a/ricaun.Nuke.Tests/TestsNet.cs +++ b/ricaun.Nuke.Tests/NuGetExtensionTests.cs @@ -2,11 +2,10 @@ namespace ricaun.Nuke.Tests { -#if NET - public class TestsNet + public class NuGetExtensionTests { [Test] - public void Test1() + public void Test_PackageNameAndVersion() { var packages = new[] { "ricaun.example.1.2.3.nupkg", @@ -26,5 +25,4 @@ public void Test1() } } } -#endif } \ No newline at end of file diff --git a/ricaun.Nuke.Tests/ricaun.Nuke.Tests.csproj b/ricaun.Nuke.Tests/ricaun.Nuke.Tests.csproj index 5c61cf9..7472eba 100644 --- a/ricaun.Nuke.Tests/ricaun.Nuke.Tests.csproj +++ b/ricaun.Nuke.Tests/ricaun.Nuke.Tests.csproj @@ -1,7 +1,7 @@  - net6;net45 + net6 Latest false @@ -12,7 +12,7 @@ - +