From fb578026ebf7655dbd9065a613f2b2b8a42f7849 Mon Sep 17 00:00:00 2001 From: csimonapastore Date: Mon, 13 May 2024 21:43:49 +0200 Subject: [PATCH] Fixing coverage - 10 --- .gitignore | 3 +- MainProject.Tests/Utils/ProgramUtils_Tests.cs | 34 +++++++++++++++++++ README.md | 3 +- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 92076e1..8775b8d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ **/obj **/bin -**/appsettings.*.json \ No newline at end of file +**/appsettings.*.json +**/coverage.xml \ No newline at end of file diff --git a/MainProject.Tests/Utils/ProgramUtils_Tests.cs b/MainProject.Tests/Utils/ProgramUtils_Tests.cs index 043da64..4256dfd 100644 --- a/MainProject.Tests/Utils/ProgramUtils_Tests.cs +++ b/MainProject.Tests/Utils/ProgramUtils_Tests.cs @@ -138,6 +138,40 @@ public class ProgramUtils_Tests } } + [TestMethod] + public void CreateOpenApiInfo_NullTermsOfServiceUrl() + { + try + { + AppSettings appSettings = new AppSettings() + { + Settings = new Settings + { + Name = "Test", + Description = "This is a test description", + Version = "v1" + }, + OpenApiSettings = new OpenApiSettings + { + TermsOfServiceUrl = null, + OpenApiContact = null, + OpenApiLicense = null + } + }; + OpenApiInfo realOpenApiInfo = ProgramUtils.CreateOpenApiInfo(appSettings); + Assert.IsTrue(realOpenApiInfo != null); + Assert.IsTrue(realOpenApiInfo.Title == appSettings.Settings.Name); + Assert.IsTrue(realOpenApiInfo.Description == appSettings.Settings.Description); + Assert.IsTrue(realOpenApiInfo.Version == appSettings.Settings.Version); + Assert.IsTrue(realOpenApiInfo.TermsOfService == null); + } + catch (Exception ex) + { + Console.WriteLine(ex.InnerException); + Assert.Fail($"An exception was thrown: {ex.Message}"); + } + } + [TestMethod] public void OpenApiConfig_NotNull() { diff --git a/README.md b/README.md index 5455fe5..80f7a0b 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,8 @@ This project is scanned on [SonarCloud](https://www.sonarsource.com/lp/products/ You can find the integration in [build.yml](.github/workflows/build.yml). #### Quality gate -[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=csimonapastore_BasicDotnetTemplate&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=csimonapastore_BasicDotnetTemplate) +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=csimonapastore_BasicDotnetTemplate&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=csimonapastore_BasicDotnetTemplate) + A Quality Gate is a set of measure-based, Boolean conditions. It helps you know immediately whether your projects are production-ready. This project uses **Sonar way** quality gate: