Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beitrag Lucas #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file added .vs/Assessment/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file added .vs/Assessment/v17/.futdcache.v1
Binary file not shown.
Binary file added .vs/ProjectEvaluation/assessment.metadata.v2
Binary file not shown.
Binary file added .vs/ProjectEvaluation/assessment.projects.v2
Binary file not shown.
29 changes: 29 additions & 0 deletions Assessment.Tests/Assessment.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<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.AspNetCore.Mvc.Testing" Version="8.0.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
</ItemGroup>

<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Assessment\Assessment.csproj" />
</ItemGroup>

</Project>
56 changes: 56 additions & 0 deletions Assessment.Tests/TimelogTypesControllerTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Xunit;
using Assessment.Controllers;
using Assessment.Models;
using Microsoft.AspNetCore.Mvc;


namespace Assessment.Tests
{
public class TimelogTypesControllerTests
{
[Fact]
public void GetTimelogTypes_ReturnsAllItems()
{
// Arrange: Controller-Instanz wird erstellt.
var controller = new TimelogTypesController();

// Act: Die GetTimelogTypes-Methode wird aufgerufen.
var result = controller.GetTimelogTypes();

// Assert: Überprüfe, ob das Ergebnis vom korrekten Typ ist und die erwartete Anzahl an Elementen enthält.// Assert
var viewResult = Assert.IsType<ActionResult<List<TimelogTypeResponse>>>(result);
var model = Assert.IsAssignableFrom<List<TimelogTypeResponse>>(viewResult.Value);
Assert.Equal(6, model.Count()); // Es werden 5 Elemente erwartet plus das eine Element was im CreateTimelogType_Validation_Fails_ForInvalidData() erstellt wird.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Abhängigkeit zu anderen Tests

}
[Fact]
public void GetTimelogType_WithInvalidId_ReturnsNotFound()
{
// Arrange: Controller-Instanz wird erstellt.
var controller = new TimelogTypesController();

// Act: Die GetTimelogType-Methode wird mit einer ungültigen ID aufgerufen.
var result = controller.GetTimelogType(9999); // 999 annehmen, dass diese ID nicht existiert

// Assert: Überprüfe, ob das Ergebnis ein NotFoundResult ist.
Assert.IsType<NotFoundResult>(result.Result);
}

[Fact]
public void CreateTimelogType_Validation_Fails_ForInvalidData()
{
// Arrange: Controller initialisieren und ungültige Testdaten erstellen
var controller = new TimelogTypesController();
var invalidTimelogType = new TimelogTypeRequest
{
timelogTypeId = 4,
timelogType = "Valid Timelog Type",
budget = -1 // Negativer Wert
};

// Act: Versuche, einen neuen TimelogType mit ungültigen Daten zu erstellen
var result = controller.CreateTimelogType(invalidTimelogType);

//Todo: Assert: Überprüfe, ob das Ergebnis ein BadRequestObjectResult ist und die Fehlermeldung enthält
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kein Assert

}
}
}
5,977 changes: 5,977 additions & 0 deletions Assessment.Tests/bin/Debug/net8.0/Assessment.Tests.deps.json

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"runtimeOptions": {
"tfm": "net8.0",
"frameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "8.0.0"
},
{
"name": "Microsoft.AspNetCore.App",
"version": "8.0.0"
}
],
"configProperties": {
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}
115 changes: 115 additions & 0 deletions Assessment.Tests/bin/Debug/net8.0/Assessment.deps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v6.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v6.0": {
"Assessment/1.0.0": {
"dependencies": {
"Swashbuckle.AspNetCore": "6.2.3"
},
"runtime": {
"Assessment.dll": {}
}
},
"Microsoft.Extensions.ApiDescription.Server/3.0.0": {},
"Microsoft.OpenApi/1.2.3": {
"runtime": {
"lib/netstandard2.0/Microsoft.OpenApi.dll": {
"assemblyVersion": "1.2.3.0",
"fileVersion": "1.2.3.0"
}
}
},
"Swashbuckle.AspNetCore/6.2.3": {
"dependencies": {
"Microsoft.Extensions.ApiDescription.Server": "3.0.0",
"Swashbuckle.AspNetCore.Swagger": "6.2.3",
"Swashbuckle.AspNetCore.SwaggerGen": "6.2.3",
"Swashbuckle.AspNetCore.SwaggerUI": "6.2.3"
}
},
"Swashbuckle.AspNetCore.Swagger/6.2.3": {
"dependencies": {
"Microsoft.OpenApi": "1.2.3"
},
"runtime": {
"lib/net6.0/Swashbuckle.AspNetCore.Swagger.dll": {
"assemblyVersion": "6.2.3.0",
"fileVersion": "6.2.3.0"
}
}
},
"Swashbuckle.AspNetCore.SwaggerGen/6.2.3": {
"dependencies": {
"Swashbuckle.AspNetCore.Swagger": "6.2.3"
},
"runtime": {
"lib/net6.0/Swashbuckle.AspNetCore.SwaggerGen.dll": {
"assemblyVersion": "6.2.3.0",
"fileVersion": "6.2.3.0"
}
}
},
"Swashbuckle.AspNetCore.SwaggerUI/6.2.3": {
"runtime": {
"lib/net6.0/Swashbuckle.AspNetCore.SwaggerUI.dll": {
"assemblyVersion": "6.2.3.0",
"fileVersion": "6.2.3.0"
}
}
}
}
},
"libraries": {
"Assessment/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Microsoft.Extensions.ApiDescription.Server/3.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-LH4OE/76F6sOCslif7+Xh3fS/wUUrE5ryeXAMcoCnuwOQGT5Smw0p57IgDh/pHgHaGz/e+AmEQb7pRgb++wt0w==",
"path": "microsoft.extensions.apidescription.server/3.0.0",
"hashPath": "microsoft.extensions.apidescription.server.3.0.0.nupkg.sha512"
},
"Microsoft.OpenApi/1.2.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-Nug3rO+7Kl5/SBAadzSMAVgqDlfGjJZ0GenQrLywJ84XGKO0uRqkunz5Wyl0SDwcR71bAATXvSdbdzPrYRYKGw==",
"path": "microsoft.openapi/1.2.3",
"hashPath": "microsoft.openapi.1.2.3.nupkg.sha512"
},
"Swashbuckle.AspNetCore/6.2.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-cnzQDn0Le+hInsw2SYwlOhOCPXpYi/szcvnyqZJ12v+QyrLBwAmWXBg6RIyHB18s/mLeywC+Rg2O9ndz0IUNYQ==",
"path": "swashbuckle.aspnetcore/6.2.3",
"hashPath": "swashbuckle.aspnetcore.6.2.3.nupkg.sha512"
},
"Swashbuckle.AspNetCore.Swagger/6.2.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-qOF7j1sL0bWm8g/qqHVPCvkO3JlVvUIB8WfC98kSh6BT5y5DAnBNctfac7XR5EZf+eD7/WasvANncTqwZYfmWQ==",
"path": "swashbuckle.aspnetcore.swagger/6.2.3",
"hashPath": "swashbuckle.aspnetcore.swagger.6.2.3.nupkg.sha512"
},
"Swashbuckle.AspNetCore.SwaggerGen/6.2.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-+Xq7WdMCCfcXlnbLJVFNgY8ITdP2TRYIlpbt6IKzDw5FwFxdi9lBfNDtcT+/wkKwX70iBBFmXldnnd02/VO72A==",
"path": "swashbuckle.aspnetcore.swaggergen/6.2.3",
"hashPath": "swashbuckle.aspnetcore.swaggergen.6.2.3.nupkg.sha512"
},
"Swashbuckle.AspNetCore.SwaggerUI/6.2.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-bCRI87uKJVb4G+KURWm8LQrL64St04dEFZcF6gIM67Zc0Sr/N47EO83ybLMYOvfNdO1DCv8xwPcrz9J/VEhQ5g==",
"path": "swashbuckle.aspnetcore.swaggerui/6.2.3",
"hashPath": "swashbuckle.aspnetcore.swaggerui.6.2.3.nupkg.sha512"
}
}
}
Binary file added Assessment.Tests/bin/Debug/net8.0/Assessment.dll
Binary file not shown.
Binary file added Assessment.Tests/bin/Debug/net8.0/Assessment.exe
Binary file not shown.
Binary file added Assessment.Tests/bin/Debug/net8.0/Assessment.pdb
Binary file not shown.
19 changes: 19 additions & 0 deletions Assessment.Tests/bin/Debug/net8.0/Assessment.runtimeconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"runtimeOptions": {
"tfm": "net6.0",
"frameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "6.0.0"
},
{
"name": "Microsoft.AspNetCore.App",
"version": "6.0.0"
}
],
"configProperties": {
"System.GC.Server": true,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Assessment.Tests/bin/Debug/net8.0/Moq.dll
Binary file not shown.
3 changes: 3 additions & 0 deletions Assessment.Tests/bin/Debug/net8.0/MvcTestingAppManifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"Assessment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null": "C:\\Users\\space\\Assessment\\Assessment"
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions Assessment.Tests/bin/Debug/net8.0/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading