Adding test configuration
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,3 @@
|
|||||||
**/obj
|
**/obj
|
||||||
**/bin
|
**/bin
|
||||||
appsettings.*.json
|
**/appsettings.*.json
|
||||||
4
.vscode/launch.json
vendored
4
.vscode/launch.json
vendored
@@ -5,12 +5,12 @@
|
|||||||
// Use IntelliSense to find out which attributes exist for C# debugging
|
// Use IntelliSense to find out which attributes exist for C# debugging
|
||||||
// Use hover for the description of the existing attributes
|
// Use hover for the description of the existing attributes
|
||||||
// For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md
|
// For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md
|
||||||
"name": ".NET Core Launch (console)",
|
"name": ".NET Rest Api",
|
||||||
"type": "coreclr",
|
"type": "coreclr",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"preLaunchTask": "build",
|
"preLaunchTask": "build",
|
||||||
// If you have changed target frameworks, make sure to update the program path.
|
// If you have changed target frameworks, make sure to update the program path.
|
||||||
"program": "${workspaceFolder}/bin/Debug/net8.0/BasicDotnetTemplate.dll",
|
"program": "${workspaceFolder}/MainProject/bin/Debug/net8.0/MainProject.dll",
|
||||||
"args": [],
|
"args": [],
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
|
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
|
||||||
|
|||||||
6
.vscode/tasks.json
vendored
6
.vscode/tasks.json
vendored
@@ -7,7 +7,7 @@
|
|||||||
"type": "process",
|
"type": "process",
|
||||||
"args": [
|
"args": [
|
||||||
"build",
|
"build",
|
||||||
"${workspaceFolder}/BasicDotnetTemplate.csproj",
|
"${workspaceFolder}/MainProject/MainProject.csproj",
|
||||||
"/property:GenerateFullPaths=true",
|
"/property:GenerateFullPaths=true",
|
||||||
"/consoleloggerparameters:NoSummary;ForceNoAlign"
|
"/consoleloggerparameters:NoSummary;ForceNoAlign"
|
||||||
],
|
],
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
"type": "process",
|
"type": "process",
|
||||||
"args": [
|
"args": [
|
||||||
"publish",
|
"publish",
|
||||||
"${workspaceFolder}/BasicDotnetTemplate.csproj",
|
"${workspaceFolder}/MainProject/MainProject.csproj",
|
||||||
"/property:GenerateFullPaths=true",
|
"/property:GenerateFullPaths=true",
|
||||||
"/consoleloggerparameters:NoSummary;ForceNoAlign"
|
"/consoleloggerparameters:NoSummary;ForceNoAlign"
|
||||||
],
|
],
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
"watch",
|
"watch",
|
||||||
"run",
|
"run",
|
||||||
"--project",
|
"--project",
|
||||||
"${workspaceFolder}/BasicDotnetTemplate.csproj"
|
"${workspaceFolder}/MainProject.csproj"
|
||||||
],
|
],
|
||||||
"problemMatcher": "$msCompile"
|
"problemMatcher": "$msCompile"
|
||||||
}
|
}
|
||||||
|
|||||||
28
BasicDotnetTemplate.sln
Normal file
28
BasicDotnetTemplate.sln
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.0.31903.59
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MainProject", "MainProject\MainProject.csproj", "{5BC4F94C-35BC-4436-A107-9D85E53A9E84}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MainProject.Tests", "MainProject.Tests\MainProject.Tests.csproj", "{A672CB00-DC99-4847-A384-B857C5E69301}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{5BC4F94C-35BC-4436-A107-9D85E53A9E84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{5BC4F94C-35BC-4436-A107-9D85E53A9E84}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{5BC4F94C-35BC-4436-A107-9D85E53A9E84}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{5BC4F94C-35BC-4436-A107-9D85E53A9E84}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{A672CB00-DC99-4847-A384-B857C5E69301}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{A672CB00-DC99-4847-A384-B857C5E69301}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{A672CB00-DC99-4847-A384-B857C5E69301}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{A672CB00-DC99-4847-A384-B857C5E69301}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
25
MainProject.Tests/AppSettingsUtils_Tests.cs
Normal file
25
MainProject.Tests/AppSettingsUtils_Tests.cs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
using BasicDotnetTemplate.MainProject.Models.Settings;
|
||||||
|
using BasicDotnetTemplate.MainProject.Utils;
|
||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
|
||||||
|
namespace BasicDotnetTemplate.MainProject.Tests
|
||||||
|
{
|
||||||
|
[TestClass]
|
||||||
|
public class AppSettingsUtils_Tests
|
||||||
|
{
|
||||||
|
private readonly AppSettings _appSettings;
|
||||||
|
|
||||||
|
public AppSettingsUtils_Tests()
|
||||||
|
{
|
||||||
|
_appSettings = new AppSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void AppSettingsUtils_Tests_IsValid()
|
||||||
|
{
|
||||||
|
bool result = AppSettingsUtils.CheckAppSettings(_appSettings);
|
||||||
|
|
||||||
|
Assert.IsTrue(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
27
MainProject.Tests/MainProject.Tests.csproj
Normal file
27
MainProject.Tests/MainProject.Tests.csproj
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
<IsTestProject>true</IsTestProject>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="coverlet.collector" Version="6.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||||
|
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
|
||||||
|
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\MainProject\MainProject.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace BasicDotnetTemplate.Models.Settings;
|
namespace BasicDotnetTemplate.MainProject.Models.Settings;
|
||||||
|
|
||||||
public class AppSettings
|
public class AppSettings
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace BasicDotnetTemplate.Models.Settings;
|
namespace BasicDotnetTemplate.MainProject.Models.Settings;
|
||||||
|
|
||||||
public class DatabaseConnection
|
public class DatabaseConnection
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace BasicDotnetTemplate.Models.Settings;
|
namespace BasicDotnetTemplate.MainProject.Models.Settings;
|
||||||
|
|
||||||
public class OpenApiSettings
|
public class OpenApiSettings
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace BasicDotnetTemplate.Models.Settings;
|
namespace BasicDotnetTemplate.MainProject.Models.Settings;
|
||||||
|
|
||||||
public class OpenApiSettingsDetails
|
public class OpenApiSettingsDetails
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace BasicDotnetTemplate.Models.Settings;
|
namespace BasicDotnetTemplate.MainProject.Models.Settings;
|
||||||
|
|
||||||
public class PrivateSettings
|
public class PrivateSettings
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace BasicDotnetTemplate.Models.Settings;
|
namespace BasicDotnetTemplate.MainProject.Models.Settings;
|
||||||
|
|
||||||
public class Settings
|
public class Settings
|
||||||
{
|
{
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
using Microsoft.OpenApi.Models;
|
using System;
|
||||||
using BasicDotnetTemplate.Models.Settings;
|
using Microsoft.OpenApi.Models;
|
||||||
|
using BasicDotnetTemplate.MainProject.Models.Settings;
|
||||||
|
using BasicDotnetTemplate.MainProject.Utils;
|
||||||
|
|
||||||
namespace BasicDotnetTemplate;
|
namespace BasicDotnetTemplate.MainProject;
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
@@ -9,7 +11,7 @@ internal static class Program
|
|||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
var _configuration = new ConfigurationBuilder()
|
var _configuration = new ConfigurationBuilder()
|
||||||
.SetBasePath(Directory.GetCurrentDirectory())
|
.SetBasePath(System.AppDomain.CurrentDomain.BaseDirectory)
|
||||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||||
.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", optional: true)
|
.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", optional: true)
|
||||||
.AddEnvironmentVariables()
|
.AddEnvironmentVariables()
|
||||||
@@ -56,7 +58,6 @@ internal static class Program
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
// REGISTER MIDDLEWARE HERE
|
// REGISTER MIDDLEWARE HERE
|
||||||
12
MainProject/Utils/AppSettingsUtils.cs
Normal file
12
MainProject/Utils/AppSettingsUtils.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using BasicDotnetTemplate.MainProject.Models.Settings;
|
||||||
|
|
||||||
|
namespace BasicDotnetTemplate.MainProject.Utils;
|
||||||
|
|
||||||
|
public static class AppSettingsUtils
|
||||||
|
{
|
||||||
|
static AppSettingsUtils() { }
|
||||||
|
public static bool CheckAppSettings(AppSettings appSetting)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
"AppSettings" :
|
"AppSettings" :
|
||||||
{
|
{
|
||||||
"Settings": {
|
"Settings": {
|
||||||
"Name": "BasicDotnetTemplate",
|
"Name": "MainProject",
|
||||||
"Version": "v1.0",
|
"Version": "v1.0",
|
||||||
"Description": "This template contains basic configuration for a .Net 8 backend"
|
"Description": "This template contains basic configuration for a .Net 8 backend"
|
||||||
},
|
},
|
||||||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Reference in New Issue
Block a user