-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Improve] code coverage for AppConfigService
- Loading branch information
samatrhea
committed
Nov 19, 2023
1 parent
43566e5
commit 0e7dc63
Showing
3 changed files
with
121 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
CometServer.Tests/Configuration/AppConfigServiceTestFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
// <copyright file="AppConfigServiceTestFixture.cs" company="RHEA System S.A."> | ||
// Copyright (c) 2015-2023 RHEA System S.A. | ||
// | ||
// Author: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate | ||
// | ||
// This file is part of CDP4-COMET Webservices Community Edition. | ||
// The CDP4-COMET Web Services Community Edition is the RHEA implementation of ECSS-E-TM-10-25 Annex A and Annex C. | ||
// This is an auto-generated class. Any manual changes to this file will be overwritten! | ||
// | ||
// The CDP4-COMET Web Services Community Edition is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU Affero General Public | ||
// License as published by the Free Software Foundation; either | ||
// version 3 of the License, or (at your option) any later version. | ||
// | ||
// The CDP4-COMET Web Services Community Edition is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// </copyright> | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
|
||
namespace CometServer.Tests.Configuration | ||
{ | ||
using System.IO; | ||
using CometServer.Configuration; | ||
using Microsoft.Extensions.Configuration; | ||
|
||
using NUnit.Framework; | ||
|
||
/// <summary> | ||
/// Suite of tests for the <see cref="AppConfigService"/> | ||
/// </summary> | ||
[TestFixture] | ||
public class AppConfigServiceTestFixture | ||
{ | ||
private IConfiguration configuration; | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
var path = Path.Combine(TestContext.CurrentContext.TestDirectory, "Data", "appsettings.json"); | ||
|
||
// Initialize the configuration builder | ||
var configurationBuilder = new ConfigurationBuilder() | ||
.SetBasePath(Directory.GetCurrentDirectory()) | ||
.AddJsonFile(path, optional: false, reloadOnChange: true); | ||
|
||
// Build the IConfiguration instance | ||
this.configuration = configurationBuilder.Build(); | ||
} | ||
|
||
[Test] | ||
public void Verify_that_configuration_is_loaded_from_appsettings() | ||
{ | ||
var appConfigService = new AppConfigService(this.configuration); | ||
|
||
Assert.That(appConfigService.AppConfig.Backtier.Database, Is.EqualTo("cdp4server")); | ||
|
||
Assert.That(appConfigService.AppConfig.Changelog.CollectChanges, Is.True); | ||
|
||
Assert.That(appConfigService.AppConfig.EmailService.SMTP, Is.EqualTo("smtp.cdp4.org")); | ||
|
||
Assert.That(appConfigService.AppConfig.HealthConfig.RequireHost, Is.Empty); | ||
|
||
Assert.That(appConfigService.AppConfig.Midtier.BacktierWaitTime, Is.EqualTo(333)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"Kestrel": { | ||
"Endpoints": { | ||
"Http": { | ||
"Url": "http://localhost:5000" | ||
} | ||
} | ||
}, | ||
"Midtier": { | ||
"UploadDirectory": "upload", | ||
"FileStorageDirectory": "storage", | ||
"IsExportEnabled": true, | ||
"ExportDirectory": "export", | ||
"BacktierWaitTime": 333 | ||
}, | ||
"Backtier": { | ||
"HostName": "localhost", | ||
"Port": 5432, | ||
"UserName": "cdp4", | ||
"Password": "cdp4", | ||
"Database": "cdp4server", | ||
"DatabaseRestore": "cdp4serverrestore", | ||
"DatabaseManage": "cdp4manage", | ||
"StatementTimeout": 180, | ||
"IsDbSeedEnabled": true, | ||
"IsDbRestoreEnabled": true, | ||
"IsDbImportEnabled": false | ||
}, | ||
"EmailService": { | ||
"Sender": "CDP4", | ||
"SMTP": "smtp.cdp4.org", | ||
"Port": 587, | ||
"UserName": "cdp4postmaster-username", | ||
"Password": "cdp4postmaster-password" | ||
}, | ||
"Defaults": { | ||
"PersonPassword": "pass" | ||
}, | ||
"Changelog": { | ||
"CollectChanges": true, | ||
"AllowEmailNotification": false | ||
}, | ||
"Health": { | ||
"RequireHost": [] | ||
} | ||
} |