Skip to content

Commit 94cc13e

Browse files
CopilotabeckDev
andcommitted
Add unit tests and code coverage (78.3% coverage achieved)
Co-authored-by: abeckDev <8720854+abeckDev@users.noreply.github.com>
1 parent b78dbf0 commit 94cc13e

10 files changed

Lines changed: 782 additions & 4 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ Generated\ Files/
5555
[Bb]uild[Ll]og.*
5656
*.trx
5757

58+
# Code Coverage Results
59+
TestResults/
60+
5861
# NUnit
5962
*.VisualState.xml
6063
TestResult.xml
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
8+
<IsPackable>false</IsPackable>
9+
<IsTestProject>true</IsTestProject>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="coverlet.collector" Version="6.0.4">
14+
<PrivateAssets>all</PrivateAssets>
15+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
16+
</PackageReference>
17+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
18+
<PackageReference Include="Moq" Version="4.20.72" />
19+
<PackageReference Include="xunit" Version="2.9.3" />
20+
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
21+
<PrivateAssets>all</PrivateAssets>
22+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
23+
</PackageReference>
24+
</ItemGroup>
25+
26+
<ItemGroup>
27+
<Using Include="Xunit" />
28+
</ItemGroup>
29+
30+
<ItemGroup>
31+
<ProjectReference Include="..\AbeckDev.DbTimetable.Mcp\AbeckDev.DbTimetable.Mcp.csproj" />
32+
</ItemGroup>
33+
34+
</Project>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using AbeckDev.DbTimetable.Mcp.Models;
2+
3+
namespace AbeckDev.DbTimetable.Mcp.Test;
4+
5+
public class ConfigurationTests
6+
{
7+
[Fact]
8+
public void Configuration_SectionName_HasCorrectValue()
9+
{
10+
// Arrange & Act & Assert
11+
Assert.Equal("DeutscheBahnApi", Configuration.SectionName);
12+
}
13+
14+
[Fact]
15+
public void Configuration_DefaultValues_AreCorrect()
16+
{
17+
// Arrange & Act
18+
var config = new Configuration();
19+
20+
// Assert
21+
Assert.Equal("https://apis.deutschebahn.com/db-api-marketplace/apis/timetables/v1/", config.BaseUrl);
22+
Assert.Equal(string.Empty, config.ClientId);
23+
Assert.Equal(string.Empty, config.ApiKey);
24+
}
25+
26+
[Fact]
27+
public void Configuration_Properties_CanBeSet()
28+
{
29+
// Arrange
30+
var config = new Configuration();
31+
var expectedBaseUrl = "https://test.api.com/";
32+
var expectedClientId = "test-client-id";
33+
var expectedApiKey = "test-api-key";
34+
35+
// Act
36+
config.BaseUrl = expectedBaseUrl;
37+
config.ClientId = expectedClientId;
38+
config.ApiKey = expectedApiKey;
39+
40+
// Assert
41+
Assert.Equal(expectedBaseUrl, config.BaseUrl);
42+
Assert.Equal(expectedClientId, config.ClientId);
43+
Assert.Equal(expectedApiKey, config.ApiKey);
44+
}
45+
}

0 commit comments

Comments
 (0)