From 57391d3e51fc3fe9b93afe4f4839ae19e634ba2a Mon Sep 17 00:00:00 2001 From: csimonapastore Date: Mon, 13 May 2024 01:13:09 +0200 Subject: [PATCH] Fixing coverage - 9 --- MainProject.Tests/Utils/ProgramUtils_Tests.cs | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/MainProject.Tests/Utils/ProgramUtils_Tests.cs b/MainProject.Tests/Utils/ProgramUtils_Tests.cs index f4df5ec..043da64 100644 --- a/MainProject.Tests/Utils/ProgramUtils_Tests.cs +++ b/MainProject.Tests/Utils/ProgramUtils_Tests.cs @@ -63,9 +63,9 @@ public class ProgramUtils_Tests { OpenApiInfo expectedOpenApiInfo = new OpenApiInfo() { - Title = "", - Description = "", - Version = "", + Title = null, + Description = null, + Version = null, Contact = null, TermsOfService = null, License = null, @@ -109,6 +109,35 @@ public class ProgramUtils_Tests } } + [TestMethod] + public void CreateOpenApiInfo_NullOpenApiSettings() + { + try + { + + AppSettings appSettings = new AppSettings() + { + Settings = new Settings + { + Name = "Test", + Description = "This is a test description", + Version = "v1" + }, + OpenApiSettings = 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); + } + catch (Exception ex) + { + Console.WriteLine(ex.InnerException); + Assert.Fail($"An exception was thrown: {ex.Message}"); + } + } + [TestMethod] public void OpenApiConfig_NotNull() {