diff --git a/Dockerfile b/Dockerfile index 14a8e1c..ed29c87 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ ARG MCR_REGISTRY=mcr.microsoft.com -FROM ${MCR_REGISTRY}/dotnet/sdk:8.0 AS build +FROM ${MCR_REGISTRY}/dotnet/sdk:10.0 AS build WORKDIR /app COPY src ./ @@ -16,7 +16,7 @@ RUN groupadd --gid "${GROUP_ID}" "${USERNAME}" && \ RUN dotnet publish -o publish -c Debug #RUN dotnet publish "Dataport.Terminfinder.WebAPI/Dataport.Terminfinder.WebAPI.csproj" -c Release -o /app/publish /p:UseAppHost=false -FROM ${MCR_REGISTRY}/dotnet/aspnet:8.0 +FROM ${MCR_REGISTRY}/dotnet/aspnet:10.0 WORKDIR /app #EXPOSE 80 diff --git a/README.md b/README.md index 24b4c93..898520e 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Copyright © 2022-2024 Dataport AöR * PostgreSql Database ## Requirements -* Microsoft dotnet 8, [ASP.NET Core Runtime 8.0](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) +* Microsoft dotnet 10, [ASP.NET Core Runtime 10.0](https://dotnet.microsoft.com/en-us/download/dotnet/10.0) * Database [PostgreSQL](https://www.postgresql.org/) ## Database diff --git a/src/Dataport.Terminfinder.BusinessLayer.Tests/AppointmentBusinessLayerTests.cs b/src/Dataport.Terminfinder.BusinessLayer.Tests/AppointmentBusinessLayerTests.cs index a98b40d..b9734b0 100644 --- a/src/Dataport.Terminfinder.BusinessLayer.Tests/AppointmentBusinessLayerTests.cs +++ b/src/Dataport.Terminfinder.BusinessLayer.Tests/AppointmentBusinessLayerTests.cs @@ -4,7 +4,6 @@ using Dataport.Terminfinder.Repository; using JetBrains.Annotations; using Microsoft.Extensions.Logging; -using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; namespace Dataport.Terminfinder.BusinessLayer.Tests; @@ -689,7 +688,7 @@ public void VerifyAppointmentPassword_NotProtected_ThrowsException() var sut = CreateSut(mockAppointmentRepo.Object); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.VerifyAppointmentPassword(ExpectedCustomerId, ExpectedAppointmentId, ExpectedPassword)); Assert.AreEqual(expectedExceptionMessage, exception.Message); } @@ -727,7 +726,7 @@ public void VerifyAppointmentPasswordByAdminId_NotProtected_ThrowsException() var sut = CreateSut(mockAppointmentRepo.Object); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.VerifyAppointmentPasswordByAdminId(ExpectedCustomerId, ExpectedAdminId, ExpectedPassword)); Assert.AreEqual(expectedExceptionMessage, exception.Message); } @@ -1024,8 +1023,7 @@ public void SetAppointmentStatusType_ChangeStatusType_DeletedToStarted_Exception var sut = CreateSut(mockAppointmentRepo.Object, mockCustomerRepo.Object, mockBcryptWrapper.Object); var appointmentObject = sut.SetAppointmentStatusType(ExpectedCustomerId, ExpectedAdminId, newStatusType); - Assert.IsTrue(appointmentObject == null); - Assert.IsFalse(appointmentObject != null); + Assert.IsNull(appointmentObject); } [TestMethod] @@ -1039,7 +1037,7 @@ public void SetAppointmentStatusType_NotProtected_ThrowsException() var sut = CreateSut(mockAppointmentRepo.Object); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.SetAppointmentStatusType(ExpectedCustomerId, ExpectedAdminId, AppointmentStatusType.Undefined)); Assert.AreEqual(expectedExceptionMessage, exception.Message); } diff --git a/src/Dataport.Terminfinder.BusinessLayer.Tests/BusinessLayerBaseTests.cs b/src/Dataport.Terminfinder.BusinessLayer.Tests/BusinessLayerBaseTests.cs index 1c3d8ca..8134f3c 100644 --- a/src/Dataport.Terminfinder.BusinessLayer.Tests/BusinessLayerBaseTests.cs +++ b/src/Dataport.Terminfinder.BusinessLayer.Tests/BusinessLayerBaseTests.cs @@ -2,7 +2,6 @@ using Dataport.Terminfinder.Repository; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; -using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; namespace Dataport.Terminfinder.BusinessLayer.Tests; diff --git a/src/Dataport.Terminfinder.BusinessLayer.Tests/Dataport.Terminfinder.BusinessLayer.Tests.csproj b/src/Dataport.Terminfinder.BusinessLayer.Tests/Dataport.Terminfinder.BusinessLayer.Tests.csproj index ee5b4c5..3a97fa2 100644 --- a/src/Dataport.Terminfinder.BusinessLayer.Tests/Dataport.Terminfinder.BusinessLayer.Tests.csproj +++ b/src/Dataport.Terminfinder.BusinessLayer.Tests/Dataport.Terminfinder.BusinessLayer.Tests.csproj @@ -1,12 +1,12 @@  - net8.0 + net10.0 enable false Portable {8E57A52E-327B-45F6-A19E-97FF379586D5} - 12 + default @@ -18,19 +18,19 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + - - + + diff --git a/src/Dataport.Terminfinder.BusinessLayer.Tests/Security/BcryptWrapperTests.cs b/src/Dataport.Terminfinder.BusinessLayer.Tests/Security/BcryptWrapperTests.cs index 80ef182..d768b71 100644 --- a/src/Dataport.Terminfinder.BusinessLayer.Tests/Security/BcryptWrapperTests.cs +++ b/src/Dataport.Terminfinder.BusinessLayer.Tests/Security/BcryptWrapperTests.cs @@ -1,6 +1,5 @@ using Dataport.Terminfinder.BusinessLayer.Security; using Microsoft.Extensions.Logging; -using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; namespace Dataport.Terminfinder.BusinessLayer.Tests.Security; @@ -26,7 +25,7 @@ public void Initialize() public void HashPassword_null_throwException() { var sut = CreateSut(saltGenerator); - Assert.ThrowsException(() => sut.HashPassword(null)); + Assert.ThrowsExactly(() => sut.HashPassword(null)); } [TestMethod] @@ -42,14 +41,14 @@ public void HashPassword_anyPassword_createdBcryptHash() public void HashPassword_passwordIsNullHashIsNotNull_throwException() { var sut = CreateSut(saltGenerator); - Assert.ThrowsException(() => sut.Verify(null, string.Empty)); + Assert.ThrowsExactly(() => sut.Verify(null, string.Empty)); } [TestMethod] public void HashPassword_passwordIsNotNullPasswordIsNull_throwException() { var sut = CreateSut(saltGenerator); - Assert.ThrowsException(() => sut.Verify(string.Empty, null)); + Assert.ThrowsExactly(() => sut.Verify(string.Empty, null)); } [TestMethod] diff --git a/src/Dataport.Terminfinder.BusinessLayer.Tests/Security/SaltGeneratorTests.cs b/src/Dataport.Terminfinder.BusinessLayer.Tests/Security/SaltGeneratorTests.cs index c3ae77d..f51314c 100644 --- a/src/Dataport.Terminfinder.BusinessLayer.Tests/Security/SaltGeneratorTests.cs +++ b/src/Dataport.Terminfinder.BusinessLayer.Tests/Security/SaltGeneratorTests.cs @@ -1,6 +1,5 @@ using Dataport.Terminfinder.BusinessLayer.Security; using Microsoft.Extensions.Logging; -using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; namespace Dataport.Terminfinder.BusinessLayer.Tests.Security; diff --git a/src/Dataport.Terminfinder.BusinessLayer/AppConfigBusinessLayer.cs b/src/Dataport.Terminfinder.BusinessLayer/AppConfigBusinessLayer.cs index b235494..5d13ba9 100644 --- a/src/Dataport.Terminfinder.BusinessLayer/AppConfigBusinessLayer.cs +++ b/src/Dataport.Terminfinder.BusinessLayer/AppConfigBusinessLayer.cs @@ -1,5 +1,5 @@ -using Dataport.Terminfinder.Repository; -using Dataport.Terminfinder.BusinessObject; +using Dataport.Terminfinder.BusinessObject; +using Dataport.Terminfinder.Repository; namespace Dataport.Terminfinder.BusinessLayer; diff --git a/src/Dataport.Terminfinder.BusinessLayer/Dataport.Terminfinder.BusinessLayer.csproj b/src/Dataport.Terminfinder.BusinessLayer/Dataport.Terminfinder.BusinessLayer.csproj index 8aca638..6fcb543 100644 --- a/src/Dataport.Terminfinder.BusinessLayer/Dataport.Terminfinder.BusinessLayer.csproj +++ b/src/Dataport.Terminfinder.BusinessLayer/Dataport.Terminfinder.BusinessLayer.csproj @@ -1,13 +1,13 @@  - net8.0 + net10.0 enable Dataport.Terminfinder.BusinessLayer Dataport.Terminfinder.BusinessLayer Portable {B8152437-534A-4732-81C0-AEEF53A79D69} - 12 + default @@ -24,11 +24,11 @@ - - - - - + + + + + diff --git a/src/Dataport.Terminfinder.BusinessObject.Tests/Dataport.Terminfinder.BusinessObject.Tests.csproj b/src/Dataport.Terminfinder.BusinessObject.Tests/Dataport.Terminfinder.BusinessObject.Tests.csproj index cb751d6..e2220d0 100644 --- a/src/Dataport.Terminfinder.BusinessObject.Tests/Dataport.Terminfinder.BusinessObject.Tests.csproj +++ b/src/Dataport.Terminfinder.BusinessObject.Tests/Dataport.Terminfinder.BusinessObject.Tests.csproj @@ -1,12 +1,12 @@  - net8.0 + net10.0 enable false Portable {D8A42831-89E7-4D75-B9A6-9C949A84C46D} - 12 + default @@ -18,18 +18,18 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + diff --git a/src/Dataport.Terminfinder.BusinessObject.Tests/JsonSerializer/DateConverterTests.cs b/src/Dataport.Terminfinder.BusinessObject.Tests/JsonSerializer/DateConverterTests.cs index 9c1f695..9f6d791 100644 --- a/src/Dataport.Terminfinder.BusinessObject.Tests/JsonSerializer/DateConverterTests.cs +++ b/src/Dataport.Terminfinder.BusinessObject.Tests/JsonSerializer/DateConverterTests.cs @@ -62,7 +62,7 @@ public void ReadJson_NonValidDateValueAsString_deserializedDateValue_false() var dt = "99.99.2015"; var sut = new DateConverter(); - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => { using var sr = new StringReader($"\"{dt}\""); using var jsonReader = new JsonTextReader(sr); diff --git a/src/Dataport.Terminfinder.BusinessObject.Tests/Validators/EnsureMaximumElementsAttributeTests.cs b/src/Dataport.Terminfinder.BusinessObject.Tests/Validators/EnsureMaximumElementsAttributeTests.cs index ccd13c8..748f1fb 100644 --- a/src/Dataport.Terminfinder.BusinessObject.Tests/Validators/EnsureMaximumElementsAttributeTests.cs +++ b/src/Dataport.Terminfinder.BusinessObject.Tests/Validators/EnsureMaximumElementsAttributeTests.cs @@ -26,7 +26,7 @@ public IEnumerable Validate(ValidationContext validationContex [TestMethod] public void Constructor_MaxElementsValueIsTooGreat_throwException() { - Assert.ThrowsException(() => new EnsureMaximumElementsAttribute() + Assert.ThrowsExactly(() => new EnsureMaximumElementsAttribute() { ErrorMessage = ExectedEnsureMaximumElementsAttributeErrorMessage, MaxElements = 10001 diff --git a/src/Dataport.Terminfinder.BusinessObject.Tests/Validators/EnsureMinimumElementsAttributeTests.cs b/src/Dataport.Terminfinder.BusinessObject.Tests/Validators/EnsureMinimumElementsAttributeTests.cs index 281a656..6f5a68a 100644 --- a/src/Dataport.Terminfinder.BusinessObject.Tests/Validators/EnsureMinimumElementsAttributeTests.cs +++ b/src/Dataport.Terminfinder.BusinessObject.Tests/Validators/EnsureMinimumElementsAttributeTests.cs @@ -26,7 +26,7 @@ public IEnumerable Validate(ValidationContext validationContex [TestMethod] public void Constructor_MinElementsValueIsTooSmall_throwException() { - Assert.ThrowsException(() => new EnsureMinimumElementsAttribute + Assert.ThrowsExactly(() => new EnsureMinimumElementsAttribute { ErrorMessage = ExectedEnsureMinimumElementsAttributeErrorMessage, MinElements = 0 diff --git a/src/Dataport.Terminfinder.BusinessObject.Tests/Validators/PasswordValidatorTests.cs b/src/Dataport.Terminfinder.BusinessObject.Tests/Validators/PasswordValidatorTests.cs index a01fa55..505769b 100644 --- a/src/Dataport.Terminfinder.BusinessObject.Tests/Validators/PasswordValidatorTests.cs +++ b/src/Dataport.Terminfinder.BusinessObject.Tests/Validators/PasswordValidatorTests.cs @@ -245,6 +245,6 @@ public void IsValid_InvalidPasswordNoSpecialCharacter_false() [TestMethod] public void IsValid_null_throwException() { - Assert.ThrowsException(() => PasswordValidator.IsValid(null)); + Assert.ThrowsExactly(() => PasswordValidator.IsValid(null)); } } \ No newline at end of file diff --git a/src/Dataport.Terminfinder.BusinessObject/Dataport.Terminfinder.BusinessObject.csproj b/src/Dataport.Terminfinder.BusinessObject/Dataport.Terminfinder.BusinessObject.csproj index 4f0b833..5582f3e 100644 --- a/src/Dataport.Terminfinder.BusinessObject/Dataport.Terminfinder.BusinessObject.csproj +++ b/src/Dataport.Terminfinder.BusinessObject/Dataport.Terminfinder.BusinessObject.csproj @@ -1,13 +1,13 @@  - net8.0 + net10.0 enable Dataport.Terminfinder.BusinessObject Dataport.Terminfinder.BusinessObject Portable {EF3E18F3-A3ED-48F2-B006-2D24FB2C7C14} - 12 + default @@ -23,7 +23,7 @@ - + diff --git a/src/Dataport.Terminfinder.Common.Tests/Dataport.Terminfinder.Common.Tests.csproj b/src/Dataport.Terminfinder.Common.Tests/Dataport.Terminfinder.Common.Tests.csproj index 3f4631b..3f48d2c 100644 --- a/src/Dataport.Terminfinder.Common.Tests/Dataport.Terminfinder.Common.Tests.csproj +++ b/src/Dataport.Terminfinder.Common.Tests/Dataport.Terminfinder.Common.Tests.csproj @@ -1,12 +1,12 @@  - net8.0 + net10.0 enable false Portable {D5D97A5B-B33E-4ED9-BF4E-549C3A265978} - 12 + default @@ -18,17 +18,17 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + diff --git a/src/Dataport.Terminfinder.Common.Tests/Extension/EnumerableExtensionsTests.cs b/src/Dataport.Terminfinder.Common.Tests/Extension/EnumerableExtensionsTests.cs index 4a36d9c..8284ae9 100644 --- a/src/Dataport.Terminfinder.Common.Tests/Extension/EnumerableExtensionsTests.cs +++ b/src/Dataport.Terminfinder.Common.Tests/Extension/EnumerableExtensionsTests.cs @@ -1,5 +1,4 @@ using Dataport.Terminfinder.Common.Extension; -using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Collections; namespace Dataport.Terminfinder.Common.Tests.Extension; diff --git a/src/Dataport.Terminfinder.Common.Tests/Extension/StringExtensionsTests.cs b/src/Dataport.Terminfinder.Common.Tests/Extension/StringExtensionsTests.cs index 2dcd8e4..b5028d5 100644 --- a/src/Dataport.Terminfinder.Common.Tests/Extension/StringExtensionsTests.cs +++ b/src/Dataport.Terminfinder.Common.Tests/Extension/StringExtensionsTests.cs @@ -1,5 +1,4 @@ using Dataport.Terminfinder.Common.Extension; -using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Dataport.Terminfinder.Common.Tests.Extension; diff --git a/src/Dataport.Terminfinder.Common/Dataport.Terminfinder.Common.csproj b/src/Dataport.Terminfinder.Common/Dataport.Terminfinder.Common.csproj index 2f3466c..e447498 100644 --- a/src/Dataport.Terminfinder.Common/Dataport.Terminfinder.Common.csproj +++ b/src/Dataport.Terminfinder.Common/Dataport.Terminfinder.Common.csproj @@ -1,13 +1,13 @@  - net8.0 + net10.0 enable Dataport.Terminfinder.Common Dataport.Terminfinder.Common Portable {5CF17597-DF2A-4FD2-A725-33E7E41B0A86} - 12 + default @@ -23,7 +23,7 @@ - + diff --git a/src/Dataport.Terminfinder.DeleteAppointments.Tool.Tests/Dataport.Terminfinder.DeleteAppointments.Tool.Tests.csproj b/src/Dataport.Terminfinder.DeleteAppointments.Tool.Tests/Dataport.Terminfinder.DeleteAppointments.Tool.Tests.csproj index e3ac25a..411f6f1 100644 --- a/src/Dataport.Terminfinder.DeleteAppointments.Tool.Tests/Dataport.Terminfinder.DeleteAppointments.Tool.Tests.csproj +++ b/src/Dataport.Terminfinder.DeleteAppointments.Tool.Tests/Dataport.Terminfinder.DeleteAppointments.Tool.Tests.csproj @@ -1,13 +1,13 @@  - net8.0 + net10.0 enable false Portable Dataport.Terminfinder.Console.DeleteAppointments.Tool.Tests {7CBEE738-07EE-4592-84DB-192E30AE7B31} - 12 + default @@ -19,19 +19,19 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + - - + + diff --git a/src/Dataport.Terminfinder.DeleteAppointments.Tool.Tests/DeleteAppointmentsTests.cs b/src/Dataport.Terminfinder.DeleteAppointments.Tool.Tests/DeleteAppointmentsTests.cs index 20d56ce..06f99a2 100644 --- a/src/Dataport.Terminfinder.DeleteAppointments.Tool.Tests/DeleteAppointmentsTests.cs +++ b/src/Dataport.Terminfinder.DeleteAppointments.Tool.Tests/DeleteAppointmentsTests.cs @@ -1,5 +1,4 @@ using Microsoft.Extensions.Logging; -using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; using System.Diagnostics.CodeAnalysis; @@ -36,7 +35,7 @@ public void DeleteExpiredAppointments_ConnectionStringIsEmpty_ApplicationExcepti var deleteExpiredAppointments = new DeleteAppointmentsService(mockRepository.Object, _logger); // Act - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => deleteExpiredAppointments.DeleteExpiredAppointments(connectionString, customerId, deleteExpiredAppointmentsAfterDays, _dateTimeGeneratorServiceFake)); Assert.AreEqual(expectedErrorMessage, exception.Message); @@ -56,7 +55,7 @@ public void DeleteExpiredAppointments_deleteExpiredAppointmentsAfterDaysGreaterT var deleteExpiredAppointments = new DeleteAppointmentsService(mockRepository.Object, _logger); // Act - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => deleteExpiredAppointments.DeleteExpiredAppointments(connectionString, customerId, deleteExpiredAppointmentsAfterDays, _dateTimeGeneratorServiceFake)); Assert.AreEqual(expectedErrorMessage, exception.Message); @@ -77,7 +76,7 @@ public void DeleteExpiredAppointments_customerIdIsEmpty_ApplicationException() var deleteExpiredAppointments = new DeleteAppointmentsService(mockRepository.Object, _logger); // Act - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => deleteExpiredAppointments.DeleteExpiredAppointments(connectionString, customerId, deleteExpiredAppointmentsAfterDays, _dateTimeGeneratorServiceFake)); Assert.AreEqual(expectedErrorMessage, exception.Message); diff --git a/src/Dataport.Terminfinder.DeleteAppointments.Tool/Dataport.Terminfinder.DeleteAppointments.Tool.csproj b/src/Dataport.Terminfinder.DeleteAppointments.Tool/Dataport.Terminfinder.DeleteAppointments.Tool.csproj index 89e67c0..2dff0a3 100644 --- a/src/Dataport.Terminfinder.DeleteAppointments.Tool/Dataport.Terminfinder.DeleteAppointments.Tool.csproj +++ b/src/Dataport.Terminfinder.DeleteAppointments.Tool/Dataport.Terminfinder.DeleteAppointments.Tool.csproj @@ -1,7 +1,7 @@  - net8.0 + net10.0 enable Dataport.Terminfinder.DeleteAppointments Dataport.Terminfinder.Console.DeleteAppointments.Tool.Program @@ -12,7 +12,7 @@ Exe true {572E043B-91FA-48E0-AC5F-5A73945E953F} - 12 + default @@ -42,17 +42,17 @@ - - - - - - + + + + + + - - - - + + + + diff --git a/src/Dataport.Terminfinder.Repository.Migrate/Dataport.Terminfinder.Repository.Migrate.csproj b/src/Dataport.Terminfinder.Repository.Migrate/Dataport.Terminfinder.Repository.Migrate.csproj index 31eebdb..c3d5f23 100644 --- a/src/Dataport.Terminfinder.Repository.Migrate/Dataport.Terminfinder.Repository.Migrate.csproj +++ b/src/Dataport.Terminfinder.Repository.Migrate/Dataport.Terminfinder.Repository.Migrate.csproj @@ -2,16 +2,16 @@ Exe - net8.0 + net10.0 enable enable Linux - - - + + + diff --git a/src/Dataport.Terminfinder.Repository.Migrate/Enum/ErrorType.cs b/src/Dataport.Terminfinder.Repository.Migrate/Enum/ErrorType.cs index f584727..88a5252 100644 --- a/src/Dataport.Terminfinder.Repository.Migrate/Enum/ErrorType.cs +++ b/src/Dataport.Terminfinder.Repository.Migrate/Enum/ErrorType.cs @@ -1,4 +1,4 @@ -namespace Dataport.Terminfinder.Console.DeleteAppointments.Tool.Enum; +namespace Dataport.Terminfinder.Repository.Migrate.Enum; /// /// Error numbers diff --git a/src/Dataport.Terminfinder.Repository.Migrate/MigrateDatabase.cs b/src/Dataport.Terminfinder.Repository.Migrate/MigrateDatabase.cs index 1fb415b..2d7be2a 100644 --- a/src/Dataport.Terminfinder.Repository.Migrate/MigrateDatabase.cs +++ b/src/Dataport.Terminfinder.Repository.Migrate/MigrateDatabase.cs @@ -1,4 +1,4 @@ -using Dataport.Terminfinder.Console.DeleteAppointments.Tool.Enum; +using Dataport.Terminfinder.Repository.Migrate.Enum; using Dataport.Terminfinder.Repository.Setup; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; diff --git a/src/Dataport.Terminfinder.Repository.Tests/AppointmentRepositoryTests.cs b/src/Dataport.Terminfinder.Repository.Tests/AppointmentRepositoryTests.cs index 084a012..97b6a2a 100644 --- a/src/Dataport.Terminfinder.Repository.Tests/AppointmentRepositoryTests.cs +++ b/src/Dataport.Terminfinder.Repository.Tests/AppointmentRepositoryTests.cs @@ -336,7 +336,7 @@ public void GetAppointmentPassword_AppointmentDoesNotExists_ThrowException() var sut = CreateSut(); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.GetAppointmentPassword(ExpectedCustomerId, unknownAppointmentId)); Assert.AreEqual(expectedExceptionMessage, exception.Message); } @@ -365,7 +365,7 @@ public void GetAppointmentPasswordByAdmin_AppointmentDoesNotExists_ThrowExceptio var sut = CreateSut(); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.GetAppointmentPasswordByAdmin(ExpectedCustomerId, unknownAdminId)); Assert.AreEqual(expectedExceptionMessage, exception.Message); } @@ -413,7 +413,7 @@ public void GetAppointmentStatusTypeByAdmin_AppointmentStatusDeleted_False() // act fetch var sut = CreateSut(mockAppointmentsSet); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.GetAppointmentStatusTypeByAdmin(ExpectedCustomerId, ExpectedAdminId)); Assert.AreEqual(expectedExceptionMessage, exception.Message); } @@ -426,7 +426,7 @@ public void GetAppointmentStatusTypeByAdmin_AppointmentDoesNotExists_ThrowsExcep var sut = CreateSut(); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.GetAppointmentStatusTypeByAdmin(Guid.Empty, Guid.Empty)); Assert.AreEqual(expectedExceptionMessage, exception.Message); } @@ -443,7 +443,7 @@ public void SetAppointmentStatusTypeByAdmin_AppointmentDoesNotExists_ThrowsExcep var sut = CreateSut(); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.SetAppointmentStatusTypeByAdmin(Guid.Empty, Guid.Empty, nameof(AppointmentStatusType.Paused))); Assert.AreEqual(expectedExceptionMessage, exception.Message); } diff --git a/src/Dataport.Terminfinder.Repository.Tests/CustomerRepositoryTests.cs b/src/Dataport.Terminfinder.Repository.Tests/CustomerRepositoryTests.cs index 457a1e6..f2470a1 100644 --- a/src/Dataport.Terminfinder.Repository.Tests/CustomerRepositoryTests.cs +++ b/src/Dataport.Terminfinder.Repository.Tests/CustomerRepositoryTests.cs @@ -44,7 +44,7 @@ public void GetCustomer_GuidIsEmpty_ArgumentNullException() var sut = CreateSut(); - var exception = Assert.ThrowsException(() => sut.GetCustomer(Guid.Empty)); + var exception = Assert.ThrowsExactly(() => sut.GetCustomer(Guid.Empty)); Assert.AreEqual(expectedExceptionMessage, exception.Message); } diff --git a/src/Dataport.Terminfinder.Repository.Tests/Dataport.Terminfinder.Repository.Tests.csproj b/src/Dataport.Terminfinder.Repository.Tests/Dataport.Terminfinder.Repository.Tests.csproj index 0d64132..a0b0308 100644 --- a/src/Dataport.Terminfinder.Repository.Tests/Dataport.Terminfinder.Repository.Tests.csproj +++ b/src/Dataport.Terminfinder.Repository.Tests/Dataport.Terminfinder.Repository.Tests.csproj @@ -1,12 +1,12 @@  - net8.0 + net10.0 enable false Portable {20BB21C0-FC32-47B8-8668-CBA6064AB4B8} - 12 + default @@ -18,21 +18,21 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + - - + + diff --git a/src/Dataport.Terminfinder.Repository/DataContext.cs b/src/Dataport.Terminfinder.Repository/DataContext.cs index 8dfe17b..193c4b0 100644 --- a/src/Dataport.Terminfinder.Repository/DataContext.cs +++ b/src/Dataport.Terminfinder.Repository/DataContext.cs @@ -1,5 +1,5 @@ -using Microsoft.EntityFrameworkCore; -using Dataport.Terminfinder.BusinessObject; +using Dataport.Terminfinder.BusinessObject; +using Microsoft.EntityFrameworkCore; namespace Dataport.Terminfinder.Repository; diff --git a/src/Dataport.Terminfinder.Repository/Dataport.Terminfinder.Repository.csproj b/src/Dataport.Terminfinder.Repository/Dataport.Terminfinder.Repository.csproj index b07b8a3..99f800b 100644 --- a/src/Dataport.Terminfinder.Repository/Dataport.Terminfinder.Repository.csproj +++ b/src/Dataport.Terminfinder.Repository/Dataport.Terminfinder.Repository.csproj @@ -1,13 +1,13 @@  - net8.0 + net10.0 enable Dataport.Terminfinder.Repository Dataport.Terminfinder.Repository Portable {C0ADC4D5-5A72-46CE-B424-5251437E0924} - 12 + default @@ -23,11 +23,11 @@ - - - - - + + + + + diff --git a/src/Dataport.Terminfinder.WebAPI.Tests/Controllers/AdminControllerTests.cs b/src/Dataport.Terminfinder.WebAPI.Tests/Controllers/AdminControllerTests.cs index 69baa70..4bab1b6 100644 --- a/src/Dataport.Terminfinder.WebAPI.Tests/Controllers/AdminControllerTests.cs +++ b/src/Dataport.Terminfinder.WebAPI.Tests/Controllers/AdminControllerTests.cs @@ -55,7 +55,7 @@ public void GetAppointment_AdminIdIsEmpty() var sut = CreateSut(mockBusinessLayer.Object); - var exception = Assert.ThrowsException(() => sut.Get(ExpectedCustomerId.ToString(), string.Empty)); + var exception = Assert.ThrowsExactly(() => sut.Get(ExpectedCustomerId.ToString(), string.Empty)); Assert.AreEqual(ErrorType.AdminIdNotValid, exception.ErrorCode); } @@ -68,7 +68,7 @@ public void GetAppointment_NotFound() var sut = CreateSut(mockBusinessLayer.Object); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Get(ExpectedCustomerId.ToString(), Guid.NewGuid().ToString())); Assert.AreEqual(ErrorType.AppointmentNotFound, exception.ErrorCode); } @@ -98,7 +98,7 @@ public void GetAppointment_verificationFailed_Unauthorized() var sut = CreateSut(mockBusinessLayer.Object, mockRequestContext.Object); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Get(ExpectedCustomerId.ToString(), ExpectedAdminId.ToString())); Assert.AreEqual(ErrorType.AuthorizationFailed, exception.ErrorCode); } @@ -208,10 +208,10 @@ public void GetProtection_GuidsAreInvalid_ThrowsException() var sut = CreateSut(mockBusinessLayer.Object, mockRequestContext.Object); - var exceptionCustomerId = Assert.ThrowsException(() => + var exceptionCustomerId = Assert.ThrowsExactly(() => sut.GetProtection(ExpectedInvalidGuidString, ExpectedAdminId.ToString())); Assert.AreEqual(ErrorType.CustomerIdNotValid, exceptionCustomerId.ErrorCode); - var exceptionAdminId = Assert.ThrowsException(() => + var exceptionAdminId = Assert.ThrowsExactly(() => sut.GetProtection(ExpectedCustomerId.ToString(), ExpectedInvalidGuidString)); Assert.AreEqual(ErrorType.AdminIdNotValid, exceptionAdminId.ErrorCode); } @@ -272,7 +272,7 @@ public void SetStatus_AppointmentIsNull_ThrowsException() var sut = CreateSut(mockBusinessLayer.Object); - var exception = Assert.ThrowsException(() => sut.SetStatus(ExpectedCustomerId.ToString(), + var exception = Assert.ThrowsExactly(() => sut.SetStatus(ExpectedCustomerId.ToString(), ExpectedAdminId.ToString(), ExpectedAppointmentStatusType.ToString())); Assert.AreEqual(ErrorType.AppointmentStatusTypeNotAllowed, exception.ErrorCode); } @@ -285,7 +285,7 @@ public void SetStatus_GuidsInvalid_ThrowsException() var sut = CreateSut(mockBusinessLayer.Object, mockRequestContext.Object); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.SetStatus(ExpectedInvalidGuidString, ExpectedInvalidGuidString, string.Empty)); Assert.AreEqual(ErrorType.CustomerIdNotValid, exception.ErrorCode); } @@ -402,7 +402,7 @@ public void GetPasswordVerification_GuidsInvalid_ThrowsException() var sut = CreateSut(mockBusinessLayer.Object, mockRequestContext.Object); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.GetPasswordVerification(ExpectedInvalidGuidString, ExpectedInvalidGuidString)); Assert.AreEqual(ErrorType.CustomerIdNotValid, exception.ErrorCode); } diff --git a/src/Dataport.Terminfinder.WebAPI.Tests/Controllers/ApiControllerBaseTests.cs b/src/Dataport.Terminfinder.WebAPI.Tests/Controllers/ApiControllerBaseTests.cs index 777367e..0ab1f93 100644 --- a/src/Dataport.Terminfinder.WebAPI.Tests/Controllers/ApiControllerBaseTests.cs +++ b/src/Dataport.Terminfinder.WebAPI.Tests/Controllers/ApiControllerBaseTests.cs @@ -16,7 +16,7 @@ public void BuildAdditionalErrorMessageFromModelState_ModelStateIsValid_ThrowsEx sut.ControllerContext = new ControllerContext { HttpContext = new DefaultHttpContext() }; sut.ModelState.Clear(); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.PublicBuildAdditionalErrorMessageFromModelState()); Assert.AreEqual(expectedExceptionMessage, exception.Message); } @@ -29,7 +29,7 @@ public void ValidateCustomerRequest_CustomerIdIsInvalid_ThrowsException() var sut = CreateSut(); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.PublicValidateCustomerRequest(invalidCustomerId, mockAppointmentBusinessLayer.Object)); Assert.AreEqual(ErrorType.CustomerIdNotFound, exception.ErrorCode); } @@ -39,7 +39,7 @@ public void ValidateCustomerRequest_AppointmentBusinessLayerIsNull_ThrowsExcepti { var sut = CreateSut(); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.PublicValidateCustomerRequest(ExpectedCustomerId, null)); Assert.AreEqual(ErrorType.CustomerIdNotFound, exception.ErrorCode); } @@ -52,7 +52,7 @@ public void ValidateCustomerRequest_CustomerWithIdDoesNotExist_ThrowsException() var sut = CreateSut(); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.PublicValidateCustomerRequest(ExpectedCustomerId, mockAppointmentBusinessLayer.Object)); Assert.AreEqual(ErrorType.CustomerIdNotFound, exception.ErrorCode); } @@ -66,7 +66,7 @@ public void ValidateAppointmentRequest_AppointmentIdIsInvalid_ThrowsException() var sut = CreateSut(); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.PublicValidateAppointmentRequest(ExpectedCustomerId, invalidAppointmentId, mockAppointmentBusinessLayer.Object)); Assert.AreEqual(ErrorType.AppointmentIdNotFound, exception.ErrorCode); @@ -86,7 +86,7 @@ public void ValidateAppointmentRequest_AdminIdIsInvalid_ThrowsException() var sut = CreateSut(); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.PublicValidateAppointmentRequest(ExpectedCustomerId, ExpectedAppointmentId, invalidAdminId, mockAppointmentBusinessLayer.Object)); Assert.AreEqual(ErrorType.AppointmentIdNotFound, exception.ErrorCode); @@ -105,7 +105,7 @@ public void ValidateAppointmentRequest_AppointmentDoesNotExist_ThrowsException() var sut = CreateSut(); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.PublicValidateAppointmentRequest(ExpectedCustomerId, ExpectedAppointmentId, ExpectedAdminId, mockAppointmentBusinessLayer.Object)); Assert.AreEqual(ErrorType.AppointmentNotFound, exception.ErrorCode); diff --git a/src/Dataport.Terminfinder.WebAPI.Tests/Controllers/AppointmentControllerTests.cs b/src/Dataport.Terminfinder.WebAPI.Tests/Controllers/AppointmentControllerTests.cs index dabafe2..19adff8 100644 --- a/src/Dataport.Terminfinder.WebAPI.Tests/Controllers/AppointmentControllerTests.cs +++ b/src/Dataport.Terminfinder.WebAPI.Tests/Controllers/AppointmentControllerTests.cs @@ -68,7 +68,7 @@ public void GetAppointment_AppointmentId_NotFound() var sut = CreateSut(mockBusinessLayer.Object); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Get(ExpectedCustomerId.ToString(), Guid.NewGuid().ToString())); Assert.AreEqual(ErrorType.AppointmentNotFound, exception.ErrorCode); } @@ -93,7 +93,7 @@ public void GetAppointment_AppointmentIdIsEmpty() var sut = CreateSut(mockBusinessLayer.Object); // Act - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Get(ExpectedCustomerId.ToString(), string.Empty)); Assert.AreEqual(ErrorType.AppointmentIdNotValid, exception.ErrorCode); } @@ -114,7 +114,7 @@ public void GetAppointment_noUserCredentialSubmittedButTheyAreRequired_Unauthori var sut = CreateSut(mockBusinessLayer.Object); // Act - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Get(ExpectedCustomerId.ToString(), ExpectedAppointmentId.ToString())); Assert.AreEqual(ErrorType.PasswordRequired, exception.ErrorCode); } @@ -143,7 +143,7 @@ public void GetAppointment_verificationFailed_Unauthorized() var sut = CreateSut(mockBusinessLayer.Object, mockRequestContext.Object); // Act - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Get(ExpectedCustomerId.ToString(), ExpectedAppointmentId.ToString())); Assert.AreEqual(ErrorType.AuthorizationFailed, exception.ErrorCode); } @@ -169,7 +169,7 @@ public void GetAppointment_verificationFailedPasswordCanNotBeDecoded_BadRequest( var sut = CreateSut(mockBusinessLayer.Object, mockRequestContext.Object); // Act - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Get(ExpectedCustomerId.ToString(), ExpectedAppointmentId.ToString())); Assert.AreEqual(ErrorType.DecodingPasswordFailed, exception.ErrorCode); } @@ -211,10 +211,10 @@ public void GetAppointment_GuidsAreInvalid_ThrowsException() { var sut = CreateSut(); - var exceptionCustomerId = Assert.ThrowsException(() => + var exceptionCustomerId = Assert.ThrowsExactly(() => sut.Get(ExpectedInvalidGuidString, ExpectedAppointmentId.ToString())); Assert.AreEqual(ErrorType.CustomerIdNotValid, exceptionCustomerId.ErrorCode); - var exceptionAppointmentId = Assert.ThrowsException(() => + var exceptionAppointmentId = Assert.ThrowsExactly(() => sut.Get(ExpectedCustomerId.ToString(), ExpectedInvalidGuidString)); Assert.AreEqual(ErrorType.AppointmentIdNotValid, exceptionAppointmentId.ErrorCode); } @@ -229,7 +229,7 @@ public void GetAppointment_AppointmentIsNull_ThrowsException() var sut = CreateSut(mockBusinessLayer.Object); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Get(ExpectedCustomerId.ToString(), ExpectedAppointmentId.ToString())); Assert.AreEqual(ErrorType.AppointmentNotFound, exception.ErrorCode); } @@ -317,7 +317,7 @@ public void AddAppointment_WithAppointmentId_FailedNotFound() var sut = CreateSut(mockBusinessLayer.Object); // Act - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Post(appointment, ExpectedCustomerId.ToString())); Assert.AreEqual(ErrorType.IdsMustBeEmpty, exception.ErrorCode); } @@ -335,7 +335,7 @@ public void AddAppointment_WithAdminId_FailedNotFound() var sut = CreateSut(mockBusinessLayer.Object); // Act - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Post(appointment, ExpectedCustomerId.ToString())); Assert.AreEqual(ErrorType.IdsMustBeEmpty, exception.ErrorCode); } @@ -353,7 +353,7 @@ public void AddAppointment_ParticipantCountExceedsLimit_ThrowsException() var sut = CreateSut(mockBusinessLayer.Object); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Post(new Appointment(), ExpectedCustomerId.ToString())); Assert.AreEqual(ErrorType.MaximumElementsOfParticipantsAreExceeded, exception.ErrorCode); } @@ -376,7 +376,7 @@ public void AddAppointment_SuggestedDateCountExceedsLimit_ThrowsException() var sut = CreateSut(mockBusinessLayer.Object); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Post(new Appointment(), ExpectedCustomerId.ToString())); Assert.AreEqual(ErrorType.MaximumElementsOfSuggestedDatesAreExceeded, exception.ErrorCode); } @@ -404,7 +404,7 @@ public void AddAppointment_SuggestedDateCountSubceedsLimit_ThrowsException() var sut = CreateSut(mockBusinessLayer.Object); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Post(new Appointment(), ExpectedCustomerId.ToString())); Assert.AreEqual(ErrorType.MinimumElementsOfSuggestedDatesAreNotExceeded, exception.ErrorCode); } @@ -435,7 +435,7 @@ public void AddAppointment_verificationFailed_Unauthorized() var sut = CreateSut(mockBusinessLayer.Object, mockRequestContext.Object); // Act - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Put(new Appointment { AppointmentId = ExpectedAppointmentId, @@ -458,7 +458,7 @@ public void UpdateAppointment_CustomerIdIsInvalid_ThrowsException() var sut = CreateSut(mockBusinessLayer.Object, mockRequestContext.Object); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Put(appointment, ExpectedInvalidGuidString)); Assert.AreEqual(ErrorType.CustomerIdNotValid, exception.ErrorCode); } @@ -524,10 +524,10 @@ public void GetProtection_GuidsAreInvalid_ThrowsException() { var sut = CreateSut(); - var exceptionCustomerId = Assert.ThrowsException(() => + var exceptionCustomerId = Assert.ThrowsExactly(() => sut.GetProtection(ExpectedInvalidGuidString, ExpectedAppointmentId.ToString())); Assert.AreEqual(ErrorType.CustomerIdNotValid, exceptionCustomerId.ErrorCode); - var exceptionAppointmentId = Assert.ThrowsException(() => + var exceptionAppointmentId = Assert.ThrowsExactly(() => sut.GetProtection(ExpectedCustomerId.ToString(), ExpectedInvalidGuidString)); Assert.AreEqual(ErrorType.AppointmentIdNotValid, exceptionAppointmentId.ErrorCode); } @@ -635,10 +635,10 @@ public void GetPasswordVerification_GuidsAreInvalid_ThrowsException() var mockBusinessLayer = new Mock(); var sut = CreateSut(mockBusinessLayer.Object); - var exceptionCustomerId = Assert.ThrowsException(() => + var exceptionCustomerId = Assert.ThrowsExactly(() => sut.GetPasswordVerification(ExpectedInvalidGuidString, ExpectedAppointmentId.ToString())); Assert.AreEqual(ErrorType.CustomerIdNotValid, exceptionCustomerId.ErrorCode); - var exceptionAppointmentId = Assert.ThrowsException(() => + var exceptionAppointmentId = Assert.ThrowsExactly(() => sut.GetPasswordVerification(ExpectedCustomerId.ToString(), ExpectedInvalidGuidString)); Assert.AreEqual(ErrorType.AppointmentIdNotValid, exceptionAppointmentId.ErrorCode); } diff --git a/src/Dataport.Terminfinder.WebAPI.Tests/Controllers/ParticipantControllerTests.cs b/src/Dataport.Terminfinder.WebAPI.Tests/Controllers/ParticipantControllerTests.cs index abbb405..3580ec4 100644 --- a/src/Dataport.Terminfinder.WebAPI.Tests/Controllers/ParticipantControllerTests.cs +++ b/src/Dataport.Terminfinder.WebAPI.Tests/Controllers/ParticipantControllerTests.cs @@ -51,7 +51,7 @@ public void DeleteParticipants_Participants_NoInput() var sut = CreateSut(mockBusinessLayer.Object); // Act - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Delete(ExpectedCustomerId.ToString(), ExpectedAppointmentId.ToString(), expectedParticipantId.ToString())); Assert.AreEqual(ErrorType.NoInput, exception.ErrorCode); @@ -77,7 +77,7 @@ public void DeleteParticipants_Participants_NotFound() var sut = CreateSut(mockBusinessLayer.Object); // Act - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Delete(ExpectedCustomerId.ToString(), ExpectedAppointmentId.ToString(), ExpectedParticipantId.ToString())); Assert.AreEqual(ErrorType.ParticipantNotFound, exception.ErrorCode); @@ -102,7 +102,7 @@ public void DeleteParticipants_AppointmentIsPaused_NotFound() var sut = CreateSut(mockBusinessLayer.Object); // Act - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Delete(ExpectedCustomerId.ToString(), ExpectedAppointmentId.ToString(), ExpectedParticipantId.ToString())); Assert.AreEqual(ErrorType.AppointmentNotFound, exception.ErrorCode); @@ -128,7 +128,7 @@ public void DeleteParticipants_AppointmentIsPasswordProtectedNoPasswordSubmitted var sut = CreateSut(mockBusinessLayer.Object); // Act - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Delete(ExpectedCustomerId.ToString(), ExpectedAppointmentId.ToString(), ExpectedParticipantId.ToString())); Assert.AreEqual(ErrorType.PasswordRequired, exception.ErrorCode); @@ -140,13 +140,13 @@ public void DeleteParticipants_GuidsAreInvalid_ThrowsException() var mockBusinessLayer = new Mock(); var sut = CreateSut(mockBusinessLayer.Object); - var exceptionCustomerId = Assert.ThrowsException(() => + var exceptionCustomerId = Assert.ThrowsExactly(() => sut.Delete(ExpectedInvalidGuidString, ExpectedAppointmentId.ToString(), ExpectedParticipantId.ToString())); Assert.AreEqual(ErrorType.CustomerIdNotValid, exceptionCustomerId.ErrorCode); - var exceptionAppointmentId = Assert.ThrowsException(() => + var exceptionAppointmentId = Assert.ThrowsExactly(() => sut.Delete(ExpectedCustomerId.ToString(), ExpectedInvalidGuidString, ExpectedParticipantId.ToString())); Assert.AreEqual(ErrorType.AppointmentIdNotValid, exceptionAppointmentId.ErrorCode); - var exceptionParticipantId = Assert.ThrowsException(() => + var exceptionParticipantId = Assert.ThrowsExactly(() => sut.Delete(ExpectedCustomerId.ToString(), ExpectedAppointmentId.ToString(), ExpectedInvalidGuidString)); Assert.AreEqual(ErrorType.ParticipantIdNotValid, exceptionParticipantId.ErrorCode); } @@ -167,7 +167,7 @@ public void DeleteParticipants_ParticipantsAreInvalid_ThrowsException() var sut = CreateSut(mockBusinessLayer.Object); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Delete(ExpectedCustomerId.ToString(), ExpectedAppointmentId.ToString(), ExpectedParticipantId.ToString())); Assert.AreEqual(ErrorType.ParticipantNotValid, exception.ErrorCode); diff --git a/src/Dataport.Terminfinder.WebAPI.Tests/Controllers/SuggestedDateControllerTests.cs b/src/Dataport.Terminfinder.WebAPI.Tests/Controllers/SuggestedDateControllerTests.cs index 34910cf..e53b097 100644 --- a/src/Dataport.Terminfinder.WebAPI.Tests/Controllers/SuggestedDateControllerTests.cs +++ b/src/Dataport.Terminfinder.WebAPI.Tests/Controllers/SuggestedDateControllerTests.cs @@ -56,7 +56,7 @@ public void DeleteSuggestedDates_SuggestedDates_NoInput() var sut = CreateSut(mockBusinessLayer.Object); // Act - var exception = Assert.ThrowsException(() => sut.Delete(ExpectedCustomerId.ToString(), + var exception = Assert.ThrowsExactly(() => sut.Delete(ExpectedCustomerId.ToString(), ExpectedAppointmentId.ToString(), expectedSuggestedDateId.ToString())); Assert.AreEqual(ErrorType.NoInput, exception.ErrorCode); } @@ -76,7 +76,7 @@ public void DeleteSuggestedDates_SuggestedDates_NotFound() var sut = CreateSut(mockBusinessLayer.Object); // Act - var exception = Assert.ThrowsException(() => sut.Delete(ExpectedCustomerId.ToString(), + var exception = Assert.ThrowsExactly(() => sut.Delete(ExpectedCustomerId.ToString(), ExpectedAppointmentId.ToString(), ExpectedSuggestedDateId.ToString())); Assert.AreEqual(ErrorType.SuggestedDateNotFound, exception.ErrorCode); } @@ -98,7 +98,7 @@ public void DeleteSuggestedDates_AppointmentIsPasswordProtectedNoPasswordSubmitt var sut = CreateSut(mockBusinessLayer.Object); // Act - var exception = Assert.ThrowsException(() => sut.Delete(ExpectedCustomerId.ToString(), + var exception = Assert.ThrowsExactly(() => sut.Delete(ExpectedCustomerId.ToString(), ExpectedAppointmentId.ToString(), ExpectedSuggestedDateId.ToString())); Assert.AreEqual(ErrorType.PasswordRequired, exception.ErrorCode); } @@ -110,13 +110,13 @@ public void DeleteSuggestedDates_GuidsAreInvalid_ThrowsException() var sut = CreateSut(); - var exceptionCustomerId = Assert.ThrowsException(() => + var exceptionCustomerId = Assert.ThrowsExactly(() => sut.Delete(invalidGuidString, ExpectedAppointmentId.ToString(), ExpectedSuggestedDateId.ToString())); Assert.AreEqual(ErrorType.CustomerIdNotValid, exceptionCustomerId.ErrorCode); - var exceptionAppointmentId = Assert.ThrowsException(() => + var exceptionAppointmentId = Assert.ThrowsExactly(() => sut.Delete(ExpectedCustomerId.ToString(), invalidGuidString, ExpectedSuggestedDateId.ToString())); Assert.AreEqual(ErrorType.AppointmentIdNotValid, exceptionAppointmentId.ErrorCode); - var exceptionSuggestedDateId = Assert.ThrowsException(() => + var exceptionSuggestedDateId = Assert.ThrowsExactly(() => sut.Delete(ExpectedCustomerId.ToString(), ExpectedAppointmentId.ToString(), invalidGuidString)); Assert.AreEqual(ErrorType.SuggestedDateIdNotValid, exceptionSuggestedDateId.ErrorCode); } diff --git a/src/Dataport.Terminfinder.WebAPI.Tests/Controllers/VotingControllerTests.cs b/src/Dataport.Terminfinder.WebAPI.Tests/Controllers/VotingControllerTests.cs index 3522417..8f01723 100644 --- a/src/Dataport.Terminfinder.WebAPI.Tests/Controllers/VotingControllerTests.cs +++ b/src/Dataport.Terminfinder.WebAPI.Tests/Controllers/VotingControllerTests.cs @@ -21,7 +21,7 @@ public void Get_AppointmentIsPasswordProtectedAndNoPasswordSubmitted_Unauthorize var sut = CreateSut(mockBusinessLayer.Object); // Act - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Get(ExpectedCustomerId.ToString(), ExpectedAppointmentId.ToString())); Assert.AreEqual(ErrorType.PasswordRequired, exception.ErrorCode); } @@ -31,10 +31,10 @@ public void Get_GuidsAreInvalid_ThrowsException() { var sut = CreateSut(); - var exceptionCustomerId = Assert.ThrowsException(() => + var exceptionCustomerId = Assert.ThrowsExactly(() => sut.Get(ExpectedInvalidGuidString, ExpectedAppointmentId.ToString())); Assert.AreEqual(ErrorType.CustomerIdNotValid, exceptionCustomerId.ErrorCode); - var exceptionAppointmentId = Assert.ThrowsException(() => + var exceptionAppointmentId = Assert.ThrowsExactly(() => sut.Get(ExpectedCustomerId.ToString(), ExpectedInvalidGuidString)); Assert.AreEqual(ErrorType.AppointmentIdNotValid, exceptionAppointmentId.ErrorCode); } @@ -51,7 +51,7 @@ public void Get_ParticipantsIsNull_ThrowsException() var sut = CreateSut(mockBusinessLayer.Object); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Get(ExpectedCustomerId.ToString(), ExpectedAppointmentId.ToString())); Assert.AreEqual(ErrorType.AppointmentNotFound, exception.ErrorCode); } @@ -72,7 +72,7 @@ public void Put_AppointmentIsPasswordProtectedAndNoPasswordSubmitted_Unauthorize var sut = CreateSut(mockBusinessLayer.Object); // Act - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Put([null], ExpectedCustomerId.ToString(), ExpectedAppointmentId.ToString())); Assert.AreEqual(ErrorType.PasswordRequired, exception.ErrorCode); } @@ -92,7 +92,7 @@ public void Put_AppointmentStatusIsPaused_NotFound() var sut = CreateSut(mockBusinessLayer.Object); // Act - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Put([null], ExpectedCustomerId.ToString(), ExpectedAppointmentId.ToString())); Assert.AreEqual(ErrorType.AppointmentNotFound, exception.ErrorCode); } @@ -158,7 +158,7 @@ public void Put_ParticipantsIsNull_ThrowsException() { var sut = CreateSut(); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Put(null, ExpectedCustomerId.ToString(), ExpectedAppointmentId.ToString())); Assert.AreEqual(ErrorType.NoInput, exception.ErrorCode); } @@ -170,10 +170,10 @@ public void Put_GuidsAreInvalid_ThrowsException() var sut = CreateSut(); - var exceptionCustomerId = Assert.ThrowsException(() => + var exceptionCustomerId = Assert.ThrowsExactly(() => sut.Put(participants, ExpectedInvalidGuidString, ExpectedAppointmentId.ToString())); Assert.AreEqual(ErrorType.CustomerIdNotValid, exceptionCustomerId.ErrorCode); - var exceptionAppointmentId = Assert.ThrowsException(() => + var exceptionAppointmentId = Assert.ThrowsExactly(() => sut.Put(participants, ExpectedCustomerId.ToString(), ExpectedInvalidGuidString)); Assert.AreEqual(ErrorType.AppointmentIdNotValid, exceptionAppointmentId.ErrorCode); } @@ -190,7 +190,7 @@ public void Put_ParticipantsAreInvalid_ThrowsException() mockBusinessLayer.Setup(x => x.ExistsAppointmentIsStarted(It.IsAny(), It.IsAny())).Returns(true); var sut = CreateSut(mockBusinessLayer.Object); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Put(participants, ExpectedCustomerId.ToString(), ExpectedAppointmentId.ToString())); Assert.AreEqual(ErrorType.ParticipantNotValid, exception.ErrorCode); } @@ -229,7 +229,7 @@ public void Put_ModelIsInvalid_ThrowsException() }); var sut = CreateSut(mockBusinessLayer.Object, objectModelValidator.Object); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Put(participants, ExpectedCustomerId.ToString(), ExpectedAppointmentId.ToString())); Assert.AreEqual(ErrorType.AppointmentNotValid, exception.ErrorCode); } @@ -261,7 +261,7 @@ public void Put_ParticipantCountExceedsLimit_ThrowsException() var sut = CreateSut(mockBusinessLayer.Object); - var exception = Assert.ThrowsException(() => + var exception = Assert.ThrowsExactly(() => sut.Put(participants, ExpectedCustomerId.ToString(), ExpectedAppointmentId.ToString())); Assert.AreEqual(ErrorType.MaximumElementsOfParticipantsAreExceeded, exception.ErrorCode); } diff --git a/src/Dataport.Terminfinder.WebAPI.Tests/Dataport.Terminfinder.WebAPI.Tests.csproj b/src/Dataport.Terminfinder.WebAPI.Tests/Dataport.Terminfinder.WebAPI.Tests.csproj index 9c6175d..1b3017c 100644 --- a/src/Dataport.Terminfinder.WebAPI.Tests/Dataport.Terminfinder.WebAPI.Tests.csproj +++ b/src/Dataport.Terminfinder.WebAPI.Tests/Dataport.Terminfinder.WebAPI.Tests.csproj @@ -1,12 +1,12 @@  - net8.0 + net10.0 enable false Portable {F67BC847-C0FB-4642-8086-CB7FDC53DEF8} - 12 + default @@ -18,20 +18,20 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + - - + + diff --git a/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/AdminControllerIntegrationTests.cs b/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/AdminControllerIntegrationTests.cs index 2172f7c..5d85426 100644 --- a/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/AdminControllerIntegrationTests.cs +++ b/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/AdminControllerIntegrationTests.cs @@ -8,14 +8,36 @@ namespace Dataport.Terminfinder.WebAPI.Tests.IntegrationTests; public class AdminControllerIntegrationTests : BaseIntegrationTests { private TestServer _testServer; + private IHost _host; private static readonly Guid ExpectedCustomerId = new("E1E81104-3944-4588-A48E-B64BDE473E1A"); [TestInitialize] - public void Initialize() + public async Task Initialize() { var config = GetConfigurationBuilder(); - var builder = new WebHostBuilder().UseStartup().UseConfiguration(config); - _testServer = new TestServer(builder); + _host = new HostBuilder() + .ConfigureWebHost(builder => + { + builder + .UseTestServer() + .UseStartup() + .UseConfiguration(config); + } + ) + .Build(); + await _host.StartAsync(); + _testServer = _host.GetTestServer(); + } + + [TestCleanup] + public async Task Cleanup() + { + if (_testServer != null) + { + await _host.StopAsync(); + _testServer.Dispose(); + } + _host?.Dispose(); } [TestMethod] diff --git a/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/AppControllerIntegrationTests.cs b/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/AppControllerIntegrationTests.cs index 483e671..ab68fa3 100644 --- a/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/AppControllerIntegrationTests.cs +++ b/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/AppControllerIntegrationTests.cs @@ -5,13 +5,35 @@ namespace Dataport.Terminfinder.WebAPI.Tests.IntegrationTests; public class AppControllerIntegrationTests : BaseIntegrationTests { private TestServer _testServer; + private IHost _host; [TestInitialize] - public void Initialize() + public async Task Initialize() { var config = GetConfigurationBuilder(); - var builder = new WebHostBuilder().UseStartup().UseConfiguration(config); - _testServer = new TestServer(builder); + _host = new HostBuilder() + .ConfigureWebHost(builder => + { + builder + .UseTestServer() + .UseStartup() + .UseConfiguration(config); + } + ) + .Build(); + await _host.StartAsync(); + _testServer = _host.GetTestServer(); + } + + [TestCleanup] + public async Task Cleanup() + { + if (_testServer != null) + { + await _host.StopAsync(); + _testServer.Dispose(); + } + _host?.Dispose(); } [TestMethod] @@ -39,4 +61,4 @@ public async Task GetAppInfo_Okay() Assert.AreEqual(expectedAppInfo.BuildDate, dto.BuildDate); Assert.AreEqual(expectedAppInfo.VersionNumber, dto.VersionNumber); } -} +} \ No newline at end of file diff --git a/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/AppointmentControllerIntegrationTests.cs b/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/AppointmentControllerIntegrationTests.cs index bec2f4a..fc4f228 100644 --- a/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/AppointmentControllerIntegrationTests.cs +++ b/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/AppointmentControllerIntegrationTests.cs @@ -9,14 +9,36 @@ namespace Dataport.Terminfinder.WebAPI.Tests.IntegrationTests; public class AppointmentControllerIntegrationTests : BaseIntegrationTests { private TestServer _testServer; + private IHost _host; private static readonly Guid ExpectedCustomerId = new("E1E81104-3944-4588-A48E-B64BDE473E1A"); [TestInitialize] - public void Initialize() + public async Task Initialize() { var config = GetConfigurationBuilder(); - var builder = new WebHostBuilder().UseStartup().UseConfiguration(config); - _testServer = new TestServer(builder); + _host = new HostBuilder() + .ConfigureWebHost(builder => + { + builder + .UseTestServer() + .UseStartup() + .UseConfiguration(config); + } + ) + .Build(); + await _host.StartAsync(); + _testServer = _host.GetTestServer(); + } + + [TestCleanup] + public async Task Cleanup() + { + if (_testServer != null) + { + await _host.StopAsync(); + _testServer.Dispose(); + } + _host?.Dispose(); } [TestMethod] @@ -39,7 +61,6 @@ public async Task AddAppointment() Assert.AreEqual(HttpStatusCode.Created, response.StatusCode); Assert.IsNotNull(dto); Assert.IsInstanceOfType(dto, typeof(Appointment)); - Assert.IsNotNull(dto.AppointmentId); //--- get the appointment var appointmentId= dto.AppointmentId; @@ -135,7 +156,6 @@ public async Task UpdateAppointment() Assert.AreEqual(HttpStatusCode.Created, response.StatusCode); Assert.IsNotNull(dto); Assert.IsInstanceOfType(dto, typeof(Appointment)); - Assert.IsNotNull(dto.AppointmentId); var appointmentId = dto.AppointmentId; var adminId = dto.AdminId; @@ -189,7 +209,6 @@ public async Task UpdateAppointment() Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); Assert.IsNotNull(dto3); Assert.IsInstanceOfType(dto3, typeof(Appointment)); - Assert.IsNotNull(dto3.AppointmentId); Assert.AreEqual(dto.AppointmentId, dto3.AppointmentId); Assert.AreEqual(dto.AdminId, dto3.AdminId); @@ -411,7 +430,6 @@ public async Task AddAppointment_WithPassword_Unauthorized() Assert.AreEqual(HttpStatusCode.Created, response.StatusCode); Assert.IsNotNull(dto); Assert.IsInstanceOfType(dto, typeof(Appointment)); - Assert.IsNotNull(dto.AppointmentId); //--- get the appointment var appointmentId = dto.AppointmentId; @@ -486,8 +504,6 @@ public async Task AddAppointment_WithPassword() Assert.AreEqual(HttpStatusCode.Created, response.StatusCode); Assert.IsNotNull(dto); Assert.IsInstanceOfType(dto, typeof(Appointment)); - Assert.IsNotNull(dto.AppointmentId); - Assert.IsNotNull(dto.AdminId); //--- get the appointment var appointmentId = dto.AppointmentId; @@ -544,8 +560,6 @@ public async Task GetProtection_appointmentExistsAndAppointmentIsProtectedByPass Assert.AreEqual(HttpStatusCode.Created, response.StatusCode); Assert.IsNotNull(dto); Assert.IsInstanceOfType(dto, typeof(Appointment)); - Assert.IsNotNull(dto.AppointmentId); - Assert.IsNotNull(dto.AdminId); var appointmentId = dto.AppointmentId; @@ -585,8 +599,6 @@ public async Task GetPasswordVerification() Assert.AreEqual(HttpStatusCode.Created, response.StatusCode); Assert.IsNotNull(dto); Assert.IsInstanceOfType(dto, typeof(Appointment)); - Assert.IsNotNull(dto.AppointmentId); - Assert.IsNotNull(dto.AdminId); var appointmentId = dto.AppointmentId; var adminId = dto.AdminId; diff --git a/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/BaseIntegrationTests.cs b/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/BaseIntegrationTests.cs index 34bf995..30dc7d3 100644 --- a/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/BaseIntegrationTests.cs +++ b/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/BaseIntegrationTests.cs @@ -87,7 +87,6 @@ protected static async Task CreateTestAppointmentInDatabase( Assert.AreEqual(HttpStatusCode.Created, response.StatusCode); Assert.IsNotNull(dto); Assert.IsInstanceOfType(dto, typeof(Appointment)); - Assert.IsNotNull(dto.AppointmentId); return dto; } diff --git a/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/CustomerControllerIntegrationTests.cs b/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/CustomerControllerIntegrationTests.cs index 90db39e..21352f1 100644 --- a/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/CustomerControllerIntegrationTests.cs +++ b/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/CustomerControllerIntegrationTests.cs @@ -5,14 +5,36 @@ public class CustomerControllerIntegrationTests : BaseIntegrationTests { private TestServer _testServer; + private IHost _host; private static readonly Guid ExpectedCustomerId = new("E1E81104-3944-4588-A48E-B64BDE473E1A"); [TestInitialize] - public void Initialize() + public async Task Initialize() { var config = GetConfigurationBuilder(); - var builder = new WebHostBuilder().UseStartup().UseConfiguration(config); - _testServer = new TestServer(builder); + _host = new HostBuilder() + .ConfigureWebHost(builder => + { + builder + .UseTestServer() + .UseStartup() + .UseConfiguration(config); + } + ) + .Build(); + await _host.StartAsync(); + _testServer = _host.GetTestServer(); + } + + [TestCleanup] + public async Task Cleanup() + { + if (_testServer != null) + { + await _host.StopAsync(); + _testServer.Dispose(); + } + _host?.Dispose(); } [TestMethod] diff --git a/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/ErrorHandling/ErrorHandlingMiddlewareTests.cs b/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/ErrorHandling/ErrorHandlingMiddlewareTests.cs index 8188baf..5555142 100644 --- a/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/ErrorHandling/ErrorHandlingMiddlewareTests.cs +++ b/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/ErrorHandling/ErrorHandlingMiddlewareTests.cs @@ -7,31 +7,45 @@ namespace Dataport.Terminfinder.WebAPI.Tests.IntegrationTests.ErrorHandling; public class ErrorHandlingMiddlewareTests : BaseIntegrationTests { private TestServer _server; + private IHost _host; private HttpClient _client; [TestInitialize] - public void Setup() + public async Task Setup() { var mockLocalizer = new Mock>(); var config = GetConfigurationBuilder(); - var builder = new WebHostBuilder() - .UseStartup() - .UseConfiguration(config) - .ConfigureServices(services => - { - services.AddSingleton(mockLocalizer.Object); - }) - .Configure(app => - { - app.UseMiddleware(); - app.Map("/conflict", cfg => + _host = new HostBuilder() + .ConfigureWebHost(builder => { - cfg.Run(_ => throw new ConflictException(ErrorType.GeneralError)); - }); - }); + builder + .UseTestServer() + .UseStartup() + .UseConfiguration(config) + .ConfigureServices(services => + { + services.AddSingleton(mockLocalizer.Object); + } + ) + .Configure(app => + { + app.UseMiddleware(); + app.Map( + "/conflict", + cfg => + { + cfg.Run(_ => throw new ConflictException(ErrorType.GeneralError)); + } + ); + } + ); + } + ) + .Build(); - _server = new TestServer(builder); + await _host.StartAsync(); + _server = _host.GetTestServer(); _client = _server.CreateClient(); } @@ -44,9 +58,15 @@ public async Task Conflict_ReturnsExpectedException() } [TestCleanup] - public void Cleanup() + public async Task Cleanup() { + if (_server != null) + { + await _host.StopAsync(); + _server.Dispose(); + } + + _host?.Dispose(); _client.Dispose(); - _server.Dispose(); } } \ No newline at end of file diff --git a/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/ParticipantControllerIntegrationTests.cs b/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/ParticipantControllerIntegrationTests.cs index cb38f23..5abe61d 100644 --- a/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/ParticipantControllerIntegrationTests.cs +++ b/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/ParticipantControllerIntegrationTests.cs @@ -9,14 +9,36 @@ namespace Dataport.Terminfinder.WebAPI.Tests.IntegrationTests; public class ParticipantControllerIntegrationTests : BaseIntegrationTests { private TestServer _testServer; + private IHost _host; private static readonly Guid ExpectedCustomerId = new("E1E81104-3944-4588-A48E-B64BDE473E1A"); [TestInitialize] - public void Initialize() + public async Task Initialize() { var config = GetConfigurationBuilder(); - var builder = new WebHostBuilder().UseStartup().UseConfiguration(config); - _testServer = new TestServer(builder); + _host = new HostBuilder() + .ConfigureWebHost(builder => + { + builder + .UseTestServer() + .UseStartup() + .UseConfiguration(config); + } + ) + .Build(); + await _host.StartAsync(); + _testServer = _host.GetTestServer(); + } + + [TestCleanup] + public async Task Cleanup() + { + if (_testServer != null) + { + await _host.StopAsync(); + _testServer.Dispose(); + } + _host?.Dispose(); } [TestMethod] diff --git a/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/SuggestedDateControllerIntegrationTests.cs b/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/SuggestedDateControllerIntegrationTests.cs index 254de1b..e3bbdc8 100644 --- a/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/SuggestedDateControllerIntegrationTests.cs +++ b/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/SuggestedDateControllerIntegrationTests.cs @@ -5,14 +5,36 @@ public class SuggestedDateControllerIntegrationTests : BaseIntegrationTests { private TestServer _testServer; + private IHost _host; private static readonly Guid ExpectedCustomerId = new("E1E81104-3944-4588-A48E-B64BDE473E1A"); [TestInitialize] - public void Initialize() + public async Task Initialize() { var config = GetConfigurationBuilder(); - var builder = new WebHostBuilder().UseStartup().UseConfiguration(config); - _testServer = new TestServer(builder); + _host = new HostBuilder() + .ConfigureWebHost(builder => + { + builder + .UseTestServer() + .UseStartup() + .UseConfiguration(config); + } + ) + .Build(); + await _host.StartAsync(); + _testServer = _host.GetTestServer(); + } + + [TestCleanup] + public async Task Cleanup() + { + if (_testServer != null) + { + await _host.StopAsync(); + _testServer.Dispose(); + } + _host?.Dispose(); } [TestMethod] @@ -111,6 +133,6 @@ public async Task AddSuggestedDateDescription_GetSuggestedDate_ValueMatches() // assert var resultDescription = result.SuggestedDates.First(s => s.Description == expectedDescription).Description; Assert.IsNotNull(resultDescription); - Assert.AreEqual(expectedDescription, expectedDescription); + Assert.AreEqual(expectedDescription, resultDescription); } } diff --git a/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/VotingControllerIntegrationTests.cs b/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/VotingControllerIntegrationTests.cs index 0f9d9fe..c5b85e6 100644 --- a/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/VotingControllerIntegrationTests.cs +++ b/src/Dataport.Terminfinder.WebAPI.Tests/IntegrationTests/VotingControllerIntegrationTests.cs @@ -8,14 +8,36 @@ namespace Dataport.Terminfinder.WebAPI.Tests.IntegrationTests; public class VotingControllerIntegrationTests : BaseIntegrationTests { private TestServer _testServer; + private IHost _host; private static readonly Guid ExpectedCustomerId = new("E1E81104-3944-4588-A48E-B64BDE473E1A"); [TestInitialize] - public void Initialize() + public async Task Initialize() { var config = GetConfigurationBuilder(); - var builder = new WebHostBuilder().UseStartup().UseConfiguration(config); - _testServer = new TestServer(builder); + _host = new HostBuilder() + .ConfigureWebHost(builder => + { + builder + .UseTestServer() + .UseStartup() + .UseConfiguration(config); + } + ) + .Build(); + await _host.StartAsync(); + _testServer = _host.GetTestServer(); + } + + [TestCleanup] + public async Task Cleanup() + { + if (_testServer != null) + { + await _host.StopAsync(); + _testServer.Dispose(); + } + _host?.Dispose(); } [TestMethod] @@ -48,7 +70,6 @@ public async Task AddAndUpdateParticipant_And_Votings() Assert.AreEqual(HttpStatusCode.Created, response.StatusCode); Assert.IsNotNull(dto); Assert.IsInstanceOfType(dto, typeof(Appointment)); - Assert.IsNotNull(dto.AppointmentId); //--- get the appointment var appointmentId = dto.AppointmentId; @@ -194,7 +215,6 @@ public async Task AppointmentIsPasswordProtectedAndNoPasswordSubmitted_Unauthori Assert.AreEqual(HttpStatusCode.Created, response.StatusCode); Assert.IsNotNull(dto); Assert.IsInstanceOfType(dto, typeof(Appointment)); - Assert.IsNotNull(dto.AppointmentId); // Act Get voting response = await client.GetAsync($"votings/{ExpectedCustomerId}/{dto.AppointmentId}"); @@ -226,7 +246,6 @@ public async Task Put_AppointmentIsPasswordProtectedAndNoPasswordSubmitted_Unaut Assert.AreEqual(HttpStatusCode.Created, response.StatusCode); Assert.IsNotNull(dto); Assert.IsInstanceOfType(dto, typeof(Appointment)); - Assert.IsNotNull(dto.AppointmentId); var participants = appointment.Participants ?? new List(); participants.Add(new Participant @@ -269,7 +288,6 @@ public async Task Put_AppointmentStatusIsPaused_NotFound() Assert.AreEqual(HttpStatusCode.Created, response.StatusCode); Assert.IsNotNull(dto); Assert.IsInstanceOfType(dto, typeof(Appointment)); - Assert.IsNotNull(dto.AppointmentId); var participants = appointment.Participants ?? new List(); participants.Add(new Participant diff --git a/src/Dataport.Terminfinder.WebAPI.Tests/RequestContext/BasicAuthenticationEncoderTests.cs b/src/Dataport.Terminfinder.WebAPI.Tests/RequestContext/BasicAuthenticationEncoderTests.cs index ac1f1df..5cf746c 100644 --- a/src/Dataport.Terminfinder.WebAPI.Tests/RequestContext/BasicAuthenticationEncoderTests.cs +++ b/src/Dataport.Terminfinder.WebAPI.Tests/RequestContext/BasicAuthenticationEncoderTests.cs @@ -40,28 +40,28 @@ public void Decode_validBasicAuthenticationPayloadValuePasswordIsEmpty_resultCon [TestMethod] public void Decode_invalidBasicAuthenticationPayloadValueNoBasicAtBeginning_throwException() { - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => BasicAuthenticationValueEncoder.Decode(" dXNlcm5hbWU6UDQkJHcwcmQ=")); } [TestMethod] public void Decode_invalidBasicAuthenticationPayloadValueNoColonInEncodedBasicAuthValue_throwException() { - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => BasicAuthenticationValueEncoder.Decode("Basic dXNlcm5hbWVQNCQkdzByZA==")); } [TestMethod] public void Decode_invalidBasicAuthenticationPayloadValueInvalidEncodedBasicAuthValue_throwException() { - Assert.ThrowsException(() => + Assert.ThrowsExactly(() => BasicAuthenticationValueEncoder.Decode("Basic aaaaaaa")); } [TestMethod] public void Decode_null_throwException() { - Assert.ThrowsException(() => BasicAuthenticationValueEncoder.Decode(null)); + Assert.ThrowsExactly(() => BasicAuthenticationValueEncoder.Decode(null)); } [TestMethod] diff --git a/src/Dataport.Terminfinder.WebAPI/Dataport.Terminfinder.WebAPI.csproj b/src/Dataport.Terminfinder.WebAPI/Dataport.Terminfinder.WebAPI.csproj index 0c1bbd2..7e31996 100644 --- a/src/Dataport.Terminfinder.WebAPI/Dataport.Terminfinder.WebAPI.csproj +++ b/src/Dataport.Terminfinder.WebAPI/Dataport.Terminfinder.WebAPI.csproj @@ -1,7 +1,7 @@  - net8.0 + net10.0 enable Dataport.Terminfinder.WebAPI Dataport.Terminfinder.WebAPI @@ -10,7 +10,7 @@ {1B884327-0051-4502-A301-D0EB71FC2EEB} Exe true - 12 + default @@ -35,28 +35,27 @@ - - - + + + - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - + + + + + + + + + + diff --git a/src/Dataport.Terminfinder.WebAPI/Startup.cs b/src/Dataport.Terminfinder.WebAPI/Startup.cs index fd2a44a..e829997 100644 --- a/src/Dataport.Terminfinder.WebAPI/Startup.cs +++ b/src/Dataport.Terminfinder.WebAPI/Startup.cs @@ -15,7 +15,7 @@ using Microsoft.Extensions.Diagnostics.HealthChecks; using Microsoft.Extensions.Options; using Microsoft.Net.Http.Headers; -using Microsoft.OpenApi.Models; +using Microsoft.OpenApi; using Newtonsoft.Json.Converters; using System.Diagnostics.CodeAnalysis; using System.Globalization; @@ -34,7 +34,7 @@ public class Startup private static readonly string ContactUrl = "https://www.dataport.de"; private static readonly string ContactEmail = "dataportdabstimmbox@dataport.de"; private static readonly string ContactName = "dataport"; - private static readonly string LicenseText = "EUPL-1.2 Copyright © 2022-2023 Dataport AöR"; + private static readonly string LicenseText = "EUPL-1.2 Copyright © 2022-2026 Dataport AöR"; private static readonly string LicenseUri = "https://opensource.org/licenses/EUPL-1.2"; private static readonly string OpenApiTitle = "Terminfinder API"; diff --git a/src/Dataport.Terminfinder.WebAPI/Swagger/BasicAuthOperationFilter.cs b/src/Dataport.Terminfinder.WebAPI/Swagger/BasicAuthOperationFilter.cs index bc5e9fa..f2f684f 100644 --- a/src/Dataport.Terminfinder.WebAPI/Swagger/BasicAuthOperationFilter.cs +++ b/src/Dataport.Terminfinder.WebAPI/Swagger/BasicAuthOperationFilter.cs @@ -1,4 +1,4 @@ -using Microsoft.OpenApi.Models; +using Microsoft.OpenApi; using Swashbuckle.AspNetCore.Filters; using Swashbuckle.AspNetCore.SwaggerGen; using System.Diagnostics.CodeAnalysis; diff --git a/src/Dataport.Terminfinder.WebAPI/Swagger/EnumTypesSchemaFilter.cs b/src/Dataport.Terminfinder.WebAPI/Swagger/EnumTypesSchemaFilter.cs index f1016f8..144aad3 100644 --- a/src/Dataport.Terminfinder.WebAPI/Swagger/EnumTypesSchemaFilter.cs +++ b/src/Dataport.Terminfinder.WebAPI/Swagger/EnumTypesSchemaFilter.cs @@ -1,5 +1,4 @@ -using Microsoft.OpenApi.Any; -using Microsoft.OpenApi.Models; +using Microsoft.OpenApi; using Swashbuckle.AspNetCore.SwaggerGen; using System.Diagnostics.CodeAnalysis; using System.Text; @@ -7,7 +6,6 @@ namespace Dataport.Terminfinder.WebAPI.Swagger; - // s. https://www.codeproject.com/Articles/5300099/Description-of-the-Enumeration-Members-in-Swashbuc /// /// Swagger documentation for EnumTypes /// @@ -29,21 +27,21 @@ public EnumTypesSchemaFilter(string xmlPath) } /// - public void Apply(OpenApiSchema schema, SchemaFilterContext context) + public void Apply(IOpenApiSchema schema, SchemaFilterContext context) { if (_xmlComments == null) { return; } - if (schema.Enum.Count > 0 && context.Type is { IsEnum: true }) + if (schema is OpenApiSchema { Enum.Count: > 0 } openApiSchema && context.Type is { IsEnum: true }) { - var sb = new StringBuilder(schema.Description); + var sb = new StringBuilder(openApiSchema.Description); sb.Append("

Members:

    "); var fullTypeName = context.Type.FullName; - foreach (var enumMemberName in schema.Enum.OfType().Select(v => v.Value)) + foreach (var enumMemberName in openApiSchema.Enum.Select(v => v.AsValue())) { var fullEnumMemberName = $"F:{fullTypeName}.{enumMemberName}"; @@ -69,7 +67,7 @@ public void Apply(OpenApiSchema schema, SchemaFilterContext context) sb.Append("
"); - schema.Description = sb.ToString(); + openApiSchema.Description = sb.ToString(); } } } \ No newline at end of file