From df6763b99bb41498012512a461fa819db8eee9a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Thu, 4 Jul 2024 18:22:26 +0200 Subject: [PATCH] Solution restructured to use multiple test projects --- .gitignore | 1 + .gitlab-ci.yml | 89 +++-- AMWD.Common/InternalsVisibleTo.cs | 3 - .../Tar/Interfaces/IArchiveDataWriter.cs | 26 -- .../Packing/Tar/Interfaces/ITarHeader.cs | 125 ------- AMWD.Common/Packing/Tar/TarReader.cs | 205 ----------- AMWD.Common/Packing/Tar/TarWriter.cs | 113 ------ AMWD.Common/Packing/Tar/Utils/DataWriter.cs | 45 --- AMWD.Common/Packing/Tar/Utils/EntryType.cs | 73 ---- .../Packing/Tar/Utils/LegacyTarWriter.cs | 329 ------------------ AMWD.Common/Packing/Tar/Utils/TarException.cs | 52 --- AMWD.Common/Packing/Tar/Utils/TarHeader.cs | 179 ---------- AMWD.Common/Packing/Tar/Utils/UsTarHeader.cs | 127 ------- CHANGELOG.md | 3 +- Common.sln | 53 +-- Directory.Build.props | 32 +- README.md | 2 +- .../Common/Packing/Tar/TarReaderTests.cs | 12 - UnitTests/UnitTests.csproj | 29 -- .../AMWD.Common.AspNetCore.csproj | 14 +- .../BasicAuthenticationAttribute.cs | 0 .../Attributes/GoogleReCaptchaAttribute.cs | 0 .../Attributes/IPAllowListAttribute.cs | 0 .../Attributes/IPBlockListAttribute.cs | 0 .../ApplicationBuilderExtensions.cs | 0 .../Extensions/HtmlExtensions.cs | 0 .../Extensions/HttpContextExtensions.cs | 0 .../Extensions/LoggerExtensions.cs | 0 .../ModelStateDictionaryExtensions.cs | 0 .../Extensions/ServiceCollectionExtensions.cs | 0 .../Extensions/SessionExtensions.cs | 0 .../InvariantFloatingPointModelBinder.cs | 0 ...variantFloatingPointModelBinderProvider.cs | 0 .../BasicAuthenticationHandler.cs | 0 .../BasicAuthenticationMiddleware.cs | 0 .../IBasicAuthenticationValidator.cs | 0 .../PathProtection/ProtectedPathExtensions.cs | 0 .../PathProtection/ProtectedPathMiddleware.cs | 0 .../PathProtection/ProtectedPathOptions.cs | 0 .../TagHelpers/ConditionClassTagHelper.cs | 0 .../TagHelpers/EmailTagHelper.cs | 0 .../TagHelpers/IntegrityHashTagHelper.cs | 0 .../TagHelpers/NumberInputTagHelper.cs | 0 .../Utilities/HtmlHelper.cs | 0 .../Utilities/PasswordHelper.cs | 0 .../AMWD.Common.EntityFrameworkCore.csproj | 14 +- .../Attributes/DatabaseIndexAttribute.cs | 0 .../Converters/DateOnlyConverter.cs | 0 .../Converters/NullableDateOnlyConverter.cs | 0 .../Converters/NullableTimeOnlyConverter.cs | 0 .../Converters/TimeOnlyConverter.cs | 0 .../Exceptions/DatabaseProviderException.cs | 0 .../Extensions/DatabaseFacadeExtensions.cs | 0 .../Extensions/DbContextExensions.cs | 0 .../DbContextOptionsBuilderExtensions.cs | 0 .../Extensions/ModelBuilderExtensions.cs | 0 .../ModelConfigurationBuilderExtensions.cs | 0 .../GlobalSuppressions.cs | 0 .../Utilities/DatabaseMigrationOptions.cs | 0 .../Utilities/DatabaseProviderOptions.cs | 0 .../AMWD.Common.MessagePack.csproj | 16 +- .../Formatters/IPAddressArrayFormatter.cs | 0 .../Formatters/IPAddressFormatter.cs | 0 .../Formatters/IPAddressListFormatter.cs | 0 .../Formatters/IPNetworkArrayFormatter.cs | 0 .../Formatters/IPNetworkFormatter.cs | 0 .../Formatters/IPNetworkListFormatter.cs | 0 .../Utilities/NetworkHelper.cs | 0 .../AMWD.Common.Test}/AMWD.Common.Test.csproj | 16 +- .../HttpMessageHandlerMoq.cs | 0 .../AMWD.Common.Test}/SnapshotAssert.cs | 0 .../AMWD.Common.Test}/TcpClientMoq.cs | 0 .../AMWD.Common}/AMWD.Common.csproj | 12 +- .../AMWD.Common}/Cli/Argument.cs | 0 .../AMWD.Common}/Cli/CommandLineParser.cs | 0 .../AMWD.Common}/Cli/EnumerableWalker.cs | 0 .../AMWD.Common}/Cli/Option.cs | 0 .../AMWD.Common}/Comparer/DomainComparer.cs | 0 .../Comparer/IPAddressComparer.cs | 0 .../Comparer/VersionStringComparer.cs | 0 .../Converters/ByteArrayHexConverter.cs | 0 .../Converters/IPAddressConverter.cs | 0 .../Converters/IPNetworkConverter.cs | 0 .../Extensions/CollectionExtensions.cs | 0 .../CryptographyHelperExtensions.cs | 0 .../Extensions/DateTimeExtensions.cs | 0 .../AMWD.Common}/Extensions/EnumExtensions.cs | 0 .../Extensions/ExceptionExtensions.cs | 0 .../Extensions/IPAddressExtensions.cs | 0 .../AMWD.Common}/Extensions/JsonExtensions.cs | 0 .../ReaderWriterLockSlimExtensions.cs | 0 .../Extensions/ReflectionExtensions.cs | 0 .../Extensions/StreamExtensions.cs | 0 .../Extensions/StringExtensions.cs | 39 ++- src/AMWD.Common/InternalsVisibleTo.cs | 4 + .../AMWD.Common}/Logging/FileLogger.cs | 0 .../AMWD.Common}/Logging/NullScope.cs | 0 .../AMWD.Common}/Packing/Ar/ArFileInfo.cs | 0 .../AMWD.Common}/Packing/Ar/ArReader.cs | 2 +- .../AMWD.Common}/Packing/Ar/ArWriter.cs | 6 +- .../AMWD.Common}/Utilities/AsyncQueue.cs | 0 .../Utilities/CryptographyHelper.cs | 0 .../AMWD.Common}/Utilities/DelayedTask.cs | 0 .../AMWD.Common}/Utilities/NetworkHelper.cs | 0 src/Directory.Build.props | 48 +++ .../AMWD.Common.AspNetCore.Tests.csproj | 11 + .../BasicAuthenticationAttributeTest.cs | 6 +- .../Attributes/IPAllowListAttributeTest.cs | 6 +- .../Attributes/IPBlockListAttributeTest.cs | 6 +- .../Extensions/HttpContextExtensionsTest.cs | 6 +- .../ModelStateDictionaryExtensionsTest.cs | 6 +- .../Extensions/SessionExtensionsTest.cs | 6 +- .../BasicAuthenticationMiddlewareTest.cs | 6 +- .../ProtectedPathMiddlewareTest.cs | 6 +- .../Utilities/HtmlHelperTest.cs | 6 +- .../Utilities/PasswordHelperTest.cs | 6 +- .../AMWD.Common.Tests.csproj | 15 + .../Cli/CommandLineParserTest.cs | 5 +- .../Cli/EnumerableWalkerTest.cs | 5 +- .../Comparer/DomainComparerTest.cs | 5 +- .../Comparer/IPAddressComparerTest.cs | 5 +- .../Comparer/VersionStringComparerTest.cs | 5 +- .../Extensions/CollectionExtensionsTest.cs | 5 +- .../CryptographyHelperExtensionsTest.cs | 6 +- .../Extensions/DateTimeExtensionsTest.cs | 8 +- .../Extensions/EnumExtensionsTest.cs | 9 +- .../Extensions/ExceptionExtensionsTest.cs | 6 +- .../Extensions/IPAddressExtensionsTest.cs | 6 +- .../Extensions/JsonExtensionsTest.cs | 10 +- .../ReaderWriterLockSlimExtensionsTest.cs | 6 +- .../Extensions/StreamExtensionsTest.cs | 6 +- .../Extensions/StringExtensionsTest.cs | 6 +- .../Logging/FileLoggerTest.cs | 5 +- .../Packing/Ar/ArReaderTest.cs | 62 ++-- .../Packing/Ar/ArWriterTest.cs | 110 +++--- .../Utilities/AsyncQueueTest.cs | 6 +- .../Utilities/CryptographyHelperTest.cs | 4 +- .../Utilities/DelayedTaskTest.cs | 6 +- .../Utilities/DelayedTaskWithResultTest.cs | 6 +- .../Utils/CryptographyHelperSaltMock.cs | 2 +- .../Utils/CustomMultipleAttribute.cs | 2 +- .../AMWD.Common.Tests}/Utils/JsonTestClass.cs | 2 +- .../Utils/TimeZoneInfoLocalMock.cs | 2 +- test/Directory.Build.props | 25 ++ 144 files changed, 387 insertions(+), 1693 deletions(-) delete mode 100644 AMWD.Common/InternalsVisibleTo.cs delete mode 100644 AMWD.Common/Packing/Tar/Interfaces/IArchiveDataWriter.cs delete mode 100644 AMWD.Common/Packing/Tar/Interfaces/ITarHeader.cs delete mode 100644 AMWD.Common/Packing/Tar/TarReader.cs delete mode 100644 AMWD.Common/Packing/Tar/TarWriter.cs delete mode 100644 AMWD.Common/Packing/Tar/Utils/DataWriter.cs delete mode 100644 AMWD.Common/Packing/Tar/Utils/EntryType.cs delete mode 100644 AMWD.Common/Packing/Tar/Utils/LegacyTarWriter.cs delete mode 100644 AMWD.Common/Packing/Tar/Utils/TarException.cs delete mode 100644 AMWD.Common/Packing/Tar/Utils/TarHeader.cs delete mode 100644 AMWD.Common/Packing/Tar/Utils/UsTarHeader.cs delete mode 100644 UnitTests/Common/Packing/Tar/TarReaderTests.cs delete mode 100644 UnitTests/UnitTests.csproj rename {AMWD.Common.AspNetCore => src/AMWD.Common.AspNetCore}/AMWD.Common.AspNetCore.csproj (57%) rename {AMWD.Common.AspNetCore => src/AMWD.Common.AspNetCore}/Attributes/BasicAuthenticationAttribute.cs (100%) rename {AMWD.Common.AspNetCore => src/AMWD.Common.AspNetCore}/Attributes/GoogleReCaptchaAttribute.cs (100%) rename {AMWD.Common.AspNetCore => src/AMWD.Common.AspNetCore}/Attributes/IPAllowListAttribute.cs (100%) rename {AMWD.Common.AspNetCore => src/AMWD.Common.AspNetCore}/Attributes/IPBlockListAttribute.cs (100%) rename {AMWD.Common.AspNetCore => src/AMWD.Common.AspNetCore}/Extensions/ApplicationBuilderExtensions.cs (100%) rename {AMWD.Common.AspNetCore => src/AMWD.Common.AspNetCore}/Extensions/HtmlExtensions.cs (100%) rename {AMWD.Common.AspNetCore => src/AMWD.Common.AspNetCore}/Extensions/HttpContextExtensions.cs (100%) rename {AMWD.Common.AspNetCore => src/AMWD.Common.AspNetCore}/Extensions/LoggerExtensions.cs (100%) rename {AMWD.Common.AspNetCore => src/AMWD.Common.AspNetCore}/Extensions/ModelStateDictionaryExtensions.cs (100%) rename {AMWD.Common.AspNetCore => src/AMWD.Common.AspNetCore}/Extensions/ServiceCollectionExtensions.cs (100%) rename {AMWD.Common.AspNetCore => src/AMWD.Common.AspNetCore}/Extensions/SessionExtensions.cs (100%) rename {AMWD.Common.AspNetCore => src/AMWD.Common.AspNetCore}/ModelBinders/InvariantFloatingPointModelBinder.cs (100%) rename {AMWD.Common.AspNetCore => src/AMWD.Common.AspNetCore}/ModelBinders/InvariantFloatingPointModelBinderProvider.cs (100%) rename {AMWD.Common.AspNetCore => src/AMWD.Common.AspNetCore}/Security/BasicAuthentication/BasicAuthenticationHandler.cs (100%) rename {AMWD.Common.AspNetCore => src/AMWD.Common.AspNetCore}/Security/BasicAuthentication/BasicAuthenticationMiddleware.cs (100%) rename {AMWD.Common.AspNetCore => src/AMWD.Common.AspNetCore}/Security/BasicAuthentication/IBasicAuthenticationValidator.cs (100%) rename {AMWD.Common.AspNetCore => src/AMWD.Common.AspNetCore}/Security/PathProtection/ProtectedPathExtensions.cs (100%) rename {AMWD.Common.AspNetCore => src/AMWD.Common.AspNetCore}/Security/PathProtection/ProtectedPathMiddleware.cs (100%) rename {AMWD.Common.AspNetCore => src/AMWD.Common.AspNetCore}/Security/PathProtection/ProtectedPathOptions.cs (100%) rename {AMWD.Common.AspNetCore => src/AMWD.Common.AspNetCore}/TagHelpers/ConditionClassTagHelper.cs (100%) rename {AMWD.Common.AspNetCore => src/AMWD.Common.AspNetCore}/TagHelpers/EmailTagHelper.cs (100%) rename {AMWD.Common.AspNetCore => src/AMWD.Common.AspNetCore}/TagHelpers/IntegrityHashTagHelper.cs (100%) rename {AMWD.Common.AspNetCore => src/AMWD.Common.AspNetCore}/TagHelpers/NumberInputTagHelper.cs (100%) rename {AMWD.Common.AspNetCore => src/AMWD.Common.AspNetCore}/Utilities/HtmlHelper.cs (100%) rename {AMWD.Common.AspNetCore => src/AMWD.Common.AspNetCore}/Utilities/PasswordHelper.cs (100%) rename {AMWD.Common.EntityFrameworkCore => src/AMWD.Common.EntityFrameworkCore}/AMWD.Common.EntityFrameworkCore.csproj (73%) rename {AMWD.Common.EntityFrameworkCore => src/AMWD.Common.EntityFrameworkCore}/Attributes/DatabaseIndexAttribute.cs (100%) rename {AMWD.Common.EntityFrameworkCore => src/AMWD.Common.EntityFrameworkCore}/Converters/DateOnlyConverter.cs (100%) rename {AMWD.Common.EntityFrameworkCore => src/AMWD.Common.EntityFrameworkCore}/Converters/NullableDateOnlyConverter.cs (100%) rename {AMWD.Common.EntityFrameworkCore => src/AMWD.Common.EntityFrameworkCore}/Converters/NullableTimeOnlyConverter.cs (100%) rename {AMWD.Common.EntityFrameworkCore => src/AMWD.Common.EntityFrameworkCore}/Converters/TimeOnlyConverter.cs (100%) rename {AMWD.Common.EntityFrameworkCore => src/AMWD.Common.EntityFrameworkCore}/Exceptions/DatabaseProviderException.cs (100%) rename {AMWD.Common.EntityFrameworkCore => src/AMWD.Common.EntityFrameworkCore}/Extensions/DatabaseFacadeExtensions.cs (100%) rename {AMWD.Common.EntityFrameworkCore => src/AMWD.Common.EntityFrameworkCore}/Extensions/DbContextExensions.cs (100%) rename {AMWD.Common.EntityFrameworkCore => src/AMWD.Common.EntityFrameworkCore}/Extensions/DbContextOptionsBuilderExtensions.cs (100%) rename {AMWD.Common.EntityFrameworkCore => src/AMWD.Common.EntityFrameworkCore}/Extensions/ModelBuilderExtensions.cs (100%) rename {AMWD.Common.EntityFrameworkCore => src/AMWD.Common.EntityFrameworkCore}/Extensions/ModelConfigurationBuilderExtensions.cs (100%) rename {AMWD.Common.EntityFrameworkCore => src/AMWD.Common.EntityFrameworkCore}/GlobalSuppressions.cs (100%) rename {AMWD.Common.EntityFrameworkCore => src/AMWD.Common.EntityFrameworkCore}/Utilities/DatabaseMigrationOptions.cs (100%) rename {AMWD.Common.EntityFrameworkCore => src/AMWD.Common.EntityFrameworkCore}/Utilities/DatabaseProviderOptions.cs (100%) rename {AMWD.Common.MessagePack => src/AMWD.Common.MessagePack}/AMWD.Common.MessagePack.csproj (53%) rename {AMWD.Common.MessagePack => src/AMWD.Common.MessagePack}/Formatters/IPAddressArrayFormatter.cs (100%) rename {AMWD.Common.MessagePack => src/AMWD.Common.MessagePack}/Formatters/IPAddressFormatter.cs (100%) rename {AMWD.Common.MessagePack => src/AMWD.Common.MessagePack}/Formatters/IPAddressListFormatter.cs (100%) rename {AMWD.Common.MessagePack => src/AMWD.Common.MessagePack}/Formatters/IPNetworkArrayFormatter.cs (100%) rename {AMWD.Common.MessagePack => src/AMWD.Common.MessagePack}/Formatters/IPNetworkFormatter.cs (100%) rename {AMWD.Common.MessagePack => src/AMWD.Common.MessagePack}/Formatters/IPNetworkListFormatter.cs (100%) rename {AMWD.Common.MessagePack => src/AMWD.Common.MessagePack}/Utilities/NetworkHelper.cs (100%) rename {AMWD.Common.Test => src/AMWD.Common.Test}/AMWD.Common.Test.csproj (53%) rename {AMWD.Common.Test => src/AMWD.Common.Test}/HttpMessageHandlerMoq.cs (100%) rename {AMWD.Common.Test => src/AMWD.Common.Test}/SnapshotAssert.cs (100%) rename {AMWD.Common.Test => src/AMWD.Common.Test}/TcpClientMoq.cs (100%) rename {AMWD.Common => src/AMWD.Common}/AMWD.Common.csproj (67%) rename {AMWD.Common => src/AMWD.Common}/Cli/Argument.cs (100%) rename {AMWD.Common => src/AMWD.Common}/Cli/CommandLineParser.cs (100%) rename {AMWD.Common => src/AMWD.Common}/Cli/EnumerableWalker.cs (100%) rename {AMWD.Common => src/AMWD.Common}/Cli/Option.cs (100%) rename {AMWD.Common => src/AMWD.Common}/Comparer/DomainComparer.cs (100%) rename {AMWD.Common => src/AMWD.Common}/Comparer/IPAddressComparer.cs (100%) rename {AMWD.Common => src/AMWD.Common}/Comparer/VersionStringComparer.cs (100%) rename {AMWD.Common => src/AMWD.Common}/Converters/ByteArrayHexConverter.cs (100%) rename {AMWD.Common => src/AMWD.Common}/Converters/IPAddressConverter.cs (100%) rename {AMWD.Common => src/AMWD.Common}/Converters/IPNetworkConverter.cs (100%) rename {AMWD.Common => src/AMWD.Common}/Extensions/CollectionExtensions.cs (100%) rename {AMWD.Common => src/AMWD.Common}/Extensions/CryptographyHelperExtensions.cs (100%) rename {AMWD.Common => src/AMWD.Common}/Extensions/DateTimeExtensions.cs (100%) rename {AMWD.Common => src/AMWD.Common}/Extensions/EnumExtensions.cs (100%) rename {AMWD.Common => src/AMWD.Common}/Extensions/ExceptionExtensions.cs (100%) rename {AMWD.Common => src/AMWD.Common}/Extensions/IPAddressExtensions.cs (100%) rename {AMWD.Common => src/AMWD.Common}/Extensions/JsonExtensions.cs (100%) rename {AMWD.Common => src/AMWD.Common}/Extensions/ReaderWriterLockSlimExtensions.cs (100%) rename {AMWD.Common => src/AMWD.Common}/Extensions/ReflectionExtensions.cs (100%) rename {AMWD.Common => src/AMWD.Common}/Extensions/StreamExtensions.cs (100%) rename {AMWD.Common => src/AMWD.Common}/Extensions/StringExtensions.cs (87%) create mode 100644 src/AMWD.Common/InternalsVisibleTo.cs rename {AMWD.Common => src/AMWD.Common}/Logging/FileLogger.cs (100%) rename {AMWD.Common => src/AMWD.Common}/Logging/NullScope.cs (100%) rename {AMWD.Common => src/AMWD.Common}/Packing/Ar/ArFileInfo.cs (100%) rename {AMWD.Common => src/AMWD.Common}/Packing/Ar/ArReader.cs (95%) rename {AMWD.Common => src/AMWD.Common}/Packing/Ar/ArWriter.cs (92%) rename {AMWD.Common => src/AMWD.Common}/Utilities/AsyncQueue.cs (100%) rename {AMWD.Common => src/AMWD.Common}/Utilities/CryptographyHelper.cs (100%) rename {AMWD.Common => src/AMWD.Common}/Utilities/DelayedTask.cs (100%) rename {AMWD.Common => src/AMWD.Common}/Utilities/NetworkHelper.cs (100%) create mode 100644 src/Directory.Build.props create mode 100644 test/AMWD.Common.AspNetCore.Tests/AMWD.Common.AspNetCore.Tests.csproj rename UnitTests/AspNetCore/Attributes/BasicAuthenticationAttributeTests.cs => test/AMWD.Common.AspNetCore.Tests/Attributes/BasicAuthenticationAttributeTest.cs (94%) rename UnitTests/AspNetCore/Attributes/IPAllowListAttributeTests.cs => test/AMWD.Common.AspNetCore.Tests/Attributes/IPAllowListAttributeTest.cs (94%) rename UnitTests/AspNetCore/Attributes/IPBlockListAttributeTests.cs => test/AMWD.Common.AspNetCore.Tests/Attributes/IPBlockListAttributeTest.cs (94%) rename UnitTests/AspNetCore/Extensions/HttpContextExtensionsTests.cs => test/AMWD.Common.AspNetCore.Tests/Extensions/HttpContextExtensionsTest.cs (93%) rename UnitTests/AspNetCore/Extensions/ModelStateDictionaryExtensionsTests.cs => test/AMWD.Common.AspNetCore.Tests/Extensions/ModelStateDictionaryExtensionsTest.cs (87%) rename UnitTests/AspNetCore/Extensions/SessionExtensionsTests.cs => test/AMWD.Common.AspNetCore.Tests/Extensions/SessionExtensionsTest.cs (90%) rename UnitTests/AspNetCore/Security/BasicAuthentication/BasicAuthenticationMiddlewareTests.cs => test/AMWD.Common.AspNetCore.Tests/Security/BasicAuthentication/BasicAuthenticationMiddlewareTest.cs (93%) rename UnitTests/AspNetCore/Security/PathProtection/ProtectedPathMiddlewareTests.cs => test/AMWD.Common.AspNetCore.Tests/Security/PathProtection/ProtectedPathMiddlewareTest.cs (92%) rename UnitTests/AspNetCore/Utilities/HtmlHelperTests.cs => test/AMWD.Common.AspNetCore.Tests/Utilities/HtmlHelperTest.cs (89%) rename UnitTests/AspNetCore/Utilities/PasswordHelperTests.cs => test/AMWD.Common.AspNetCore.Tests/Utilities/PasswordHelperTest.cs (90%) create mode 100644 test/AMWD.Common.Tests/AMWD.Common.Tests.csproj rename UnitTests/Common/Cli/CommandLineParserTests.cs => test/AMWD.Common.Tests/Cli/CommandLineParserTest.cs (95%) rename UnitTests/Common/Cli/EnumerableWalkerTests.cs => test/AMWD.Common.Tests/Cli/EnumerableWalkerTest.cs (88%) rename UnitTests/Common/Comparer/DomainComparerTests.cs => test/AMWD.Common.Tests/Comparer/DomainComparerTest.cs (87%) rename UnitTests/Common/Comparer/IPAddressComparerTests.cs => test/AMWD.Common.Tests/Comparer/IPAddressComparerTest.cs (87%) rename UnitTests/Common/Comparer/VersionStringComparerTests.cs => test/AMWD.Common.Tests/Comparer/VersionStringComparerTest.cs (86%) rename UnitTests/Common/Extensions/CollectionExtensionsTests.cs => test/AMWD.Common.Tests/Extensions/CollectionExtensionsTest.cs (90%) rename UnitTests/Common/Extensions/CryptographyHelperExtensionsTests.cs => test/AMWD.Common.Tests/Extensions/CryptographyHelperExtensionsTest.cs (86%) rename UnitTests/Common/Extensions/DateTimeExtensionsTests.cs => test/AMWD.Common.Tests/Extensions/DateTimeExtensionsTest.cs (96%) rename UnitTests/Common/Extensions/EnumExtensionsTests.cs => test/AMWD.Common.Tests/Extensions/EnumExtensionsTest.cs (88%) rename UnitTests/Common/Extensions/ExceptionExtensionsTests.cs => test/AMWD.Common.Tests/Extensions/ExceptionExtensionsTest.cs (88%) rename UnitTests/Common/Extensions/IPAddressExtensionsTests.cs => test/AMWD.Common.Tests/Extensions/IPAddressExtensionsTest.cs (85%) rename UnitTests/Common/Extensions/JsonExtensionsTests.cs => test/AMWD.Common.Tests/Extensions/JsonExtensionsTest.cs (92%) rename UnitTests/Common/Extensions/ReaderWriterLockSlimExtensionsTests.cs => test/AMWD.Common.Tests/Extensions/ReaderWriterLockSlimExtensionsTest.cs (91%) rename UnitTests/Common/Extensions/StreamExtensionsTests.cs => test/AMWD.Common.Tests/Extensions/StreamExtensionsTest.cs (89%) rename UnitTests/Common/Extensions/StringExtensionsTests.cs => test/AMWD.Common.Tests/Extensions/StringExtensionsTest.cs (93%) rename UnitTests/Common/Logging/FileLoggerTests.cs => test/AMWD.Common.Tests/Logging/FileLoggerTest.cs (95%) rename UnitTests/Common/Packing/Ar/ArReaderTests.cs => test/AMWD.Common.Tests/Packing/Ar/ArReaderTest.cs (77%) rename UnitTests/Common/Packing/Ar/ArWriterTests.cs => test/AMWD.Common.Tests/Packing/Ar/ArWriterTest.cs (67%) rename UnitTests/Common/Utilities/AsyncQueueTests.cs => test/AMWD.Common.Tests/Utilities/AsyncQueueTest.cs (93%) rename UnitTests/Common/Utilities/CryptographyHelperTests.cs => test/AMWD.Common.Tests/Utilities/CryptographyHelperTest.cs (95%) rename UnitTests/Common/Utilities/DelayedTaskTests.cs => test/AMWD.Common.Tests/Utilities/DelayedTaskTest.cs (94%) rename UnitTests/Common/Utilities/DelayedTaskWithResultTests.cs => test/AMWD.Common.Tests/Utilities/DelayedTaskWithResultTest.cs (92%) rename {UnitTests/Common => test/AMWD.Common.Tests}/Utils/CryptographyHelperSaltMock.cs (91%) rename {UnitTests/Common => test/AMWD.Common.Tests}/Utils/CustomMultipleAttribute.cs (85%) rename {UnitTests/Common => test/AMWD.Common.Tests}/Utils/JsonTestClass.cs (92%) rename {UnitTests/Common => test/AMWD.Common.Tests}/Utils/TimeZoneInfoLocalMock.cs (92%) create mode 100644 test/Directory.Build.props diff --git a/.gitignore b/.gitignore index e140a18..c7e04b0 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ build coverage.json +coverage.cobertura.xml # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 53b649e..3887a50 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,22 +17,23 @@ build-debug: tags: - docker - lnx + - 64bit rules: - if: $CI_COMMIT_TAG == null script: - dotnet restore --no-cache --force - dotnet build -c Debug --nologo --no-restore --no-incremental - mkdir ./artifacts - - mv ./AMWD.Common/bin/Debug/*.nupkg ./artifacts/ - - mv ./AMWD.Common/bin/Debug/*.snupkg ./artifacts/ - - mv ./AMWD.Common.AspNetCore/bin/Debug/*.nupkg ./artifacts/ - - mv ./AMWD.Common.AspNetCore/bin/Debug/*.snupkg ./artifacts/ - - mv ./AMWD.Common.EntityFrameworkCore/bin/Debug/*.nupkg ./artifacts/ - - mv ./AMWD.Common.EntityFrameworkCore/bin/Debug/*.snupkg ./artifacts/ - - mv ./AMWD.Common.MessagePack/bin/Debug/*.nupkg ./artifacts/ - - mv ./AMWD.Common.MessagePack/bin/Debug/*.snupkg ./artifacts/ - - mv ./AMWD.Common.Test/bin/Debug/*.nupkg ./artifacts/ - - mv ./AMWD.Common.Test/bin/Debug/*.snupkg ./artifacts/ + - mv ./src/AMWD.Common/bin/Debug/*.nupkg ./artifacts/ + - mv ./src/AMWD.Common/bin/Debug/*.snupkg ./artifacts/ + - mv ./src/AMWD.Common.AspNetCore/bin/Debug/*.nupkg ./artifacts/ + - mv ./src/AMWD.Common.AspNetCore/bin/Debug/*.snupkg ./artifacts/ + - mv ./src/AMWD.Common.EntityFrameworkCore/bin/Debug/*.nupkg ./artifacts/ + - mv ./src/AMWD.Common.EntityFrameworkCore/bin/Debug/*.snupkg ./artifacts/ + - mv ./src/AMWD.Common.MessagePack/bin/Debug/*.nupkg ./artifacts/ + - mv ./src/AMWD.Common.MessagePack/bin/Debug/*.snupkg ./artifacts/ + - mv ./src/AMWD.Common.Test/bin/Debug/*.nupkg ./artifacts/ + - mv ./src/AMWD.Common.Test/bin/Debug/*.snupkg ./artifacts/ artifacts: paths: - artifacts/*.nupkg @@ -46,15 +47,24 @@ test-debug: tags: - docker - lnx + - 64bit rules: - if: $CI_COMMIT_TAG == null - # line-coverage - #coverage: '/Total[^|]*\|\s*([0-9.%]+)/' - # branch-coverage - coverage: '/Total[^|]*\|[^|]*\|\s*([0-9.%]+)/' + #coverage: /Line coverage[\s\S].+%/ + coverage: /Branch coverage[\s\S].+%/ + before_script: + - dotnet tool install dotnet-reportgenerator-globaltool --tool-path /dotnet-tools script: - dotnet restore --no-cache --force - - dotnet test -c Debug --nologo --no-restore + - dotnet test -c Debug --nologo --no-restore /p:CoverletOutputFormat=Cobertura + - /dotnet-tools/reportgenerator "-reports:${CI_PROJECT_DIR}/**/coverage.cobertura.xml" "-targetdir:/reports" -reportType:TextSummary + - cat /reports/Summary.txt + artifacts: + when: always + reports: + coverage_report: + coverage_format: cobertura + path: ./**/coverage.cobertura.xml @@ -63,22 +73,23 @@ build-release: tags: - docker - lnx + - 64bit rules: - if: $CI_COMMIT_TAG != null script: - dotnet restore --no-cache --force - dotnet build -c Release --nologo --no-restore --no-incremental - mkdir ./artifacts - - mv ./AMWD.Common/bin/Release/*.nupkg ./artifacts/ - - mv ./AMWD.Common/bin/Release/*.snupkg ./artifacts/ - - mv ./AMWD.Common.AspNetCore/bin/Release/*.nupkg ./artifacts/ - - mv ./AMWD.Common.AspNetCore/bin/Release/*.snupkg ./artifacts/ - - mv ./AMWD.Common.EntityFrameworkCore/bin/Release/*.nupkg ./artifacts/ - - mv ./AMWD.Common.EntityFrameworkCore/bin/Release/*.snupkg ./artifacts/ - - mv ./AMWD.Common.MessagePack/bin/Release/*.nupkg ./artifacts/ - - mv ./AMWD.Common.MessagePack/bin/Release/*.snupkg ./artifacts/ - - mv ./AMWD.Common.Test/bin/Release/*.nupkg ./artifacts/ - - mv ./AMWD.Common.Test/bin/Release/*.snupkg ./artifacts/ + - mv ./src/AMWD.Common/bin/Release/*.nupkg ./artifacts/ + - mv ./src/AMWD.Common/bin/Release/*.snupkg ./artifacts/ + - mv ./src/AMWD.Common.AspNetCore/bin/Release/*.nupkg ./artifacts/ + - mv ./src/AMWD.Common.AspNetCore/bin/Release/*.snupkg ./artifacts/ + - mv ./src/AMWD.Common.EntityFrameworkCore/bin/Release/*.nupkg ./artifacts/ + - mv ./src/AMWD.Common.EntityFrameworkCore/bin/Release/*.snupkg ./artifacts/ + - mv ./src/AMWD.Common.MessagePack/bin/Release/*.nupkg ./artifacts/ + - mv ./src/AMWD.Common.MessagePack/bin/Release/*.snupkg ./artifacts/ + - mv ./src/AMWD.Common.Test/bin/Release/*.nupkg ./artifacts/ + - mv ./src/AMWD.Common.Test/bin/Release/*.snupkg ./artifacts/ artifacts: paths: - artifacts/*.nupkg @@ -92,15 +103,24 @@ test-release: tags: - docker - lnx + - 64bit rules: - if: $CI_COMMIT_TAG != null - # line-coverage - #coverage: '/Total[^|]*\|\s*([0-9.%]+)/' - # branch-coverage - coverage: '/Total[^|]*\|[^|]*\|\s*([0-9.%]+)/' + #coverage: /Line coverage[\s\S].+%/ + coverage: /Branch coverage[\s\S].+%/ + before_script: + - dotnet tool install dotnet-reportgenerator-globaltool --tool-path /dotnet-tools script: - dotnet restore --no-cache --force - - dotnet test -c Release --nologo --no-restore + - dotnet test -c Release --nologo --no-restore /p:CoverletOutputFormat=Cobertura + - /dotnet-tools/reportgenerator "-reports:${CI_PROJECT_DIR}/**/coverage.cobertura.xml" "-targetdir:/reports" -reportType:TextSummary + - cat /reports/Summary.txt + artifacts: + when: always + reports: + coverage_report: + coverage_format: cobertura + path: ./**/coverage.cobertura.xml deploy-common: stage: deploy @@ -110,6 +130,7 @@ deploy-common: tags: - docker - lnx + - 64bit rules: - if: $CI_COMMIT_TAG =~ /^v[0-9.]+/ script: @@ -123,12 +144,13 @@ deploy-aspnet: tags: - docker - lnx + - 64bit rules: - if: $CI_COMMIT_TAG =~ /^asp\/v[0-9.]+/ script: - dotnet nuget push -k $BAGET_APIKEY -s https://nuget.am-wd.de/v3/index.json --skip-duplicate artifacts/AMWD.Common.AspNetCore.*.nupkg -deploy-entityframework: +deploy-efcore: stage: deploy dependencies: - build-release @@ -136,12 +158,13 @@ deploy-entityframework: tags: - docker - lnx + - 64bit rules: - if: $CI_COMMIT_TAG =~ /^efc\/v[0-9.]+/ script: - dotnet nuget push -k $BAGET_APIKEY -s https://nuget.am-wd.de/v3/index.json --skip-duplicate artifacts/AMWD.Common.EntityFrameworkCore.*.nupkg -deploy-messagepack: +deploy-msgpack: stage: deploy dependencies: - build-release @@ -149,6 +172,7 @@ deploy-messagepack: tags: - docker - lnx + - 64bit rules: - if: $CI_COMMIT_TAG =~ /^msgpack\/v[0-9.]+/ script: @@ -162,6 +186,7 @@ deploy-test: tags: - docker - lnx + - 64bit rules: - if: $CI_COMMIT_TAG =~ /^test\/v[0-9.]+/ script: diff --git a/AMWD.Common/InternalsVisibleTo.cs b/AMWD.Common/InternalsVisibleTo.cs deleted file mode 100644 index cd080bc..0000000 --- a/AMWD.Common/InternalsVisibleTo.cs +++ /dev/null @@ -1,3 +0,0 @@ -using System.Runtime.CompilerServices; - -[assembly: InternalsVisibleTo("UnitTests")] diff --git a/AMWD.Common/Packing/Tar/Interfaces/IArchiveDataWriter.cs b/AMWD.Common/Packing/Tar/Interfaces/IArchiveDataWriter.cs deleted file mode 100644 index d621ed3..0000000 --- a/AMWD.Common/Packing/Tar/Interfaces/IArchiveDataWriter.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace AMWD.Common.Packing.Tar.Interfaces -{ - /// - /// Interface of a archive writer. - /// - public interface IArchiveDataWriter - { - /// - /// Write bytes of data from to corresponding archive. - /// - /// The data storage. - /// How many bytes to be written to the corresponding archive. - int Write(byte[] buffer, int count); - - /// - /// Gets a value indicating whether the writer can write. - /// - bool CanWrite { get; } - } - - /// - /// The writer delegate. - /// - /// The writer. - public delegate void WriteDataDelegate(IArchiveDataWriter writer); -} diff --git a/AMWD.Common/Packing/Tar/Interfaces/ITarHeader.cs b/AMWD.Common/Packing/Tar/Interfaces/ITarHeader.cs deleted file mode 100644 index f4a474f..0000000 --- a/AMWD.Common/Packing/Tar/Interfaces/ITarHeader.cs +++ /dev/null @@ -1,125 +0,0 @@ -using System; -using AMWD.Common.Packing.Tar.Utils; - -namespace AMWD.Common.Packing.Tar.Interfaces -{ - /// - /// See "struct star_header" in - /// - public interface ITarHeader - { - /// - /// The name field is the file name of the file, with directory names (if any) preceding the file name, - /// separated by slashes. - /// - /// - /// name - ///
- /// Byte offset: 0 - ///
- string FileName { get; set; } - - /// - /// The mode field provides nine bits specifying file permissions and three bits to specify - /// the Set UID, Set GID, and Save Text (sticky) modes. - /// When special permissions are required to create a file with a given mode, - /// and the user restoring files from the archive does not hold such permissions, - /// the mode bit(s) specifying those special permissions are ignored. - /// Modes which are not supported by the operating system restoring files from the archive will be ignored. - /// Unsupported modes should be faked up when creating or updating an archive; e.g., - /// the group permission could be copied from the other permission. - /// - /// - /// mode - ///
- /// Byte offset: 100 - ///
- int Mode { get; set; } - - /// - /// The uid field is the numeric user ID of the file owners. - /// If the operating system does not support numeric user ID, this field should be ignored. - /// - /// - /// uid - ///
- /// Byte offset: 108 - ///
- int UserId { get; set; } - - /// - /// The gid fields is the numeric group ID of the file owners. - /// If the operating system does not support numeric group ID, this field should be ignored. - /// - /// - /// gid - ///
- /// Byte offset: 116 - ///
- int GroupId { get; set; } - - /// - /// The size field is the size of the file in bytes; - /// linked files are archived with this field specified as zero. - /// - /// - /// size - ///
- /// Byte offset: 124 - ///
- long SizeInBytes { get; set; } - - /// - /// mtime - /// byte offset: 136 - /// The mtime field represents the data modification time of the file at the time it was archived. - /// It represents the integer number of seconds since January 1, 1970, 00:00 Coordinated Universal Time. - /// - /// - /// mtime - ///
- /// Byte offset: 136 - ///
- DateTime LastModification { get; set; } - - /// - /// The typeflag field specifies the type of file archived. - /// If a particular implementation does not recognize or permit the specified type, - /// the file will be extracted as if it were a regular file. - /// As this action occurs, tar issues a warning to the standard error. - /// - /// - /// typeflag - ///
- /// Byte offset: 156 - ///
- EntryType EntryType { get; set; } - - /// - /// The uname field will contain the ASCII representation of the owner of the file. - /// If found, the user ID is used rather than the value in the uid field. - /// - /// - /// uname - ///
- /// Byte offset: 265 - ///
- string UserName { get; set; } - - /// - /// The gname field will contain the ASCII representation of the group of the file. - /// If found, the group ID is used rather than the values in the gid field. - /// - /// - /// gname - ///
- /// Byte offset: 297 - ///
- string GroupName { get; set; } - - /// - /// The size of this header. - /// - int HeaderSize { get; } - } -} diff --git a/AMWD.Common/Packing/Tar/TarReader.cs b/AMWD.Common/Packing/Tar/TarReader.cs deleted file mode 100644 index 51f891f..0000000 --- a/AMWD.Common/Packing/Tar/TarReader.cs +++ /dev/null @@ -1,205 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using AMWD.Common.Packing.Tar.Interfaces; -using AMWD.Common.Packing.Tar.Utils; - -namespace AMWD.Common.Packing.Tar -{ - /// - /// Extract contents of a tar file represented by a stream for the TarReader constructor. - /// - /// - /// Constructs TarReader object to read data from `tarredData` stream. - ///
- /// Copied from: DotnetMakeDeb - ///
- /// A stream to read tar archive from - public class TarReader(Stream tarredData) - { - private readonly byte[] _dataBuffer = new byte[512]; - private readonly UsTarHeader _header = new(); - private readonly Stream _inStream = tarredData; - private long _remainingBytesInFile; - - /// - /// Gets the file info (the header). - /// - public ITarHeader FileInfo => _header; - - /// - /// Read all files from an archive to a directory. It creates some child directories to - /// reproduce a file structure from the archive. - /// - /// The out directory. - /// - /// CAUTION! This method is not safe. It's not tar-bomb proof. - /// {see http://en.wikipedia.org/wiki/Tar_(file_format) } - /// If you are not sure about the source of an archive you extracting, - /// then use MoveNext and Read and handle paths like ".." and "../.." according - /// to your business logic. - public void ReadToEnd(string destDirectory) - { - while (MoveNext(skipData: false)) - { - string fileNameFromArchive = FileInfo.FileName; - string totalPath = destDirectory + Path.DirectorySeparatorChar + fileNameFromArchive; - if (UsTarHeader.IsPathSeparator(fileNameFromArchive[fileNameFromArchive.Length - 1]) || FileInfo.EntryType == EntryType.Directory) - { - // Record is a directory - Directory.CreateDirectory(totalPath); - continue; - } - - // If record is a file - string fileName = Path.GetFileName(totalPath); - string directory = totalPath.Remove(totalPath.Length - fileName.Length); - Directory.CreateDirectory(directory); - - using FileStream file = File.Create(totalPath); - Read(file); - } - } - - /// - /// Read data from the current archive to a Stream. - /// - /// A stream to read data to - /// - public void Read(Stream dataDestanation) - { - Debug.WriteLine("tar stream position Read in: " + _inStream.Position); - - int readBytes; - while ((readBytes = Read(out byte[] read)) != -1) - { - Debug.WriteLine("tar stream position Read while(...) : " + _inStream.Position); - dataDestanation.Write(read, 0, readBytes); - } - - Debug.WriteLine("tar stream position Read out: " + _inStream.Position); - } - - /// - /// Reads data from the current archive to a buffer array. - /// - /// The buffer array. - /// The nuber of bytes read. - protected int Read(out byte[] buffer) - { - if (_remainingBytesInFile == 0) - { - buffer = null; - return -1; - } - - int align512 = -1; - long toRead = _remainingBytesInFile - 512; - - if (toRead > 0) - { - toRead = 512; - } - else - { - align512 = 512 - (int)_remainingBytesInFile; - toRead = _remainingBytesInFile; - } - - int bytesRead = _inStream.Read(_dataBuffer, 0, (int)toRead); - _remainingBytesInFile -= bytesRead; - - if (_inStream.CanSeek && align512 > 0) - { - _inStream.Seek(align512, SeekOrigin.Current); - } - else - while (align512 > 0) - { - _inStream.ReadByte(); - --align512; - } - - buffer = _dataBuffer; - return bytesRead; - } - - /// - /// Check if all bytes in buffer are zeroes - /// - /// buffer to check - /// true if all bytes are zeroes, otherwise false - private static bool IsEmpty(IEnumerable buffer) - { - foreach (byte b in buffer) - { - if (b != 0) - return false; - } - return true; - } - - /// - /// Move internal pointer to a next file in archive. - /// - /// Should be true if you want to read a header only, otherwise false - /// false on End Of File otherwise true - /// - /// Example: - /// while(MoveNext()) - /// { - /// Read(dataDestStream); - /// } - /// - public bool MoveNext(bool skipData) - { - Debug.WriteLine("tar stream position MoveNext in: " + _inStream.Position); - if (_remainingBytesInFile > 0) - { - if (!skipData) - { - throw new TarException( - "You are trying to change file while not all the data from the previous one was read. If you do want to skip files use skipData parameter set to true."); - } - - // Skip to the end of file. - if (_inStream.CanSeek) - { - long remainer = _remainingBytesInFile % 512; - _inStream.Seek(_remainingBytesInFile + (512 - (remainer == 0 ? 512 : remainer)), SeekOrigin.Current); - } - else - { - while (Read(out _) != -1) ; - } - } - - byte[] bytes = _header.GetBytes(); - - int headerRead = _inStream.Read(bytes, 0, _header.HeaderSize); - if (headerRead < 512) - throw new TarException("Can not read header"); - - if (IsEmpty(bytes)) - { - headerRead = _inStream.Read(bytes, 0, _header.HeaderSize); - if (headerRead == 512 && IsEmpty(bytes)) - { - Debug.WriteLine("tar stream position MoveNext out(false): " + _inStream.Position); - return false; - } - throw new TarException("Broken archive"); - } - - if (_header.UpdateHeaderFromBytes()) - { - throw new TarException("Checksum check failed"); - } - - _remainingBytesInFile = _header.SizeInBytes; - - Debug.WriteLine("tar stream position MoveNext out(true): " + _inStream.Position); - return true; - } - } -} diff --git a/AMWD.Common/Packing/Tar/TarWriter.cs b/AMWD.Common/Packing/Tar/TarWriter.cs deleted file mode 100644 index 12f90f9..0000000 --- a/AMWD.Common/Packing/Tar/TarWriter.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System; -using System.IO; -using AMWD.Common.Packing.Tar.Interfaces; -using AMWD.Common.Packing.Tar.Utils; - -namespace AMWD.Common.Packing.Tar -{ - /// - /// Writes a tar (see GNU tar) archive to a stream. - /// - /// - /// Copied from: DotnetMakeDeb - /// - public class TarWriter : LegacyTarWriter - { - /// - /// Initilizes a new instance of the class. - /// - /// The stream to write the archive to. - public TarWriter(Stream outStream) - : base(outStream) - { } - - /// - /// Writes an entry header (file, dir, ...) to the archive. - /// - /// The name. - /// The last modification time. - /// The number of bytes. - /// The user id. - /// The group id. - /// The access mode. - /// The entry type. - protected override void WriteHeader(string name, DateTime lastModificationTime, long count, int userId, int groupId, int mode, EntryType entryType) - { - var tarHeader = new UsTarHeader() - { - FileName = name, - Mode = mode, - UserId = userId, - GroupId = groupId, - SizeInBytes = count, - LastModification = lastModificationTime, - EntryType = entryType, - UserName = Convert.ToString(userId, 8), - GroupName = Convert.ToString(groupId, 8) - }; - OutStream.Write(tarHeader.GetHeaderValue(), 0, tarHeader.HeaderSize); - } - - /// - /// Writes an entry header (file, dir, ...) to the archive. - /// Hashes the username and groupname down to a HashCode. - /// - /// The name. - /// The last modification time. - /// The number of bytes. - /// The username. - /// The group name. - /// The access mode. - /// The entry type. - protected virtual void WriteHeader(string name, DateTime lastModificationTime, long count, string userName, string groupName, int mode, EntryType entryType) - { - WriteHeader( - name: name, - lastModificationTime: lastModificationTime, - count: count, - userId: userName.GetHashCode(), - groupId: groupName.GetHashCode(), - mode: mode, - entryType: entryType); - } - - /// - /// Writes a file to the archive. - /// - /// The file name. - /// The filesize in bytes. - /// The username. - /// The group name. - /// The access mode. - /// The last modification time. - /// The write handle. - public virtual void Write(string name, long dataSizeInBytes, string userName, string groupName, int mode, DateTime lastModificationTime, WriteDataDelegate writeDelegate) - { - var writer = new DataWriter(OutStream, dataSizeInBytes); - WriteHeader(name, lastModificationTime, dataSizeInBytes, userName, groupName, mode, EntryType.File); - while (writer.CanWrite) - { - writeDelegate(writer); - } - AlignTo512(dataSizeInBytes, false); - } - - /// - /// Writes a file to the archive. - /// - /// The file stream to add to the archive. - /// The filesize in bytes. - /// The file name. - /// The user id. - /// The group id. - /// The access mode. - /// The last modification time. - public void Write(Stream data, long dataSizeInBytes, string fileName, string userId, string groupId, int mode, - DateTime lastModificationTime) - { - WriteHeader(fileName, lastModificationTime, dataSizeInBytes, userId, groupId, mode, EntryType.File); - WriteContent(dataSizeInBytes, data); - AlignTo512(dataSizeInBytes, false); - } - } -} diff --git a/AMWD.Common/Packing/Tar/Utils/DataWriter.cs b/AMWD.Common/Packing/Tar/Utils/DataWriter.cs deleted file mode 100644 index 2401fcd..0000000 --- a/AMWD.Common/Packing/Tar/Utils/DataWriter.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.IO; -using AMWD.Common.Packing.Tar.Interfaces; - -namespace AMWD.Common.Packing.Tar.Utils -{ - internal class DataWriter : IArchiveDataWriter - { - private readonly long _size; - private long _remainingBytes; - private readonly Stream _stream; - - public DataWriter(Stream data, long dataSizeInBytes) - { - _size = dataSizeInBytes; - _remainingBytes = _size; - _stream = data; - } - - public bool CanWrite { get; private set; } = true; - - public int Write(byte[] buffer, int count) - { - if (_remainingBytes == 0) - { - CanWrite = false; - return -1; - } - - int bytesToWrite; - if (_remainingBytes - count < 0) - { - bytesToWrite = (int)_remainingBytes; - } - else - { - bytesToWrite = count; - } - - _stream.Write(buffer, 0, bytesToWrite); - _remainingBytes -= bytesToWrite; - - return bytesToWrite; - } - } -} diff --git a/AMWD.Common/Packing/Tar/Utils/EntryType.cs b/AMWD.Common/Packing/Tar/Utils/EntryType.cs deleted file mode 100644 index 2eadbec..0000000 --- a/AMWD.Common/Packing/Tar/Utils/EntryType.cs +++ /dev/null @@ -1,73 +0,0 @@ -namespace AMWD.Common.Packing.Tar.Utils -{ - ///
- /// See "Values used in typeflag field." in - /// - public enum EntryType : byte - { - /// - /// AREGTYPE, regular file - /// - File = 0, - - /// - /// REGTYPE, regular file - /// - FileObsolete = 0x30, - - /// - /// LNKTYPE, link - /// - HardLink = 0x31, - - /// - /// SYMTYPE, reserved - /// - SymLink = 0x32, - - /// - /// CHRTYPE, character special - /// - CharDevice = 0x33, - - /// - /// BLKTYPE, block special - /// - BlockDevice = 0x34, - - /// - /// DIRTYPE, directory - /// - Directory = 0x35, - - /// - /// FIFOTYPE, FIFO special - /// - Fifo = 0x36, - - /// - /// CONTTYPE, reserved - /// - Content = 0x37, - - /// - /// XHDTYPE, Extended header referring to the next file in the archive - /// - ExtendedHeader = 0x78, - - /// - /// XGLTYPE, Global extended header - /// - GlobalExtendedHeader = 0x67, - - /// - /// GNUTYPE_LONGLINK, Identifies the *next* file on the tape as having a long linkname. - /// - LongLink = 0x4b, - - /// - /// GNUTYPE_LONGNAME, Identifies the *next* file on the tape as having a long name. - /// - LongName = 0x4c - } -} diff --git a/AMWD.Common/Packing/Tar/Utils/LegacyTarWriter.cs b/AMWD.Common/Packing/Tar/Utils/LegacyTarWriter.cs deleted file mode 100644 index 1944326..0000000 --- a/AMWD.Common/Packing/Tar/Utils/LegacyTarWriter.cs +++ /dev/null @@ -1,329 +0,0 @@ -using System; -using System.IO; -using System.Text; -using System.Threading; -using AMWD.Common.Packing.Tar.Interfaces; - -namespace AMWD.Common.Packing.Tar.Utils -{ - /// - /// Implements a legacy TAR writer. - /// - /// - /// Writes tar (see GNU tar) archive to a stream - ///
- /// Copied from: DotnetMakeDeb - ///
- /// stream to write archive to - public class LegacyTarWriter(Stream outStream) : IDisposable - { - private readonly Stream _outStream = outStream; - private bool _isClosed; - - /// - /// The buffer for writing. - /// - protected byte[] buffer = new byte[1024]; - - /// - /// Gets or sets a value indicating whether to read on zero. - /// - public bool ReadOnZero { get; set; } = true; - - /// - /// Gets the output stream. - /// - protected virtual Stream OutStream - { - get { return _outStream; } - } - - #region IDisposable Members - - /// - public void Dispose() - => Close(); - - #endregion IDisposable Members - - /// - /// Writes a directory entry. - /// - /// The path to the directory. - /// The user id. - /// The group id. - /// The access mode. - /// is not set. - public void WriteDirectoryEntry(string path, int userId, int groupId, int mode) - { - if (string.IsNullOrEmpty(path)) - throw new ArgumentNullException(nameof(path), "The path is not set."); - if (path[path.Length - 1] != '/') - path += '/'; - - DateTime lastWriteTime; - if (Directory.Exists(path)) - { - lastWriteTime = Directory.GetLastWriteTime(path); - } - else - { - lastWriteTime = DateTime.Now; - } - - // handle long path names (> 99 characters) - if (path.Length > 99) - { - WriteLongName( - name: path, - userId: userId, - groupId: groupId, - mode: mode, - lastModificationTime: lastWriteTime); - - // shorten the path name so it can be written properly - path = path.Substring(0, 99); - } - - WriteHeader(path, lastWriteTime, 0, userId, groupId, mode, EntryType.Directory); - } - - /// - /// Writes a directory and its contents. - /// - /// The directory. - /// Write also sub-directories. - /// is not set. - public void WriteDirectory(string directory, bool doRecursive) - { - if (string.IsNullOrEmpty(directory)) - throw new ArgumentNullException(nameof(directory), "The directory is not set."); - - WriteDirectoryEntry(directory, 0, 0, 0755); - - string[] files = Directory.GetFiles(directory); - foreach (string fileName in files) - Write(fileName); - - string[] directories = Directory.GetDirectories(directory); - foreach (string dirName in directories) - { - WriteDirectoryEntry(dirName, 0, 0, 0755); - if (doRecursive) - WriteDirectory(dirName, true); - } - } - - /// - /// Writes a file. - /// - /// The file. - /// is not set. - public void Write(string fileName) - { - if (string.IsNullOrEmpty(fileName)) - throw new ArgumentNullException(nameof(fileName), "The file name is not set."); - - using var fileStream = File.OpenRead(fileName); - Write(fileStream, fileStream.Length, fileName, 61, 61, 511, File.GetLastWriteTime(fileStream.Name)); - } - - /// - /// Writes a file stream. - /// - /// The file stream. - public void Write(FileStream file) - { - string path = Path.GetFullPath(file.Name).Replace(Path.GetPathRoot(file.Name), string.Empty); - path = path.Replace(Path.DirectorySeparatorChar, '/'); - Write(file, file.Length, path, 61, 61, 511, File.GetLastWriteTime(file.Name)); - } - - /// - /// Writes a stream. - /// - /// The contents. - /// The file size in bytes. - /// The file name. - public void Write(Stream data, long dataSizeInBytes, string name) - => Write(data, dataSizeInBytes, name, 61, 61, 511, DateTime.Now); - - /// - /// Writes a file to the archive. - /// - /// The file name. - /// The file size in bytes. - /// The user id. - /// The group id. - /// The access mode. - /// The last modification timestamp. - /// The . - public virtual void Write(string name, long dataSizeInBytes, int userId, int groupId, int mode, DateTime lastModificationTime, WriteDataDelegate writeDelegate) - { - var writer = new DataWriter(OutStream, dataSizeInBytes); - - WriteHeader(name, lastModificationTime, dataSizeInBytes, userId, groupId, mode, EntryType.File); - - while (writer.CanWrite) - writeDelegate(writer); - - AlignTo512(dataSizeInBytes, false); - } - - /// - /// Writes a stream as file to the archive. - /// - /// The content as . - /// The file size in bytes. - /// The file name. - /// The user id. - /// The group id. - /// The access mode. - /// The last modification timestamp. - /// This writer is already closed. - public virtual void Write(Stream data, long dataSizeInBytes, string name, int userId, int groupId, int mode, DateTime lastModificationTime) - { - if (_isClosed) - throw new TarException("Can not write to the closed writer"); - - // handle long file names (> 99 characters) - if (name.Length > 99) - { - WriteLongName( - name: name, - userId: userId, - groupId: groupId, - mode: mode, - lastModificationTime: lastModificationTime); - - // shorten the file name so it can be written properly - name = name.Substring(0, 99); - } - - WriteHeader(name, lastModificationTime, dataSizeInBytes, userId, groupId, mode, EntryType.File); - WriteContent(dataSizeInBytes, data); - AlignTo512(dataSizeInBytes, false); - } - - /// - /// Handle long file or path names (> 99 characters). - /// Write header and content, which its content contain the long (complete) file/path name. - /// This handling method is adapted from https://github.com/qmfrederik/dotnet-packaging/pull/50/files#diff-f64c58cc18e8e445cee6ffed7a0d765cdb442c0ef21a3ed80bd20514057967b1 - /// - /// File name or path name. - /// User ID. - /// Group ID. - /// Mode. - /// Last modification time. - private void WriteLongName(string name, int userId, int groupId, int mode, DateTime lastModificationTime) - { - // must include a trailing \0 - int nameLength = Encoding.UTF8.GetByteCount(name); - byte[] entryName = new byte[nameLength + 1]; - - Encoding.UTF8.GetBytes(name, 0, name.Length, entryName, 0); - - // add a "././@LongLink" pseudo-entry which contains the full name - using var nameStream = new MemoryStream(entryName); - WriteHeader("././@LongLink", lastModificationTime, entryName.Length, userId, groupId, mode, EntryType.LongName); - WriteContent(entryName.Length, nameStream); - AlignTo512(entryName.Length, false); - } - - /// - /// Writes a stream as file to the archive. - /// - /// The size of the file in bytes. - /// The file content as stream. - /// has not enough to read from. - protected void WriteContent(long count, Stream data) - { - while (count > 0 && count > buffer.Length) - { - int bytesRead = data.Read(buffer, 0, buffer.Length); - if (bytesRead < 0) - throw new IOException($"{nameof(LegacyTarWriter)} unable to read from provided stream"); - - if (bytesRead == 0) - { - if (ReadOnZero) - Thread.Sleep(100); - else - break; - } - OutStream.Write(buffer, 0, bytesRead); - count -= bytesRead; - } - if (count > 0) - { - int bytesRead = data.Read(buffer, 0, (int)count); - if (bytesRead < 0) - throw new IOException($"{nameof(LegacyTarWriter)} unable to read from provided stream"); - - if (bytesRead == 0) - { - while (count > 0) - { - OutStream.WriteByte(0); - --count; - } - } - else - OutStream.Write(buffer, 0, bytesRead); - } - } - - /// - /// Writes a entry header to the archive. - /// - /// The file name. - /// The last modification time. - /// The number of bytes. - /// The user id. - /// The group id. - /// The file mode. - /// The entry type - protected virtual void WriteHeader(string name, DateTime lastModificationTime, long count, int userId, int groupId, int mode, EntryType entryType) - { - var header = new TarHeader - { - FileName = name, - LastModification = lastModificationTime, - SizeInBytes = count, - UserId = userId, - GroupId = groupId, - Mode = mode, - EntryType = entryType - }; - OutStream.Write(header.GetHeaderValue(), 0, header.HeaderSize); - } - - /// - /// Aligns the entry to 512 bytes. - /// - public void AlignTo512(long size, bool acceptZero) - { - size %= 512; - if (size == 0 && !acceptZero) return; - while (size < 512) - { - OutStream.WriteByte(0); - size++; - } - } - - /// - /// Closes the writer and aligns to 512 bytes. - /// - public virtual void Close() - { - if (_isClosed) - return; - - AlignTo512(0, true); - AlignTo512(0, true); - - _isClosed = true; - } - } -} diff --git a/AMWD.Common/Packing/Tar/Utils/TarException.cs b/AMWD.Common/Packing/Tar/Utils/TarException.cs deleted file mode 100644 index ed83e55..0000000 --- a/AMWD.Common/Packing/Tar/Utils/TarException.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; - -namespace AMWD.Common.Packing.Tar.Utils -{ - /// - /// Represents errors that occur during tar archive execution. - /// - public class TarException : Exception - { - /// - /// Initializes a new instance of the class. - /// - public TarException() - : base() - { } - - /// - /// Initializes a new instance of the class with a specified - /// error message. - /// - /// The message that describes the error. - public TarException(string message) - : base(message) - { } - - /// - /// Initializes a new instance of the System.Exception class with a specified error - /// message and a reference to the inner exception that is the cause of this exception. - /// - /// The error message that explains the reason for the exception. - /// The exception that is the cause of the current exception, or a null reference - /// if no inner exception is specified. - public TarException(string message, Exception innerException) - : base(message, innerException) - { } - -#if !NET8_0_OR_GREATER - - /// - /// Initializes a new instance of the class with serialized data. - /// - /// The that holds the serialized - /// object data about the exception being thrown. - /// The that contains contextual information - /// about the source or destination. - protected TarException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) - { } - -#endif - } -} diff --git a/AMWD.Common/Packing/Tar/Utils/TarHeader.cs b/AMWD.Common/Packing/Tar/Utils/TarHeader.cs deleted file mode 100644 index c1f1107..0000000 --- a/AMWD.Common/Packing/Tar/Utils/TarHeader.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using System.Linq; -using System.Net; -using System.Text; -using AMWD.Common.Packing.Tar.Interfaces; - -namespace AMWD.Common.Packing.Tar.Utils -{ - internal class TarHeader : ITarHeader - { - private static readonly byte[] _spaces = Encoding.ASCII.GetBytes(" "); - private readonly byte[] _buffer = new byte[512]; - - private string _fileName; - private long _headerChecksum; - - public TarHeader() - { - // Default values - Mode = 511; // 0777 dec - UserId = 61; // 101 dec - GroupId = 61; // 101 dec - } - - public EntryType EntryType { get; set; } - - public virtual string FileName - { - get => _fileName.Replace("\0", string.Empty); - set - { - if (value.Length > 100) - throw new TarException("A file name can not be more than 100 chars long"); - - _fileName = value; - } - } - - public int Mode { get; set; } - - public string ModeString - => Convert.ToString(Mode, 8).PadLeft(7, '0'); - - public int UserId { get; set; } - - public virtual string UserName - { - get => UserId.ToString(); - set => UserId = int.Parse(value); - } - - public string UserIdString - => Convert.ToString(UserId, 8).PadLeft(7, '0'); - - public int GroupId { get; set; } - - public virtual string GroupName - { - get => GroupId.ToString(); - set => GroupId = int.Parse(value); - } - - public string GroupIdString - => Convert.ToString(GroupId, 8).PadLeft(7, '0'); - - public long SizeInBytes { get; set; } - - public string SizeString - => Convert.ToString(SizeInBytes, 8).PadLeft(11, '0'); - - public DateTime LastModification { get; set; } - - public string LastModificationString - { - get - { - long unixTime = ((DateTimeOffset)DateTime.SpecifyKind(LastModification, DateTimeKind.Utc)).ToUnixTimeSeconds(); - return Convert.ToString(unixTime, 8).PadLeft(11, '0'); - } - } - - public string HeaderChecksumString - => Convert.ToString(_headerChecksum, 8).PadLeft(6, '0'); - - public virtual int HeaderSize => 512; - - public byte[] GetBytes() => _buffer.ToArray(); - - public virtual bool UpdateHeaderFromBytes() - { - FileName = Encoding.ASCII.GetString(_buffer, 0, 100); - - // Thanks to Shasha Alperocivh. Trimming nulls. - Mode = Convert.ToInt32(Encoding.ASCII.GetString(_buffer, 100, 7).Trim(), 8); - UserId = Convert.ToInt32(Encoding.ASCII.GetString(_buffer, 108, 7).Trim(), 8); - GroupId = Convert.ToInt32(Encoding.ASCII.GetString(_buffer, 116, 7).Trim(), 8); - - EntryType = (EntryType)_buffer[156]; - - if ((_buffer[124] & 0x80) == 0x80) // if size in binary - { - long sizeBigEndian = BitConverter.ToInt64(_buffer, 0x80); - SizeInBytes = IPAddress.NetworkToHostOrder(sizeBigEndian); - } - else - { - SizeInBytes = Convert.ToInt64(Encoding.ASCII.GetString(_buffer, 124, 11), 8); - } - long unixTimeStamp = Convert.ToInt64(Encoding.ASCII.GetString(_buffer, 136, 11), 8); - LastModification = DateTimeOffset.FromUnixTimeSeconds(unixTimeStamp).DateTime; - - int storedChecksum = Convert.ToInt32(Encoding.ASCII.GetString(_buffer, 148, 6)); - RecalculateChecksum(_buffer); - if (storedChecksum == _headerChecksum) - return true; - - RecalculateAltChecksum(_buffer); - return storedChecksum == _headerChecksum; - } - - private void RecalculateAltChecksum(byte[] buf) - { - _spaces.CopyTo(buf, 148); - _headerChecksum = 0; - foreach (byte b in buf) - { - if ((b & 0x80) == 0x80) - { - _headerChecksum -= b ^ 0x80; - } - else - { - _headerChecksum += b; - } - } - } - - public virtual byte[] GetHeaderValue() - { - // Clean old values - Array.Clear(_buffer, 0, _buffer.Length); - - if (string.IsNullOrEmpty(FileName)) - throw new TarException("FileName can not be empty."); - - if (FileName.Length >= 100) - throw new TarException("FileName is too long. It must be less than 100 bytes."); - - // Fill header - Encoding.ASCII.GetBytes(FileName.PadRight(100, '\0')).CopyTo(_buffer, 0); - Encoding.ASCII.GetBytes(ModeString).CopyTo(_buffer, 100); - Encoding.ASCII.GetBytes(UserIdString).CopyTo(_buffer, 108); - Encoding.ASCII.GetBytes(GroupIdString).CopyTo(_buffer, 116); - Encoding.ASCII.GetBytes(SizeString).CopyTo(_buffer, 124); - Encoding.ASCII.GetBytes(LastModificationString).CopyTo(_buffer, 136); - - // buffer[156] = 20; - _buffer[156] = ((byte)EntryType); - - RecalculateChecksum(_buffer); - - // Write checksum - Encoding.ASCII.GetBytes(HeaderChecksumString).CopyTo(_buffer, 148); - - return _buffer; - } - - protected virtual void RecalculateChecksum(byte[] buf) - { - // Set default value for checksum. That is 8 spaces. - _spaces.CopyTo(buf, 148); - - // Calculate checksum - _headerChecksum = 0; - foreach (byte b in buf) - _headerChecksum += b; - } - } -} diff --git a/AMWD.Common/Packing/Tar/Utils/UsTarHeader.cs b/AMWD.Common/Packing/Tar/Utils/UsTarHeader.cs deleted file mode 100644 index 4f26bf3..0000000 --- a/AMWD.Common/Packing/Tar/Utils/UsTarHeader.cs +++ /dev/null @@ -1,127 +0,0 @@ -using System; -using System.Net; -using System.Text; - -namespace AMWD.Common.Packing.Tar.Utils -{ - /// - /// UsTar header implementation. - /// - internal class UsTarHeader : TarHeader - { - private const string Magic = "ustar"; - private const string Version = " "; - - private string _groupName; - - private string _namePrefix = string.Empty; - private string _userName; - - public override string UserName - { - get => _userName.Replace("\0", string.Empty); - set - { - if (value.Length > 32) - throw new TarException("user name can not be longer than 32 chars"); - - _userName = value; - } - } - - public override string GroupName - { - get => _groupName.Replace("\0", string.Empty); - set - { - if (value.Length > 32) - throw new TarException("group name can not be longer than 32 chars"); - - _groupName = value; - } - } - - public override string FileName - { - get => _namePrefix.Replace("\0", string.Empty) + base.FileName.Replace("\0", string.Empty); - set - { - if (value.Length > 100) - { - if (value.Length > 255) - throw new TarException("UsTar fileName can not be longer thatn 255 chars"); - - int position = value.Length - 100; - - // Find first path separator in the remaining 100 chars of the file name - while (!IsPathSeparator(value[position])) - { - ++position; - if (position == value.Length) - { - break; - } - } - if (position == value.Length) - position = value.Length - 100; - _namePrefix = value.Substring(0, position); - - base.FileName = value.Substring(position, value.Length - position); - } - else - { - base.FileName = value; - } - } - } - - public override bool UpdateHeaderFromBytes() - { - byte[] bytes = GetBytes(); - - UserName = Encoding.ASCII.GetString(bytes, 0x109, 32); - GroupName = Encoding.ASCII.GetString(bytes, 0x129, 32); - _namePrefix = Encoding.ASCII.GetString(bytes, 347, 157); - - return base.UpdateHeaderFromBytes(); - } - - internal static bool IsPathSeparator(char ch) - => ch == '\\' || ch == '/' || ch == '|'; // All the path separators I ever met. - - public override byte[] GetHeaderValue() - { - byte[] header = base.GetHeaderValue(); - - Encoding.ASCII.GetBytes(Magic).CopyTo(header, 0x101); // Mark header as ustar - Encoding.ASCII.GetBytes(Version).CopyTo(header, 0x106); - Encoding.ASCII.GetBytes(UserName).CopyTo(header, 0x109); - Encoding.ASCII.GetBytes(GroupName).CopyTo(header, 0x129); - Encoding.ASCII.GetBytes(_namePrefix).CopyTo(header, 347); - - if (SizeInBytes >= 0x1FFFFFFFF) - { - byte[] bytes = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(SizeInBytes)); - SetMarker(AlignTo12(bytes)).CopyTo(header, 124); - } - - RecalculateChecksum(header); - Encoding.ASCII.GetBytes(HeaderChecksumString).CopyTo(header, 148); - - return header; - } - - private static byte[] SetMarker(byte[] bytes) - { - bytes[0] |= 0x80; - return bytes; - } - - private static byte[] AlignTo12(byte[] bytes) - { - byte[] retVal = new byte[12]; - bytes.CopyTo(retVal, 12 - bytes.Length); - return retVal; - } - } -} diff --git a/CHANGELOG.md b/CHANGELOG.md index b9ff10d..4638b9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to this project will be documented in this file. -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Upcoming - 0000-00-00 @@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Solution restructured to use multiple test projects - Optimized for C# 12 - `IPNetwork` is used from (as `Microsoft.AspNetCore.HttpOverrides` is tagged as "out of support"): - .NET Standard 2.0 and .NET 6.0: `Microsoft.AspNetCore.HttpOverrides.IPNetwork` diff --git a/Common.sln b/Common.sln index c1d89ff..eb68539 100644 --- a/Common.sln +++ b/Common.sln @@ -3,23 +3,31 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AMWD.Common", "AMWD.Common\AMWD.Common.csproj", "{F512C474-B670-4E47-911E-7C0674AA8E7E}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F2C7556A-99EB-43EB-8954-56A24AFE928F}" + ProjectSection(SolutionItems) = preProject + src\Directory.Build.props = src\Directory.Build.props + EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AMWD.Common.AspNetCore", "AMWD.Common.AspNetCore\AMWD.Common.AspNetCore.csproj", "{725F40C9-8172-487F-B3D0-D7E38B4DB197}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{E5DF156A-6C8B-4004-BA4C-A8DDE6FD3ECD}" + ProjectSection(SolutionItems) = preProject + test\Directory.Build.props = test\Directory.Build.props + EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AMWD.Common.EntityFrameworkCore", "AMWD.Common.EntityFrameworkCore\AMWD.Common.EntityFrameworkCore.csproj", "{7091CECF-C981-4FB9-9CC6-91C4E65A6356}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AMWD.Common", "src\AMWD.Common\AMWD.Common.csproj", "{F512C474-B670-4E47-911E-7C0674AA8E7E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AMWD.Common.AspNetCore", "src\AMWD.Common.AspNetCore\AMWD.Common.AspNetCore.csproj", "{725F40C9-8172-487F-B3D0-D7E38B4DB197}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AMWD.Common.EntityFrameworkCore", "src\AMWD.Common.EntityFrameworkCore\AMWD.Common.EntityFrameworkCore.csproj", "{7091CECF-C981-4FB9-9CC6-91C4E65A6356}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AMWD.Common.MessagePack", "src\AMWD.Common.MessagePack\AMWD.Common.MessagePack.csproj", "{EA014C15-93B6-4F2C-8229-1C13E22BF84A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AMWD.Common.Test", "src\AMWD.Common.Test\AMWD.Common.Test.csproj", "{6EBA2792-0B66-4C90-89A1-4E1D26D16443}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AMWD.Common.Tests", "test\AMWD.Common.Tests\AMWD.Common.Tests.csproj", "{9469D87B-126E-4338-92E3-701F762CB54D}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AFBF83AE-FE7D-48C1-B7E7-31BF3E17C6FB}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F2C7556A-99EB-43EB-8954-56A24AFE928F}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{E5DF156A-6C8B-4004-BA4C-A8DDE6FD3ECD}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AMWD.Common.Test", "AMWD.Common.Test\AMWD.Common.Test.csproj", "{6EBA2792-0B66-4C90-89A1-4E1D26D16443}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests", "UnitTests\UnitTests.csproj", "{9469D87B-126E-4338-92E3-701F762CB54D}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docs", "Docs", "{86DE1B7C-3ECF-49B1-AB28-A976A3973FF5}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{86DE1B7C-3ECF-49B1-AB28-A976A3973FF5}" ProjectSection(SolutionItems) = preProject CHANGELOG.md = CHANGELOG.md icon.png = icon.png @@ -27,13 +35,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docs", "Docs", "{86DE1B7C-3 README.md = README.md EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{7196DA2B-D858-4B25-BC23-865175CFCDEC}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{7196DA2B-D858-4B25-BC23-865175CFCDEC}" ProjectSection(SolutionItems) = preProject .gitlab-ci.yml = .gitlab-ci.yml directory.build.props = directory.build.props EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Utils", "Utils", "{93EC8B16-7DEF-4E39-B590-E804DEF7C607}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "config", "config", "{93EC8B16-7DEF-4E39-B590-E804DEF7C607}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig .gitignore = .gitignore @@ -41,7 +49,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Utils", "Utils", "{93EC8B16 nuget.config = nuget.config EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AMWD.Common.MessagePack", "AMWD.Common.MessagePack\AMWD.Common.MessagePack.csproj", "{EA014C15-93B6-4F2C-8229-1C13E22BF84A}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AMWD.Common.AspNetCore.Tests", "test\AMWD.Common.AspNetCore.Tests\AMWD.Common.AspNetCore.Tests.csproj", "{2CDA58C2-DE85-478D-9474-A937A20BECD1}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -61,6 +69,10 @@ Global {7091CECF-C981-4FB9-9CC6-91C4E65A6356}.Debug|Any CPU.Build.0 = Debug|Any CPU {7091CECF-C981-4FB9-9CC6-91C4E65A6356}.Release|Any CPU.ActiveCfg = Release|Any CPU {7091CECF-C981-4FB9-9CC6-91C4E65A6356}.Release|Any CPU.Build.0 = Release|Any CPU + {EA014C15-93B6-4F2C-8229-1C13E22BF84A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EA014C15-93B6-4F2C-8229-1C13E22BF84A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EA014C15-93B6-4F2C-8229-1C13E22BF84A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EA014C15-93B6-4F2C-8229-1C13E22BF84A}.Release|Any CPU.Build.0 = Release|Any CPU {6EBA2792-0B66-4C90-89A1-4E1D26D16443}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6EBA2792-0B66-4C90-89A1-4E1D26D16443}.Debug|Any CPU.Build.0 = Debug|Any CPU {6EBA2792-0B66-4C90-89A1-4E1D26D16443}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -69,10 +81,10 @@ Global {9469D87B-126E-4338-92E3-701F762CB54D}.Debug|Any CPU.Build.0 = Debug|Any CPU {9469D87B-126E-4338-92E3-701F762CB54D}.Release|Any CPU.ActiveCfg = Release|Any CPU {9469D87B-126E-4338-92E3-701F762CB54D}.Release|Any CPU.Build.0 = Release|Any CPU - {EA014C15-93B6-4F2C-8229-1C13E22BF84A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EA014C15-93B6-4F2C-8229-1C13E22BF84A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EA014C15-93B6-4F2C-8229-1C13E22BF84A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EA014C15-93B6-4F2C-8229-1C13E22BF84A}.Release|Any CPU.Build.0 = Release|Any CPU + {2CDA58C2-DE85-478D-9474-A937A20BECD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2CDA58C2-DE85-478D-9474-A937A20BECD1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2CDA58C2-DE85-478D-9474-A937A20BECD1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2CDA58C2-DE85-478D-9474-A937A20BECD1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -81,12 +93,13 @@ Global {F512C474-B670-4E47-911E-7C0674AA8E7E} = {F2C7556A-99EB-43EB-8954-56A24AFE928F} {725F40C9-8172-487F-B3D0-D7E38B4DB197} = {F2C7556A-99EB-43EB-8954-56A24AFE928F} {7091CECF-C981-4FB9-9CC6-91C4E65A6356} = {F2C7556A-99EB-43EB-8954-56A24AFE928F} + {EA014C15-93B6-4F2C-8229-1C13E22BF84A} = {F2C7556A-99EB-43EB-8954-56A24AFE928F} {6EBA2792-0B66-4C90-89A1-4E1D26D16443} = {F2C7556A-99EB-43EB-8954-56A24AFE928F} {9469D87B-126E-4338-92E3-701F762CB54D} = {E5DF156A-6C8B-4004-BA4C-A8DDE6FD3ECD} {86DE1B7C-3ECF-49B1-AB28-A976A3973FF5} = {AFBF83AE-FE7D-48C1-B7E7-31BF3E17C6FB} {7196DA2B-D858-4B25-BC23-865175CFCDEC} = {AFBF83AE-FE7D-48C1-B7E7-31BF3E17C6FB} {93EC8B16-7DEF-4E39-B590-E804DEF7C607} = {AFBF83AE-FE7D-48C1-B7E7-31BF3E17C6FB} - {EA014C15-93B6-4F2C-8229-1C13E22BF84A} = {F2C7556A-99EB-43EB-8954-56A24AFE928F} + {2CDA58C2-DE85-478D-9474-A937A20BECD1} = {E5DF156A-6C8B-4004-BA4C-A8DDE6FD3ECD} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {961E8DF8-DDF5-4D10-A510-CE409E9962AC} diff --git a/Directory.Build.props b/Directory.Build.props index 553ca7c..8665a0f 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,41 +1,11 @@ - {semvertag:main}{!:-dev} + 12.0 true false - true - - true - snupkg - false - - https://wiki.am-wd.de/libs/common - Library with classes and extensions used frequently on AM.WD projects. - - git - https://git.am-wd.de/AM.WD/common.git - true AM.WD Andreas Müller - © {copyright:2020-} AM.WD - MIT - - - true - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - diff --git a/README.md b/README.md index b8c7d1f..c583682 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ To save time, they are all packed to NuGet packages. | AMWD.Common.EntityFrameworkCore | ![https://nuget.am-wd.de/packages/amwd.common.entityframeworkcore/](https://services.am-wd.de/nuget.php?package=AMWD.Common.EntityFrameworkCore) | | AMWD.Common.MessagePack | ![https://nuget.am-wd.de/packages/amwd.common.messagepack/](https://services.am-wd.de/nuget.php?package=AMWD.Common.MessagePack) | | AMWD.Common.Test | ![https://nuget.am-wd.de/packages/amwd.common.test/](https://services.am-wd.de/nuget.php?package=AMWD.Common.Test) | -| CI / CD | ![https://git.am-wd.de/AM.WD/common/-/pipelines](https://git.am-wd.de/AM.WD/common/badges/main/pipeline.svg?style=flat-square) ![https://git.am-wd.de/AM.WD/common/-/tree/main](https://git.am-wd.de/AM.WD/common/badges/main/coverage.svg?style=flat-square) | +| CI / CD | ![https://git.am-wd.de/am-wd/common/-/pipelines](https://git.am-wd.de/am-wd/common/badges/main/pipeline.svg?style=flat-square) ![https://git.am-wd.de/am-wd/common/-/tree/main](https://git.am-wd.de/am-wd/common/badges/main/coverage.svg?style=flat-square) | ## Documentation diff --git a/UnitTests/Common/Packing/Tar/TarReaderTests.cs b/UnitTests/Common/Packing/Tar/TarReaderTests.cs deleted file mode 100644 index 3e5abc7..0000000 --- a/UnitTests/Common/Packing/Tar/TarReaderTests.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace UnitTests.Common.Packing.Tar -{ - internal class TarReaderTests - { - } -} diff --git a/UnitTests/UnitTests.csproj b/UnitTests/UnitTests.csproj deleted file mode 100644 index aed5779..0000000 --- a/UnitTests/UnitTests.csproj +++ /dev/null @@ -1,29 +0,0 @@ - - - - net8.0 - 12.0 - false - true - false - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - - diff --git a/AMWD.Common.AspNetCore/AMWD.Common.AspNetCore.csproj b/src/AMWD.Common.AspNetCore/AMWD.Common.AspNetCore.csproj similarity index 57% rename from AMWD.Common.AspNetCore/AMWD.Common.AspNetCore.csproj rename to src/AMWD.Common.AspNetCore/AMWD.Common.AspNetCore.csproj index 7cece0b..689c55c 100644 --- a/AMWD.Common.AspNetCore/AMWD.Common.AspNetCore.csproj +++ b/src/AMWD.Common.AspNetCore/AMWD.Common.AspNetCore.csproj @@ -2,25 +2,15 @@ net6.0;net8.0 - 12.0 - asp/v[0-9]* - AMWD.Common.AspNetCore + amwd-common-aspnetcore AMWD.Common.AspNetCore - true + asp/v[0-9]* AMWD.Common.AspNetCore - icon.png - README.md - AM.WD Common Library for ASP.NET Core - - - - - diff --git a/AMWD.Common.AspNetCore/Attributes/BasicAuthenticationAttribute.cs b/src/AMWD.Common.AspNetCore/Attributes/BasicAuthenticationAttribute.cs similarity index 100% rename from AMWD.Common.AspNetCore/Attributes/BasicAuthenticationAttribute.cs rename to src/AMWD.Common.AspNetCore/Attributes/BasicAuthenticationAttribute.cs diff --git a/AMWD.Common.AspNetCore/Attributes/GoogleReCaptchaAttribute.cs b/src/AMWD.Common.AspNetCore/Attributes/GoogleReCaptchaAttribute.cs similarity index 100% rename from AMWD.Common.AspNetCore/Attributes/GoogleReCaptchaAttribute.cs rename to src/AMWD.Common.AspNetCore/Attributes/GoogleReCaptchaAttribute.cs diff --git a/AMWD.Common.AspNetCore/Attributes/IPAllowListAttribute.cs b/src/AMWD.Common.AspNetCore/Attributes/IPAllowListAttribute.cs similarity index 100% rename from AMWD.Common.AspNetCore/Attributes/IPAllowListAttribute.cs rename to src/AMWD.Common.AspNetCore/Attributes/IPAllowListAttribute.cs diff --git a/AMWD.Common.AspNetCore/Attributes/IPBlockListAttribute.cs b/src/AMWD.Common.AspNetCore/Attributes/IPBlockListAttribute.cs similarity index 100% rename from AMWD.Common.AspNetCore/Attributes/IPBlockListAttribute.cs rename to src/AMWD.Common.AspNetCore/Attributes/IPBlockListAttribute.cs diff --git a/AMWD.Common.AspNetCore/Extensions/ApplicationBuilderExtensions.cs b/src/AMWD.Common.AspNetCore/Extensions/ApplicationBuilderExtensions.cs similarity index 100% rename from AMWD.Common.AspNetCore/Extensions/ApplicationBuilderExtensions.cs rename to src/AMWD.Common.AspNetCore/Extensions/ApplicationBuilderExtensions.cs diff --git a/AMWD.Common.AspNetCore/Extensions/HtmlExtensions.cs b/src/AMWD.Common.AspNetCore/Extensions/HtmlExtensions.cs similarity index 100% rename from AMWD.Common.AspNetCore/Extensions/HtmlExtensions.cs rename to src/AMWD.Common.AspNetCore/Extensions/HtmlExtensions.cs diff --git a/AMWD.Common.AspNetCore/Extensions/HttpContextExtensions.cs b/src/AMWD.Common.AspNetCore/Extensions/HttpContextExtensions.cs similarity index 100% rename from AMWD.Common.AspNetCore/Extensions/HttpContextExtensions.cs rename to src/AMWD.Common.AspNetCore/Extensions/HttpContextExtensions.cs diff --git a/AMWD.Common.AspNetCore/Extensions/LoggerExtensions.cs b/src/AMWD.Common.AspNetCore/Extensions/LoggerExtensions.cs similarity index 100% rename from AMWD.Common.AspNetCore/Extensions/LoggerExtensions.cs rename to src/AMWD.Common.AspNetCore/Extensions/LoggerExtensions.cs diff --git a/AMWD.Common.AspNetCore/Extensions/ModelStateDictionaryExtensions.cs b/src/AMWD.Common.AspNetCore/Extensions/ModelStateDictionaryExtensions.cs similarity index 100% rename from AMWD.Common.AspNetCore/Extensions/ModelStateDictionaryExtensions.cs rename to src/AMWD.Common.AspNetCore/Extensions/ModelStateDictionaryExtensions.cs diff --git a/AMWD.Common.AspNetCore/Extensions/ServiceCollectionExtensions.cs b/src/AMWD.Common.AspNetCore/Extensions/ServiceCollectionExtensions.cs similarity index 100% rename from AMWD.Common.AspNetCore/Extensions/ServiceCollectionExtensions.cs rename to src/AMWD.Common.AspNetCore/Extensions/ServiceCollectionExtensions.cs diff --git a/AMWD.Common.AspNetCore/Extensions/SessionExtensions.cs b/src/AMWD.Common.AspNetCore/Extensions/SessionExtensions.cs similarity index 100% rename from AMWD.Common.AspNetCore/Extensions/SessionExtensions.cs rename to src/AMWD.Common.AspNetCore/Extensions/SessionExtensions.cs diff --git a/AMWD.Common.AspNetCore/ModelBinders/InvariantFloatingPointModelBinder.cs b/src/AMWD.Common.AspNetCore/ModelBinders/InvariantFloatingPointModelBinder.cs similarity index 100% rename from AMWD.Common.AspNetCore/ModelBinders/InvariantFloatingPointModelBinder.cs rename to src/AMWD.Common.AspNetCore/ModelBinders/InvariantFloatingPointModelBinder.cs diff --git a/AMWD.Common.AspNetCore/ModelBinders/InvariantFloatingPointModelBinderProvider.cs b/src/AMWD.Common.AspNetCore/ModelBinders/InvariantFloatingPointModelBinderProvider.cs similarity index 100% rename from AMWD.Common.AspNetCore/ModelBinders/InvariantFloatingPointModelBinderProvider.cs rename to src/AMWD.Common.AspNetCore/ModelBinders/InvariantFloatingPointModelBinderProvider.cs diff --git a/AMWD.Common.AspNetCore/Security/BasicAuthentication/BasicAuthenticationHandler.cs b/src/AMWD.Common.AspNetCore/Security/BasicAuthentication/BasicAuthenticationHandler.cs similarity index 100% rename from AMWD.Common.AspNetCore/Security/BasicAuthentication/BasicAuthenticationHandler.cs rename to src/AMWD.Common.AspNetCore/Security/BasicAuthentication/BasicAuthenticationHandler.cs diff --git a/AMWD.Common.AspNetCore/Security/BasicAuthentication/BasicAuthenticationMiddleware.cs b/src/AMWD.Common.AspNetCore/Security/BasicAuthentication/BasicAuthenticationMiddleware.cs similarity index 100% rename from AMWD.Common.AspNetCore/Security/BasicAuthentication/BasicAuthenticationMiddleware.cs rename to src/AMWD.Common.AspNetCore/Security/BasicAuthentication/BasicAuthenticationMiddleware.cs diff --git a/AMWD.Common.AspNetCore/Security/BasicAuthentication/IBasicAuthenticationValidator.cs b/src/AMWD.Common.AspNetCore/Security/BasicAuthentication/IBasicAuthenticationValidator.cs similarity index 100% rename from AMWD.Common.AspNetCore/Security/BasicAuthentication/IBasicAuthenticationValidator.cs rename to src/AMWD.Common.AspNetCore/Security/BasicAuthentication/IBasicAuthenticationValidator.cs diff --git a/AMWD.Common.AspNetCore/Security/PathProtection/ProtectedPathExtensions.cs b/src/AMWD.Common.AspNetCore/Security/PathProtection/ProtectedPathExtensions.cs similarity index 100% rename from AMWD.Common.AspNetCore/Security/PathProtection/ProtectedPathExtensions.cs rename to src/AMWD.Common.AspNetCore/Security/PathProtection/ProtectedPathExtensions.cs diff --git a/AMWD.Common.AspNetCore/Security/PathProtection/ProtectedPathMiddleware.cs b/src/AMWD.Common.AspNetCore/Security/PathProtection/ProtectedPathMiddleware.cs similarity index 100% rename from AMWD.Common.AspNetCore/Security/PathProtection/ProtectedPathMiddleware.cs rename to src/AMWD.Common.AspNetCore/Security/PathProtection/ProtectedPathMiddleware.cs diff --git a/AMWD.Common.AspNetCore/Security/PathProtection/ProtectedPathOptions.cs b/src/AMWD.Common.AspNetCore/Security/PathProtection/ProtectedPathOptions.cs similarity index 100% rename from AMWD.Common.AspNetCore/Security/PathProtection/ProtectedPathOptions.cs rename to src/AMWD.Common.AspNetCore/Security/PathProtection/ProtectedPathOptions.cs diff --git a/AMWD.Common.AspNetCore/TagHelpers/ConditionClassTagHelper.cs b/src/AMWD.Common.AspNetCore/TagHelpers/ConditionClassTagHelper.cs similarity index 100% rename from AMWD.Common.AspNetCore/TagHelpers/ConditionClassTagHelper.cs rename to src/AMWD.Common.AspNetCore/TagHelpers/ConditionClassTagHelper.cs diff --git a/AMWD.Common.AspNetCore/TagHelpers/EmailTagHelper.cs b/src/AMWD.Common.AspNetCore/TagHelpers/EmailTagHelper.cs similarity index 100% rename from AMWD.Common.AspNetCore/TagHelpers/EmailTagHelper.cs rename to src/AMWD.Common.AspNetCore/TagHelpers/EmailTagHelper.cs diff --git a/AMWD.Common.AspNetCore/TagHelpers/IntegrityHashTagHelper.cs b/src/AMWD.Common.AspNetCore/TagHelpers/IntegrityHashTagHelper.cs similarity index 100% rename from AMWD.Common.AspNetCore/TagHelpers/IntegrityHashTagHelper.cs rename to src/AMWD.Common.AspNetCore/TagHelpers/IntegrityHashTagHelper.cs diff --git a/AMWD.Common.AspNetCore/TagHelpers/NumberInputTagHelper.cs b/src/AMWD.Common.AspNetCore/TagHelpers/NumberInputTagHelper.cs similarity index 100% rename from AMWD.Common.AspNetCore/TagHelpers/NumberInputTagHelper.cs rename to src/AMWD.Common.AspNetCore/TagHelpers/NumberInputTagHelper.cs diff --git a/AMWD.Common.AspNetCore/Utilities/HtmlHelper.cs b/src/AMWD.Common.AspNetCore/Utilities/HtmlHelper.cs similarity index 100% rename from AMWD.Common.AspNetCore/Utilities/HtmlHelper.cs rename to src/AMWD.Common.AspNetCore/Utilities/HtmlHelper.cs diff --git a/AMWD.Common.AspNetCore/Utilities/PasswordHelper.cs b/src/AMWD.Common.AspNetCore/Utilities/PasswordHelper.cs similarity index 100% rename from AMWD.Common.AspNetCore/Utilities/PasswordHelper.cs rename to src/AMWD.Common.AspNetCore/Utilities/PasswordHelper.cs diff --git a/AMWD.Common.EntityFrameworkCore/AMWD.Common.EntityFrameworkCore.csproj b/src/AMWD.Common.EntityFrameworkCore/AMWD.Common.EntityFrameworkCore.csproj similarity index 73% rename from AMWD.Common.EntityFrameworkCore/AMWD.Common.EntityFrameworkCore.csproj rename to src/AMWD.Common.EntityFrameworkCore/AMWD.Common.EntityFrameworkCore.csproj index a85eb4e..b07b8ad 100644 --- a/AMWD.Common.EntityFrameworkCore/AMWD.Common.EntityFrameworkCore.csproj +++ b/src/AMWD.Common.EntityFrameworkCore/AMWD.Common.EntityFrameworkCore.csproj @@ -2,25 +2,15 @@ net6.0;net8.0 - 12.0 - efc/v[0-9]* - AMWD.Common.EntityFrameworkCore + amwd-common-efcore AMWD.Common.EntityFrameworkCore - true + efc/v[0-9]* AMWD.Common.EntityFrameworkCore - icon.png - README.md - AM.WD Common Library for EntityFramework Core - - - - - diff --git a/AMWD.Common.EntityFrameworkCore/Attributes/DatabaseIndexAttribute.cs b/src/AMWD.Common.EntityFrameworkCore/Attributes/DatabaseIndexAttribute.cs similarity index 100% rename from AMWD.Common.EntityFrameworkCore/Attributes/DatabaseIndexAttribute.cs rename to src/AMWD.Common.EntityFrameworkCore/Attributes/DatabaseIndexAttribute.cs diff --git a/AMWD.Common.EntityFrameworkCore/Converters/DateOnlyConverter.cs b/src/AMWD.Common.EntityFrameworkCore/Converters/DateOnlyConverter.cs similarity index 100% rename from AMWD.Common.EntityFrameworkCore/Converters/DateOnlyConverter.cs rename to src/AMWD.Common.EntityFrameworkCore/Converters/DateOnlyConverter.cs diff --git a/AMWD.Common.EntityFrameworkCore/Converters/NullableDateOnlyConverter.cs b/src/AMWD.Common.EntityFrameworkCore/Converters/NullableDateOnlyConverter.cs similarity index 100% rename from AMWD.Common.EntityFrameworkCore/Converters/NullableDateOnlyConverter.cs rename to src/AMWD.Common.EntityFrameworkCore/Converters/NullableDateOnlyConverter.cs diff --git a/AMWD.Common.EntityFrameworkCore/Converters/NullableTimeOnlyConverter.cs b/src/AMWD.Common.EntityFrameworkCore/Converters/NullableTimeOnlyConverter.cs similarity index 100% rename from AMWD.Common.EntityFrameworkCore/Converters/NullableTimeOnlyConverter.cs rename to src/AMWD.Common.EntityFrameworkCore/Converters/NullableTimeOnlyConverter.cs diff --git a/AMWD.Common.EntityFrameworkCore/Converters/TimeOnlyConverter.cs b/src/AMWD.Common.EntityFrameworkCore/Converters/TimeOnlyConverter.cs similarity index 100% rename from AMWD.Common.EntityFrameworkCore/Converters/TimeOnlyConverter.cs rename to src/AMWD.Common.EntityFrameworkCore/Converters/TimeOnlyConverter.cs diff --git a/AMWD.Common.EntityFrameworkCore/Exceptions/DatabaseProviderException.cs b/src/AMWD.Common.EntityFrameworkCore/Exceptions/DatabaseProviderException.cs similarity index 100% rename from AMWD.Common.EntityFrameworkCore/Exceptions/DatabaseProviderException.cs rename to src/AMWD.Common.EntityFrameworkCore/Exceptions/DatabaseProviderException.cs diff --git a/AMWD.Common.EntityFrameworkCore/Extensions/DatabaseFacadeExtensions.cs b/src/AMWD.Common.EntityFrameworkCore/Extensions/DatabaseFacadeExtensions.cs similarity index 100% rename from AMWD.Common.EntityFrameworkCore/Extensions/DatabaseFacadeExtensions.cs rename to src/AMWD.Common.EntityFrameworkCore/Extensions/DatabaseFacadeExtensions.cs diff --git a/AMWD.Common.EntityFrameworkCore/Extensions/DbContextExensions.cs b/src/AMWD.Common.EntityFrameworkCore/Extensions/DbContextExensions.cs similarity index 100% rename from AMWD.Common.EntityFrameworkCore/Extensions/DbContextExensions.cs rename to src/AMWD.Common.EntityFrameworkCore/Extensions/DbContextExensions.cs diff --git a/AMWD.Common.EntityFrameworkCore/Extensions/DbContextOptionsBuilderExtensions.cs b/src/AMWD.Common.EntityFrameworkCore/Extensions/DbContextOptionsBuilderExtensions.cs similarity index 100% rename from AMWD.Common.EntityFrameworkCore/Extensions/DbContextOptionsBuilderExtensions.cs rename to src/AMWD.Common.EntityFrameworkCore/Extensions/DbContextOptionsBuilderExtensions.cs diff --git a/AMWD.Common.EntityFrameworkCore/Extensions/ModelBuilderExtensions.cs b/src/AMWD.Common.EntityFrameworkCore/Extensions/ModelBuilderExtensions.cs similarity index 100% rename from AMWD.Common.EntityFrameworkCore/Extensions/ModelBuilderExtensions.cs rename to src/AMWD.Common.EntityFrameworkCore/Extensions/ModelBuilderExtensions.cs diff --git a/AMWD.Common.EntityFrameworkCore/Extensions/ModelConfigurationBuilderExtensions.cs b/src/AMWD.Common.EntityFrameworkCore/Extensions/ModelConfigurationBuilderExtensions.cs similarity index 100% rename from AMWD.Common.EntityFrameworkCore/Extensions/ModelConfigurationBuilderExtensions.cs rename to src/AMWD.Common.EntityFrameworkCore/Extensions/ModelConfigurationBuilderExtensions.cs diff --git a/AMWD.Common.EntityFrameworkCore/GlobalSuppressions.cs b/src/AMWD.Common.EntityFrameworkCore/GlobalSuppressions.cs similarity index 100% rename from AMWD.Common.EntityFrameworkCore/GlobalSuppressions.cs rename to src/AMWD.Common.EntityFrameworkCore/GlobalSuppressions.cs diff --git a/AMWD.Common.EntityFrameworkCore/Utilities/DatabaseMigrationOptions.cs b/src/AMWD.Common.EntityFrameworkCore/Utilities/DatabaseMigrationOptions.cs similarity index 100% rename from AMWD.Common.EntityFrameworkCore/Utilities/DatabaseMigrationOptions.cs rename to src/AMWD.Common.EntityFrameworkCore/Utilities/DatabaseMigrationOptions.cs diff --git a/AMWD.Common.EntityFrameworkCore/Utilities/DatabaseProviderOptions.cs b/src/AMWD.Common.EntityFrameworkCore/Utilities/DatabaseProviderOptions.cs similarity index 100% rename from AMWD.Common.EntityFrameworkCore/Utilities/DatabaseProviderOptions.cs rename to src/AMWD.Common.EntityFrameworkCore/Utilities/DatabaseProviderOptions.cs diff --git a/AMWD.Common.MessagePack/AMWD.Common.MessagePack.csproj b/src/AMWD.Common.MessagePack/AMWD.Common.MessagePack.csproj similarity index 53% rename from AMWD.Common.MessagePack/AMWD.Common.MessagePack.csproj rename to src/AMWD.Common.MessagePack/AMWD.Common.MessagePack.csproj index 986d0c6..39bf8b2 100644 --- a/AMWD.Common.MessagePack/AMWD.Common.MessagePack.csproj +++ b/src/AMWD.Common.MessagePack/AMWD.Common.MessagePack.csproj @@ -2,27 +2,17 @@ netstandard2.0;net6.0;net8.0 - 12.0 - msgpack/v[0-9]* - AMWD.Common.MessagePack + amwd-common-msgpack AMWD.Common.MessagePack - true + msgpack/v[0-9]* AMWD.Common.MessagePack - icon.png - README.md - AM.WD Common Library for MessagePack - - - - - - + diff --git a/AMWD.Common.MessagePack/Formatters/IPAddressArrayFormatter.cs b/src/AMWD.Common.MessagePack/Formatters/IPAddressArrayFormatter.cs similarity index 100% rename from AMWD.Common.MessagePack/Formatters/IPAddressArrayFormatter.cs rename to src/AMWD.Common.MessagePack/Formatters/IPAddressArrayFormatter.cs diff --git a/AMWD.Common.MessagePack/Formatters/IPAddressFormatter.cs b/src/AMWD.Common.MessagePack/Formatters/IPAddressFormatter.cs similarity index 100% rename from AMWD.Common.MessagePack/Formatters/IPAddressFormatter.cs rename to src/AMWD.Common.MessagePack/Formatters/IPAddressFormatter.cs diff --git a/AMWD.Common.MessagePack/Formatters/IPAddressListFormatter.cs b/src/AMWD.Common.MessagePack/Formatters/IPAddressListFormatter.cs similarity index 100% rename from AMWD.Common.MessagePack/Formatters/IPAddressListFormatter.cs rename to src/AMWD.Common.MessagePack/Formatters/IPAddressListFormatter.cs diff --git a/AMWD.Common.MessagePack/Formatters/IPNetworkArrayFormatter.cs b/src/AMWD.Common.MessagePack/Formatters/IPNetworkArrayFormatter.cs similarity index 100% rename from AMWD.Common.MessagePack/Formatters/IPNetworkArrayFormatter.cs rename to src/AMWD.Common.MessagePack/Formatters/IPNetworkArrayFormatter.cs diff --git a/AMWD.Common.MessagePack/Formatters/IPNetworkFormatter.cs b/src/AMWD.Common.MessagePack/Formatters/IPNetworkFormatter.cs similarity index 100% rename from AMWD.Common.MessagePack/Formatters/IPNetworkFormatter.cs rename to src/AMWD.Common.MessagePack/Formatters/IPNetworkFormatter.cs diff --git a/AMWD.Common.MessagePack/Formatters/IPNetworkListFormatter.cs b/src/AMWD.Common.MessagePack/Formatters/IPNetworkListFormatter.cs similarity index 100% rename from AMWD.Common.MessagePack/Formatters/IPNetworkListFormatter.cs rename to src/AMWD.Common.MessagePack/Formatters/IPNetworkListFormatter.cs diff --git a/AMWD.Common.MessagePack/Utilities/NetworkHelper.cs b/src/AMWD.Common.MessagePack/Utilities/NetworkHelper.cs similarity index 100% rename from AMWD.Common.MessagePack/Utilities/NetworkHelper.cs rename to src/AMWD.Common.MessagePack/Utilities/NetworkHelper.cs diff --git a/AMWD.Common.Test/AMWD.Common.Test.csproj b/src/AMWD.Common.Test/AMWD.Common.Test.csproj similarity index 53% rename from AMWD.Common.Test/AMWD.Common.Test.csproj rename to src/AMWD.Common.Test/AMWD.Common.Test.csproj index fcb3652..8bc807f 100644 --- a/AMWD.Common.Test/AMWD.Common.Test.csproj +++ b/src/AMWD.Common.Test/AMWD.Common.Test.csproj @@ -2,28 +2,18 @@ netstandard2.0 - 12.0 - test/v[0-9]* - AMWD.Common.Test + amwd-common-test AMWD.Common.Test - true + test/v[0-9]* AMWD.Common.Test - icon.png - README.md - AM.WD Common Library for Unit-Testing - - - - - - + diff --git a/AMWD.Common.Test/HttpMessageHandlerMoq.cs b/src/AMWD.Common.Test/HttpMessageHandlerMoq.cs similarity index 100% rename from AMWD.Common.Test/HttpMessageHandlerMoq.cs rename to src/AMWD.Common.Test/HttpMessageHandlerMoq.cs diff --git a/AMWD.Common.Test/SnapshotAssert.cs b/src/AMWD.Common.Test/SnapshotAssert.cs similarity index 100% rename from AMWD.Common.Test/SnapshotAssert.cs rename to src/AMWD.Common.Test/SnapshotAssert.cs diff --git a/AMWD.Common.Test/TcpClientMoq.cs b/src/AMWD.Common.Test/TcpClientMoq.cs similarity index 100% rename from AMWD.Common.Test/TcpClientMoq.cs rename to src/AMWD.Common.Test/TcpClientMoq.cs diff --git a/AMWD.Common/AMWD.Common.csproj b/src/AMWD.Common/AMWD.Common.csproj similarity index 67% rename from AMWD.Common/AMWD.Common.csproj rename to src/AMWD.Common/AMWD.Common.csproj index e37a629..f436227 100644 --- a/AMWD.Common/AMWD.Common.csproj +++ b/src/AMWD.Common/AMWD.Common.csproj @@ -2,24 +2,14 @@ netstandard2.0;net8.0 - 12.0 - AMWD.Common + amwd-common AMWD.Common - true AMWD.Common - icon.png - README.md - AM.WD Common Library - - - - - diff --git a/AMWD.Common/Cli/Argument.cs b/src/AMWD.Common/Cli/Argument.cs similarity index 100% rename from AMWD.Common/Cli/Argument.cs rename to src/AMWD.Common/Cli/Argument.cs diff --git a/AMWD.Common/Cli/CommandLineParser.cs b/src/AMWD.Common/Cli/CommandLineParser.cs similarity index 100% rename from AMWD.Common/Cli/CommandLineParser.cs rename to src/AMWD.Common/Cli/CommandLineParser.cs diff --git a/AMWD.Common/Cli/EnumerableWalker.cs b/src/AMWD.Common/Cli/EnumerableWalker.cs similarity index 100% rename from AMWD.Common/Cli/EnumerableWalker.cs rename to src/AMWD.Common/Cli/EnumerableWalker.cs diff --git a/AMWD.Common/Cli/Option.cs b/src/AMWD.Common/Cli/Option.cs similarity index 100% rename from AMWD.Common/Cli/Option.cs rename to src/AMWD.Common/Cli/Option.cs diff --git a/AMWD.Common/Comparer/DomainComparer.cs b/src/AMWD.Common/Comparer/DomainComparer.cs similarity index 100% rename from AMWD.Common/Comparer/DomainComparer.cs rename to src/AMWD.Common/Comparer/DomainComparer.cs diff --git a/AMWD.Common/Comparer/IPAddressComparer.cs b/src/AMWD.Common/Comparer/IPAddressComparer.cs similarity index 100% rename from AMWD.Common/Comparer/IPAddressComparer.cs rename to src/AMWD.Common/Comparer/IPAddressComparer.cs diff --git a/AMWD.Common/Comparer/VersionStringComparer.cs b/src/AMWD.Common/Comparer/VersionStringComparer.cs similarity index 100% rename from AMWD.Common/Comparer/VersionStringComparer.cs rename to src/AMWD.Common/Comparer/VersionStringComparer.cs diff --git a/AMWD.Common/Converters/ByteArrayHexConverter.cs b/src/AMWD.Common/Converters/ByteArrayHexConverter.cs similarity index 100% rename from AMWD.Common/Converters/ByteArrayHexConverter.cs rename to src/AMWD.Common/Converters/ByteArrayHexConverter.cs diff --git a/AMWD.Common/Converters/IPAddressConverter.cs b/src/AMWD.Common/Converters/IPAddressConverter.cs similarity index 100% rename from AMWD.Common/Converters/IPAddressConverter.cs rename to src/AMWD.Common/Converters/IPAddressConverter.cs diff --git a/AMWD.Common/Converters/IPNetworkConverter.cs b/src/AMWD.Common/Converters/IPNetworkConverter.cs similarity index 100% rename from AMWD.Common/Converters/IPNetworkConverter.cs rename to src/AMWD.Common/Converters/IPNetworkConverter.cs diff --git a/AMWD.Common/Extensions/CollectionExtensions.cs b/src/AMWD.Common/Extensions/CollectionExtensions.cs similarity index 100% rename from AMWD.Common/Extensions/CollectionExtensions.cs rename to src/AMWD.Common/Extensions/CollectionExtensions.cs diff --git a/AMWD.Common/Extensions/CryptographyHelperExtensions.cs b/src/AMWD.Common/Extensions/CryptographyHelperExtensions.cs similarity index 100% rename from AMWD.Common/Extensions/CryptographyHelperExtensions.cs rename to src/AMWD.Common/Extensions/CryptographyHelperExtensions.cs diff --git a/AMWD.Common/Extensions/DateTimeExtensions.cs b/src/AMWD.Common/Extensions/DateTimeExtensions.cs similarity index 100% rename from AMWD.Common/Extensions/DateTimeExtensions.cs rename to src/AMWD.Common/Extensions/DateTimeExtensions.cs diff --git a/AMWD.Common/Extensions/EnumExtensions.cs b/src/AMWD.Common/Extensions/EnumExtensions.cs similarity index 100% rename from AMWD.Common/Extensions/EnumExtensions.cs rename to src/AMWD.Common/Extensions/EnumExtensions.cs diff --git a/AMWD.Common/Extensions/ExceptionExtensions.cs b/src/AMWD.Common/Extensions/ExceptionExtensions.cs similarity index 100% rename from AMWD.Common/Extensions/ExceptionExtensions.cs rename to src/AMWD.Common/Extensions/ExceptionExtensions.cs diff --git a/AMWD.Common/Extensions/IPAddressExtensions.cs b/src/AMWD.Common/Extensions/IPAddressExtensions.cs similarity index 100% rename from AMWD.Common/Extensions/IPAddressExtensions.cs rename to src/AMWD.Common/Extensions/IPAddressExtensions.cs diff --git a/AMWD.Common/Extensions/JsonExtensions.cs b/src/AMWD.Common/Extensions/JsonExtensions.cs similarity index 100% rename from AMWD.Common/Extensions/JsonExtensions.cs rename to src/AMWD.Common/Extensions/JsonExtensions.cs diff --git a/AMWD.Common/Extensions/ReaderWriterLockSlimExtensions.cs b/src/AMWD.Common/Extensions/ReaderWriterLockSlimExtensions.cs similarity index 100% rename from AMWD.Common/Extensions/ReaderWriterLockSlimExtensions.cs rename to src/AMWD.Common/Extensions/ReaderWriterLockSlimExtensions.cs diff --git a/AMWD.Common/Extensions/ReflectionExtensions.cs b/src/AMWD.Common/Extensions/ReflectionExtensions.cs similarity index 100% rename from AMWD.Common/Extensions/ReflectionExtensions.cs rename to src/AMWD.Common/Extensions/ReflectionExtensions.cs diff --git a/AMWD.Common/Extensions/StreamExtensions.cs b/src/AMWD.Common/Extensions/StreamExtensions.cs similarity index 100% rename from AMWD.Common/Extensions/StreamExtensions.cs rename to src/AMWD.Common/Extensions/StreamExtensions.cs diff --git a/AMWD.Common/Extensions/StringExtensions.cs b/src/AMWD.Common/Extensions/StringExtensions.cs similarity index 87% rename from AMWD.Common/Extensions/StringExtensions.cs rename to src/AMWD.Common/Extensions/StringExtensions.cs index 7a7e802..bb50e3a 100644 --- a/AMWD.Common/Extensions/StringExtensions.cs +++ b/src/AMWD.Common/Extensions/StringExtensions.cs @@ -41,7 +41,7 @@ namespace System if (InvalidHexCharRegex().IsMatch(str)) yield break; #else - if (Regex.IsMatch(str, "[^0-9a-fA-F]")) + if (Regex.IsMatch(str, "[^0-9a-fA-F]", RegexOptions.Compiled)) yield break; #endif @@ -180,18 +180,30 @@ namespace System /// true when the email address is valid, other wise false. public static bool IsValidEmailAddress(this string emailAddress, IEnumerable nameservers) { + if (string.IsNullOrWhiteSpace(emailAddress)) + return false; + try { var mailAddress = new MailAddress(emailAddress); - bool isValid = mailAddress.Address == emailAddress; + if (mailAddress.Address != emailAddress) + return false; - if (isValid && nameservers?.Any() == true) +#if NET8_0_OR_GREATER + if (!ValidEmailRegex().IsMatch(emailAddress)) + return false; +#else + string emailRegex = @"^[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$"; + if (!Regex.IsMatch(emailAddress, emailRegex, RegexOptions.Compiled)) + return false; +#endif + + if (nameservers?.Any() == true) { var dnsClientType = Type.GetType("DNS.Client.DnsClient, DNS") ?? throw new DllNotFoundException("The DNS NuGet package is required: https://www.nuget.org/packages/DNS/7.0.0"); var recordTypeType = Type.GetType("DNS.Protocol.RecordType, DNS"); var resolveMethodInfo = dnsClientType.GetMethod("Resolve", [typeof(string), recordTypeType, typeof(CancellationToken)]); - bool exists = false; foreach (var nameserver in nameservers) { object dnsClient = Activator.CreateInstance(dnsClientType, [nameserver]); @@ -210,21 +222,13 @@ namespace System foreach (object item in (list as IEnumerable)) { int type = (int)item.GetType().GetProperty("Type").GetValue(item); - if (type == 15) - { - exists = true; - break; - } + if (type == 15) // MX found + return true; } - - if (exists) - break; } - - isValid &= exists; } - return isValid; + return true; } catch { @@ -244,8 +248,11 @@ namespace System => sb.Append(value).Append(newLine); #if NET8_0_OR_GREATER - [GeneratedRegex("[^0-9a-fA-F]")] + [GeneratedRegex("[^0-9a-fA-F]", RegexOptions.Compiled)] private static partial Regex InvalidHexCharRegex(); + + [GeneratedRegex(@"^[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", RegexOptions.Compiled)] + private static partial Regex ValidEmailRegex(); #endif } } diff --git a/src/AMWD.Common/InternalsVisibleTo.cs b/src/AMWD.Common/InternalsVisibleTo.cs new file mode 100644 index 0000000..6c9f07b --- /dev/null +++ b/src/AMWD.Common/InternalsVisibleTo.cs @@ -0,0 +1,4 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("AMWD.Common.Tests")] +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] diff --git a/AMWD.Common/Logging/FileLogger.cs b/src/AMWD.Common/Logging/FileLogger.cs similarity index 100% rename from AMWD.Common/Logging/FileLogger.cs rename to src/AMWD.Common/Logging/FileLogger.cs diff --git a/AMWD.Common/Logging/NullScope.cs b/src/AMWD.Common/Logging/NullScope.cs similarity index 100% rename from AMWD.Common/Logging/NullScope.cs rename to src/AMWD.Common/Logging/NullScope.cs diff --git a/AMWD.Common/Packing/Ar/ArFileInfo.cs b/src/AMWD.Common/Packing/Ar/ArFileInfo.cs similarity index 100% rename from AMWD.Common/Packing/Ar/ArFileInfo.cs rename to src/AMWD.Common/Packing/Ar/ArFileInfo.cs diff --git a/AMWD.Common/Packing/Ar/ArReader.cs b/src/AMWD.Common/Packing/Ar/ArReader.cs similarity index 95% rename from AMWD.Common/Packing/Ar/ArReader.cs rename to src/AMWD.Common/Packing/Ar/ArReader.cs index 28b2e41..821b3e6 100644 --- a/AMWD.Common/Packing/Ar/ArReader.cs +++ b/src/AMWD.Common/Packing/Ar/ArReader.cs @@ -14,7 +14,7 @@ namespace AMWD.Common.Packing.Ar // Source: http://en.wikipedia.org/wiki/Ar_%28Unix%29 private readonly Stream _inStream; - private readonly List _files = new(); + private readonly List _files = []; private readonly long _streamStartPosition; /// diff --git a/AMWD.Common/Packing/Ar/ArWriter.cs b/src/AMWD.Common/Packing/Ar/ArWriter.cs similarity index 92% rename from AMWD.Common/Packing/Ar/ArWriter.cs rename to src/AMWD.Common/Packing/Ar/ArWriter.cs index fbb948f..f1c6563 100644 --- a/AMWD.Common/Packing/Ar/ArWriter.cs +++ b/src/AMWD.Common/Packing/Ar/ArWriter.cs @@ -64,7 +64,7 @@ namespace AMWD.Common.Packing.Ar // Align to even offsets, pad with LF bytes if ((_outStream.Position % 2) != 0) { - byte[] bytes = new byte[] { 0x0A }; + byte[] bytes = [0x0A]; _outStream.Write(bytes, 0, 1); } } @@ -124,12 +124,12 @@ namespace AMWD.Common.Packing.Ar // File size in bytes if (fileSize < 0 || 10000000000 <= fileSize) - throw new ArgumentOutOfRangeException("Invalid file size."); // above 9.32 GB + throw new ArgumentOutOfRangeException(nameof(fileSize), "Invalid file size."); // above 9.32 GB WriteAsciiString(fileSize.ToString().PadRight(10, ' ')); // File magic - byte[] bytes = new byte[] { 0x60, 0x0A }; + byte[] bytes = [0x60, 0x0A]; _outStream.Write(bytes, 0, 2); } diff --git a/AMWD.Common/Utilities/AsyncQueue.cs b/src/AMWD.Common/Utilities/AsyncQueue.cs similarity index 100% rename from AMWD.Common/Utilities/AsyncQueue.cs rename to src/AMWD.Common/Utilities/AsyncQueue.cs diff --git a/AMWD.Common/Utilities/CryptographyHelper.cs b/src/AMWD.Common/Utilities/CryptographyHelper.cs similarity index 100% rename from AMWD.Common/Utilities/CryptographyHelper.cs rename to src/AMWD.Common/Utilities/CryptographyHelper.cs diff --git a/AMWD.Common/Utilities/DelayedTask.cs b/src/AMWD.Common/Utilities/DelayedTask.cs similarity index 100% rename from AMWD.Common/Utilities/DelayedTask.cs rename to src/AMWD.Common/Utilities/DelayedTask.cs diff --git a/AMWD.Common/Utilities/NetworkHelper.cs b/src/AMWD.Common/Utilities/NetworkHelper.cs similarity index 100% rename from AMWD.Common/Utilities/NetworkHelper.cs rename to src/AMWD.Common/Utilities/NetworkHelper.cs diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 0000000..21669d9 --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,48 @@ + + + {semvertag:main}{!:-dev} + true + + true + true + snupkg + false + + git + https://git.am-wd.de/am-wd/common.git + true + + icon.png + https://wiki.am-wd.de/libs/common + README.md + MIT + + AM.WD + Andreas Müller + © {copyright:2020-} AM.WD + Library with classes and extensions used frequently on AM.WD projects. + + + + + + + + + true + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + diff --git a/test/AMWD.Common.AspNetCore.Tests/AMWD.Common.AspNetCore.Tests.csproj b/test/AMWD.Common.AspNetCore.Tests/AMWD.Common.AspNetCore.Tests.csproj new file mode 100644 index 0000000..59f2c67 --- /dev/null +++ b/test/AMWD.Common.AspNetCore.Tests/AMWD.Common.AspNetCore.Tests.csproj @@ -0,0 +1,11 @@ + + + + net8.0 + + + + + + + diff --git a/UnitTests/AspNetCore/Attributes/BasicAuthenticationAttributeTests.cs b/test/AMWD.Common.AspNetCore.Tests/Attributes/BasicAuthenticationAttributeTest.cs similarity index 94% rename from UnitTests/AspNetCore/Attributes/BasicAuthenticationAttributeTests.cs rename to test/AMWD.Common.AspNetCore.Tests/Attributes/BasicAuthenticationAttributeTest.cs index 0710f83..4c50ae3 100644 --- a/UnitTests/AspNetCore/Attributes/BasicAuthenticationAttributeTests.cs +++ b/test/AMWD.Common.AspNetCore.Tests/Attributes/BasicAuthenticationAttributeTest.cs @@ -13,14 +13,12 @@ using Microsoft.AspNetCore.Mvc.Abstractions; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.Primitives; -using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; -namespace UnitTests.AspNetCore.Attributes +namespace AMWD.Common.AspNetCore.Tests.Attributes { [TestClass] - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - public class BasicAuthenticationAttributeTests + public class BasicAuthenticationAttributeTest { private Mock _requestHeaderMock; private Mock _responseHeaderMock; diff --git a/UnitTests/AspNetCore/Attributes/IPAllowListAttributeTests.cs b/test/AMWD.Common.AspNetCore.Tests/Attributes/IPAllowListAttributeTest.cs similarity index 94% rename from UnitTests/AspNetCore/Attributes/IPAllowListAttributeTests.cs rename to test/AMWD.Common.AspNetCore.Tests/Attributes/IPAllowListAttributeTest.cs index cca8600..0cf7f04 100644 --- a/UnitTests/AspNetCore/Attributes/IPAllowListAttributeTests.cs +++ b/test/AMWD.Common.AspNetCore.Tests/Attributes/IPAllowListAttributeTest.cs @@ -7,14 +7,12 @@ using Microsoft.AspNetCore.Mvc.Abstractions; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.Configuration; -using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; -namespace UnitTests.AspNetCore.Attributes +namespace AMWD.Common.AspNetCore.Tests.Attributes { [TestClass] - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - public class IPAllowListAttributeTests + public class IPAllowListAttributeTest { private Dictionary _requestHeaders; private Dictionary _itemsCallback; diff --git a/UnitTests/AspNetCore/Attributes/IPBlockListAttributeTests.cs b/test/AMWD.Common.AspNetCore.Tests/Attributes/IPBlockListAttributeTest.cs similarity index 94% rename from UnitTests/AspNetCore/Attributes/IPBlockListAttributeTests.cs rename to test/AMWD.Common.AspNetCore.Tests/Attributes/IPBlockListAttributeTest.cs index 0bb406d..837b388 100644 --- a/UnitTests/AspNetCore/Attributes/IPBlockListAttributeTests.cs +++ b/test/AMWD.Common.AspNetCore.Tests/Attributes/IPBlockListAttributeTest.cs @@ -7,14 +7,12 @@ using Microsoft.AspNetCore.Mvc.Abstractions; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.Configuration; -using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; -namespace UnitTests.AspNetCore.Attributes +namespace AMWD.Common.AspNetCore.Tests.Attributes { [TestClass] - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - public class IPBlockListAttributeTests + public class IPBlockListAttributeTest { private Dictionary _requestHeaders; private Dictionary _itemsCallback; diff --git a/UnitTests/AspNetCore/Extensions/HttpContextExtensionsTests.cs b/test/AMWD.Common.AspNetCore.Tests/Extensions/HttpContextExtensionsTest.cs similarity index 93% rename from UnitTests/AspNetCore/Extensions/HttpContextExtensionsTests.cs rename to test/AMWD.Common.AspNetCore.Tests/Extensions/HttpContextExtensionsTest.cs index fff41a1..c12fefa 100644 --- a/UnitTests/AspNetCore/Extensions/HttpContextExtensionsTests.cs +++ b/test/AMWD.Common.AspNetCore.Tests/Extensions/HttpContextExtensionsTest.cs @@ -3,14 +3,12 @@ using System.Collections.Generic; using System.Net; using Microsoft.AspNetCore.Antiforgery; using Microsoft.AspNetCore.Http; -using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; -namespace UnitTests.AspNetCore.Extensions +namespace AMWD.Common.AspNetCore.Tests.Extensions { [TestClass] - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - public class HttpContextExtensionsTests + public class HttpContextExtensionsTest { private Mock _sessionMock; diff --git a/UnitTests/AspNetCore/Extensions/ModelStateDictionaryExtensionsTests.cs b/test/AMWD.Common.AspNetCore.Tests/Extensions/ModelStateDictionaryExtensionsTest.cs similarity index 87% rename from UnitTests/AspNetCore/Extensions/ModelStateDictionaryExtensionsTests.cs rename to test/AMWD.Common.AspNetCore.Tests/Extensions/ModelStateDictionaryExtensionsTest.cs index 0a7f199..a08ce77 100644 --- a/UnitTests/AspNetCore/Extensions/ModelStateDictionaryExtensionsTests.cs +++ b/test/AMWD.Common.AspNetCore.Tests/Extensions/ModelStateDictionaryExtensionsTest.cs @@ -1,13 +1,11 @@ using System; using System.Linq; using Microsoft.AspNetCore.Mvc.ModelBinding; -using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace UnitTests.AspNetCore.Extensions +namespace AMWD.Common.AspNetCore.Tests.Extensions { [TestClass] - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - public class ModelStateDictionaryExtensionsTests + public class ModelStateDictionaryExtensionsTest { private TestModel _testModel; diff --git a/UnitTests/AspNetCore/Extensions/SessionExtensionsTests.cs b/test/AMWD.Common.AspNetCore.Tests/Extensions/SessionExtensionsTest.cs similarity index 90% rename from UnitTests/AspNetCore/Extensions/SessionExtensionsTests.cs rename to test/AMWD.Common.AspNetCore.Tests/Extensions/SessionExtensionsTest.cs index d1b53ff..ce2b0a9 100644 --- a/UnitTests/AspNetCore/Extensions/SessionExtensionsTests.cs +++ b/test/AMWD.Common.AspNetCore.Tests/Extensions/SessionExtensionsTest.cs @@ -1,14 +1,12 @@ using System.Text; using Microsoft.AspNetCore.Http; -using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; using Newtonsoft.Json; -namespace UnitTests.AspNetCore.Extensions +namespace AMWD.Common.AspNetCore.Tests.Extensions { [TestClass] - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - public class SessionExtensionsTests + public class SessionExtensionsTest { private Mock _sessionMock; diff --git a/UnitTests/AspNetCore/Security/BasicAuthentication/BasicAuthenticationMiddlewareTests.cs b/test/AMWD.Common.AspNetCore.Tests/Security/BasicAuthentication/BasicAuthenticationMiddlewareTest.cs similarity index 93% rename from UnitTests/AspNetCore/Security/BasicAuthentication/BasicAuthenticationMiddlewareTests.cs rename to test/AMWD.Common.AspNetCore.Tests/Security/BasicAuthentication/BasicAuthenticationMiddlewareTest.cs index 20ac3b5..3caad25 100644 --- a/UnitTests/AspNetCore/Security/BasicAuthentication/BasicAuthenticationMiddlewareTests.cs +++ b/test/AMWD.Common.AspNetCore.Tests/Security/BasicAuthentication/BasicAuthenticationMiddlewareTest.cs @@ -10,14 +10,12 @@ using AMWD.Common.AspNetCore.Security.BasicAuthentication; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Primitives; using Microsoft.Net.Http.Headers; -using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; -namespace UnitTests.AspNetCore.Security.BasicAuthentication +namespace AMWD.Common.AspNetCore.Tests.Security.BasicAuthentication { [TestClass] - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - public class BasicAuthenticationMiddlewareTests + public class BasicAuthenticationMiddlewareTest { private Dictionary _requestHeaders; diff --git a/UnitTests/AspNetCore/Security/PathProtection/ProtectedPathMiddlewareTests.cs b/test/AMWD.Common.AspNetCore.Tests/Security/PathProtection/ProtectedPathMiddlewareTest.cs similarity index 92% rename from UnitTests/AspNetCore/Security/PathProtection/ProtectedPathMiddlewareTests.cs rename to test/AMWD.Common.AspNetCore.Tests/Security/PathProtection/ProtectedPathMiddlewareTest.cs index 33c9b6e..1e0160c 100644 --- a/UnitTests/AspNetCore/Security/PathProtection/ProtectedPathMiddlewareTests.cs +++ b/test/AMWD.Common.AspNetCore.Tests/Security/PathProtection/ProtectedPathMiddlewareTest.cs @@ -5,14 +5,12 @@ using AMWD.Common.AspNetCore.Security.PathProtection; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; -using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; -namespace UnitTests.AspNetCore.Security.PathProtection +namespace AMWD.Common.AspNetCore.Tests.Security.PathProtection { [TestClass] - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - public class ProtectedPathMiddlewareTests + public class ProtectedPathMiddlewareTest { private Mock _nextMock; private Mock _httpContextMock; diff --git a/UnitTests/AspNetCore/Utilities/HtmlHelperTests.cs b/test/AMWD.Common.AspNetCore.Tests/Utilities/HtmlHelperTest.cs similarity index 89% rename from UnitTests/AspNetCore/Utilities/HtmlHelperTests.cs rename to test/AMWD.Common.AspNetCore.Tests/Utilities/HtmlHelperTest.cs index 593dde4..ac718db 100644 --- a/UnitTests/AspNetCore/Utilities/HtmlHelperTests.cs +++ b/test/AMWD.Common.AspNetCore.Tests/Utilities/HtmlHelperTest.cs @@ -1,12 +1,10 @@ using System; using AMWD.Common.AspNetCore.Utilities; -using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace UnitTests.AspNetCore.Utilities +namespace AMWD.Common.AspNetCore.Tests.Utilities { [TestClass] - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - public class HtmlHelperTests + public class HtmlHelperTest { [TestMethod] [ExpectedException(typeof(ArgumentNullException))] diff --git a/UnitTests/AspNetCore/Utilities/PasswordHelperTests.cs b/test/AMWD.Common.AspNetCore.Tests/Utilities/PasswordHelperTest.cs similarity index 90% rename from UnitTests/AspNetCore/Utilities/PasswordHelperTests.cs rename to test/AMWD.Common.AspNetCore.Tests/Utilities/PasswordHelperTest.cs index 305800e..7c8838f 100644 --- a/UnitTests/AspNetCore/Utilities/PasswordHelperTests.cs +++ b/test/AMWD.Common.AspNetCore.Tests/Utilities/PasswordHelperTest.cs @@ -1,12 +1,10 @@ using System.Reflection; using Microsoft.AspNetCore.Identity; -using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace UnitTests.AspNetCore.Utilities +namespace AMWD.Common.AspNetCore.Tests.Utilities { [TestClass] - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - public class PasswordHelperTests + public class PasswordHelperTest { [TestMethod] public void ShouldReturnNullHashWhenNullProvided() diff --git a/test/AMWD.Common.Tests/AMWD.Common.Tests.csproj b/test/AMWD.Common.Tests/AMWD.Common.Tests.csproj new file mode 100644 index 0000000..f8301d0 --- /dev/null +++ b/test/AMWD.Common.Tests/AMWD.Common.Tests.csproj @@ -0,0 +1,15 @@ + + + + net8.0 + + + + + + + + + + + diff --git a/UnitTests/Common/Cli/CommandLineParserTests.cs b/test/AMWD.Common.Tests/Cli/CommandLineParserTest.cs similarity index 95% rename from UnitTests/Common/Cli/CommandLineParserTests.cs rename to test/AMWD.Common.Tests/Cli/CommandLineParserTest.cs index d19d547..21c88ca 100644 --- a/UnitTests/Common/Cli/CommandLineParserTests.cs +++ b/test/AMWD.Common.Tests/Cli/CommandLineParserTest.cs @@ -3,12 +3,11 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using AMWD.Common.Cli; -using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace UnitTests.Common.Cli +namespace AMWD.Common.Tests.Cli { [TestClass] - public class CommandLineParserTests + public class CommandLineParserTest { [TestMethod] public void ShouldParseStringToArgs() diff --git a/UnitTests/Common/Cli/EnumerableWalkerTests.cs b/test/AMWD.Common.Tests/Cli/EnumerableWalkerTest.cs similarity index 88% rename from UnitTests/Common/Cli/EnumerableWalkerTests.cs rename to test/AMWD.Common.Tests/Cli/EnumerableWalkerTest.cs index 73b0f74..1e76d1c 100644 --- a/UnitTests/Common/Cli/EnumerableWalkerTests.cs +++ b/test/AMWD.Common.Tests/Cli/EnumerableWalkerTest.cs @@ -1,12 +1,11 @@ using System; using System.Collections.Generic; using AMWD.Common.Cli; -using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace UnitTests.Common.Cli +namespace AMWD.Common.Tests.Cli { [TestClass] - public class EnumerableWalkerTests + public class EnumerableWalkerTest { private List _list; diff --git a/UnitTests/Common/Comparer/DomainComparerTests.cs b/test/AMWD.Common.Tests/Comparer/DomainComparerTest.cs similarity index 87% rename from UnitTests/Common/Comparer/DomainComparerTests.cs rename to test/AMWD.Common.Tests/Comparer/DomainComparerTest.cs index 5912293..a2a3ee6 100644 --- a/UnitTests/Common/Comparer/DomainComparerTests.cs +++ b/test/AMWD.Common.Tests/Comparer/DomainComparerTest.cs @@ -1,10 +1,9 @@ using AMWD.Common.Comparer; -using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace UnitTests.Common.Comparer +namespace AMWD.Common.Tests.Comparer { [TestClass] - public class DomainComparerTests + public class DomainComparerTest { [DataTestMethod] [DataRow("int", "internal")] diff --git a/UnitTests/Common/Comparer/IPAddressComparerTests.cs b/test/AMWD.Common.Tests/Comparer/IPAddressComparerTest.cs similarity index 87% rename from UnitTests/Common/Comparer/IPAddressComparerTests.cs rename to test/AMWD.Common.Tests/Comparer/IPAddressComparerTest.cs index 525b87c..4ec5da1 100644 --- a/UnitTests/Common/Comparer/IPAddressComparerTests.cs +++ b/test/AMWD.Common.Tests/Comparer/IPAddressComparerTest.cs @@ -1,11 +1,10 @@ using System.Net; using AMWD.Common.Comparer; -using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace UnitTests.Common.Comparer +namespace AMWD.Common.Tests.Comparer { [TestClass] - public class IPAddressComparerTests + public class IPAddressComparerTest { [DataTestMethod] [DataRow("127.0.0.0", "127.0.0.1")] diff --git a/UnitTests/Common/Comparer/VersionStringComparerTests.cs b/test/AMWD.Common.Tests/Comparer/VersionStringComparerTest.cs similarity index 86% rename from UnitTests/Common/Comparer/VersionStringComparerTests.cs rename to test/AMWD.Common.Tests/Comparer/VersionStringComparerTest.cs index a24d496..80dc487 100644 --- a/UnitTests/Common/Comparer/VersionStringComparerTests.cs +++ b/test/AMWD.Common.Tests/Comparer/VersionStringComparerTest.cs @@ -1,10 +1,9 @@ using AMWD.Common.Comparer; -using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace UnitTests.Common.Comparer +namespace AMWD.Common.Tests.Comparer { [TestClass] - public class VersionStringComparerTests + public class VersionStringComparerTest { [DataTestMethod] [DataRow(null, "0")] diff --git a/UnitTests/Common/Extensions/CollectionExtensionsTests.cs b/test/AMWD.Common.Tests/Extensions/CollectionExtensionsTest.cs similarity index 90% rename from UnitTests/Common/Extensions/CollectionExtensionsTests.cs rename to test/AMWD.Common.Tests/Extensions/CollectionExtensionsTest.cs index 19762c3..b49c7af 100644 --- a/UnitTests/Common/Extensions/CollectionExtensionsTests.cs +++ b/test/AMWD.Common.Tests/Extensions/CollectionExtensionsTest.cs @@ -1,11 +1,10 @@ using System; using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace UnitTests.Common.Extensions +namespace AMWD.Common.Tests.Extensions { [TestClass] - public class CollectionExtensionsTests + public class CollectionExtensionsTest { [TestMethod] public void ShouldAddItem() diff --git a/UnitTests/Common/Extensions/CryptographyHelperExtensionsTests.cs b/test/AMWD.Common.Tests/Extensions/CryptographyHelperExtensionsTest.cs similarity index 86% rename from UnitTests/Common/Extensions/CryptographyHelperExtensionsTests.cs rename to test/AMWD.Common.Tests/Extensions/CryptographyHelperExtensionsTest.cs index a0e1067..131278d 100644 --- a/UnitTests/Common/Extensions/CryptographyHelperExtensionsTests.cs +++ b/test/AMWD.Common.Tests/Extensions/CryptographyHelperExtensionsTest.cs @@ -1,11 +1,9 @@ using System.Security.Cryptography; -using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace UnitTests.Common.Extensions +namespace AMWD.Common.Tests.Extensions { [TestClass] - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - public class CryptographyHelperExtensionsTests + public class CryptographyHelperExtensionsTest { [TestMethod] public void ShouldReturnMd5Hash() diff --git a/UnitTests/Common/Extensions/DateTimeExtensionsTests.cs b/test/AMWD.Common.Tests/Extensions/DateTimeExtensionsTest.cs similarity index 96% rename from UnitTests/Common/Extensions/DateTimeExtensionsTests.cs rename to test/AMWD.Common.Tests/Extensions/DateTimeExtensionsTest.cs index c4ea947..3d159bb 100644 --- a/UnitTests/Common/Extensions/DateTimeExtensionsTests.cs +++ b/test/AMWD.Common.Tests/Extensions/DateTimeExtensionsTest.cs @@ -1,12 +1,10 @@ using System; -using UnitTests.Common.Utils; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using AMWD.Common.Tests.Utils; -namespace UnitTests.Common.Extensions +namespace AMWD.Common.Tests.Extensions { [TestClass] - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - public class DateTimeExtensionsTests + public class DateTimeExtensionsTest { [TestMethod] public void ShouldReturnUtc() diff --git a/UnitTests/Common/Extensions/EnumExtensionsTests.cs b/test/AMWD.Common.Tests/Extensions/EnumExtensionsTest.cs similarity index 88% rename from UnitTests/Common/Extensions/EnumExtensionsTests.cs rename to test/AMWD.Common.Tests/Extensions/EnumExtensionsTest.cs index 0099f7a..baab4f9 100644 --- a/UnitTests/Common/Extensions/EnumExtensionsTests.cs +++ b/test/AMWD.Common.Tests/Extensions/EnumExtensionsTest.cs @@ -1,15 +1,12 @@ using System; -using System.ComponentModel.DataAnnotations; using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using UnitTests.Common.Utils; +using AMWD.Common.Tests.Utils; using DescriptionAttribute = System.ComponentModel.DescriptionAttribute; -namespace UnitTests.Common.Extensions +namespace AMWD.Common.Tests.Extensions { [TestClass] - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - public class EnumExtensionsTests + public class EnumExtensionsTest { [TestMethod] public void ShouldReturnEmptyList() diff --git a/UnitTests/Common/Extensions/ExceptionExtensionsTests.cs b/test/AMWD.Common.Tests/Extensions/ExceptionExtensionsTest.cs similarity index 88% rename from UnitTests/Common/Extensions/ExceptionExtensionsTests.cs rename to test/AMWD.Common.Tests/Extensions/ExceptionExtensionsTest.cs index d8d0158..d797e8c 100644 --- a/UnitTests/Common/Extensions/ExceptionExtensionsTests.cs +++ b/test/AMWD.Common.Tests/Extensions/ExceptionExtensionsTest.cs @@ -1,12 +1,10 @@ using System; using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace UnitTests.Common.Extensions +namespace AMWD.Common.Tests.Extensions { [TestClass] - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - public class ExceptionExtensionsTests + public class ExceptionExtensionsTest { [TestMethod] public void ShouldReturnExceptionMessage() diff --git a/UnitTests/Common/Extensions/IPAddressExtensionsTests.cs b/test/AMWD.Common.Tests/Extensions/IPAddressExtensionsTest.cs similarity index 85% rename from UnitTests/Common/Extensions/IPAddressExtensionsTests.cs rename to test/AMWD.Common.Tests/Extensions/IPAddressExtensionsTest.cs index d4b5c86..bc97e03 100644 --- a/UnitTests/Common/Extensions/IPAddressExtensionsTests.cs +++ b/test/AMWD.Common.Tests/Extensions/IPAddressExtensionsTest.cs @@ -1,11 +1,9 @@ using System.Net; -using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace UnitTests.Common.Extensions +namespace AMWD.Common.Tests.Extensions { [TestClass] - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - public class IPAddressExtensionsTests + public class IPAddressExtensionsTest { [TestMethod] public void ShouldIncrementLastByte() diff --git a/UnitTests/Common/Extensions/JsonExtensionsTests.cs b/test/AMWD.Common.Tests/Extensions/JsonExtensionsTest.cs similarity index 92% rename from UnitTests/Common/Extensions/JsonExtensionsTests.cs rename to test/AMWD.Common.Tests/Extensions/JsonExtensionsTest.cs index cd6c710..5fb5f96 100644 --- a/UnitTests/Common/Extensions/JsonExtensionsTests.cs +++ b/test/AMWD.Common.Tests/Extensions/JsonExtensionsTest.cs @@ -1,15 +1,13 @@ using System; using System.Collections; -using UnitTests.Common.Utils; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using AMWD.Common.Tests.Utils; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -namespace UnitTests.Common.Extensions +namespace AMWD.Common.Tests.Extensions { [TestClass] - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - public class JsonExtensionsTests + public class JsonExtensionsTest { [TestMethod] public void ShouldReturnJson() @@ -91,7 +89,7 @@ namespace UnitTests.Common.Extensions { // arrange var testObject = new JsonTestClass(); - string expected = @"{""$type"":""UnitTests.Common.Utils.JsonTestClass, UnitTests"",""stringValue"":""Hello World!"",""isBoolTrue"":true,""floatValue"":12.34,""doubleValue"":21.42,""decimalValue"":42.21,""localTimestamp"":""2021-11-16T20:15:34+01:00"",""utcTimestamp"":""2021-11-16T20:15:34Z"",""object"":{""$type"":""UnitTests.Common.Utils.JsonTestSubClass, UnitTests"",""integerValue"":42,""stringValue"":""Foo-Bar""}}"; + string expected = @"{""$type"":""AMWD.Common.Tests.Utils.JsonTestClass, AMWD.Common.Tests"",""stringValue"":""Hello World!"",""isBoolTrue"":true,""floatValue"":12.34,""doubleValue"":21.42,""decimalValue"":42.21,""localTimestamp"":""2021-11-16T20:15:34+01:00"",""utcTimestamp"":""2021-11-16T20:15:34Z"",""object"":{""$type"":""AMWD.Common.Tests.Utils.JsonTestSubClass, AMWD.Common.Tests"",""integerValue"":42,""stringValue"":""Foo-Bar""}}"; // act string json = testObject.SerializeJson(includeType: true); diff --git a/UnitTests/Common/Extensions/ReaderWriterLockSlimExtensionsTests.cs b/test/AMWD.Common.Tests/Extensions/ReaderWriterLockSlimExtensionsTest.cs similarity index 91% rename from UnitTests/Common/Extensions/ReaderWriterLockSlimExtensionsTests.cs rename to test/AMWD.Common.Tests/Extensions/ReaderWriterLockSlimExtensionsTest.cs index 85e5d78..421491d 100644 --- a/UnitTests/Common/Extensions/ReaderWriterLockSlimExtensionsTests.cs +++ b/test/AMWD.Common.Tests/Extensions/ReaderWriterLockSlimExtensionsTest.cs @@ -1,13 +1,11 @@ using System; using System.Threading; using System.Threading.Tasks; -using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace UnitTests.Common.Extensions +namespace AMWD.Common.Tests.Extensions { [TestClass] - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - public class ReaderWriterLockSlimExtensionsTests + public class ReaderWriterLockSlimExtensionsTest { [TestMethod] public void ShouldEnterReadLock() diff --git a/UnitTests/Common/Extensions/StreamExtensionsTests.cs b/test/AMWD.Common.Tests/Extensions/StreamExtensionsTest.cs similarity index 89% rename from UnitTests/Common/Extensions/StreamExtensionsTests.cs rename to test/AMWD.Common.Tests/Extensions/StreamExtensionsTest.cs index 10b6371..8df5061 100644 --- a/UnitTests/Common/Extensions/StreamExtensionsTests.cs +++ b/test/AMWD.Common.Tests/Extensions/StreamExtensionsTest.cs @@ -2,13 +2,11 @@ using System.IO; using System.Text; using System.Threading.Tasks; -using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace UnitTests.Common.Extensions +namespace AMWD.Common.Tests.Extensions { [TestClass] - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - public class StreamExtensionsTests + public class StreamExtensionsTest { [TestMethod] public void ShouldReadLineFromStreamSynchronous() diff --git a/UnitTests/Common/Extensions/StringExtensionsTests.cs b/test/AMWD.Common.Tests/Extensions/StringExtensionsTest.cs similarity index 93% rename from UnitTests/Common/Extensions/StringExtensionsTests.cs rename to test/AMWD.Common.Tests/Extensions/StringExtensionsTest.cs index 43a590f..49fbfe2 100644 --- a/UnitTests/Common/Extensions/StringExtensionsTests.cs +++ b/test/AMWD.Common.Tests/Extensions/StringExtensionsTest.cs @@ -2,13 +2,11 @@ using System; using System.Linq; using System.Net; using System.Text; -using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace UnitTests.Common.Extensions +namespace AMWD.Common.Tests.Extensions { [TestClass] - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - public class StringExtensionsTests + public class StringExtensionsTest { [TestMethod] public void ShouldReturnEmptyList() diff --git a/UnitTests/Common/Logging/FileLoggerTests.cs b/test/AMWD.Common.Tests/Logging/FileLoggerTest.cs similarity index 95% rename from UnitTests/Common/Logging/FileLoggerTests.cs rename to test/AMWD.Common.Tests/Logging/FileLoggerTest.cs index 9d56643..39dea90 100644 --- a/UnitTests/Common/Logging/FileLoggerTests.cs +++ b/test/AMWD.Common.Tests/Logging/FileLoggerTest.cs @@ -7,13 +7,12 @@ using System.Threading; using System.Threading.Tasks; using AMWD.Common.Logging; using Microsoft.Extensions.Logging; -using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; -namespace UnitTests.Common.Logging +namespace AMWD.Common.Tests.Logging { [TestClass] - public class FileLoggerTests + public class FileLoggerTest { private Mock _streamWriterMock; diff --git a/UnitTests/Common/Packing/Ar/ArReaderTests.cs b/test/AMWD.Common.Tests/Packing/Ar/ArReaderTest.cs similarity index 77% rename from UnitTests/Common/Packing/Ar/ArReaderTests.cs rename to test/AMWD.Common.Tests/Packing/Ar/ArReaderTest.cs index 712a59a..eb507e5 100644 --- a/UnitTests/Common/Packing/Ar/ArReaderTests.cs +++ b/test/AMWD.Common.Tests/Packing/Ar/ArReaderTest.cs @@ -4,19 +4,17 @@ using System.IO; using System.Linq; using System.Text; using AMWD.Common.Packing.Ar; -using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace UnitTests.Common.Packing.Ar +namespace AMWD.Common.Tests.Packing.Ar { [TestClass] - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - public class ArReaderTests + public class ArReaderTest { private readonly DateTime _fixedDateTime = new(2023, 03, 01, 10, 20, 30, 0, DateTimeKind.Utc); private Dictionary _files; - private Stream inStream; + private MemoryStream _inStream; [TestInitialize] public void Initialize() @@ -61,40 +59,40 @@ namespace UnitTests.Common.Packing.Ar } }; - inStream = new MemoryStream(); - inStream.Write(Encoding.ASCII.GetBytes("!\n")); + _inStream = new MemoryStream(); + _inStream.Write(Encoding.ASCII.GetBytes("!\n")); foreach (var file in _files) { int unixSeconds = (int)file.Value.ModifyTime.Subtract(DateTime.UnixEpoch).TotalSeconds; - inStream.Write(Encoding.ASCII.GetBytes($"{file.Key,-16}{unixSeconds,-12}123 456 100644 {file.Value.FileSize,-10}`\n")); - inStream.Write(Encoding.UTF8.GetBytes(new string('a', (int)file.Value.FileSize))); + _inStream.Write(Encoding.ASCII.GetBytes($"{file.Key,-16}{unixSeconds,-12}123 456 100644 {file.Value.FileSize,-10}`\n")); + _inStream.Write(Encoding.UTF8.GetBytes(new string('a', (int)file.Value.FileSize))); if (file.Value.FileSize % 2 != 0) - inStream.Write(Encoding.ASCII.GetBytes("\n")); + _inStream.Write(Encoding.ASCII.GetBytes("\n")); } - inStream.Seek(0, SeekOrigin.Begin); + _inStream.Seek(0, SeekOrigin.Begin); } [TestCleanup] public void Cleanup() { - inStream.Dispose(); - inStream = null; + _inStream.Dispose(); + _inStream = null; } [TestMethod] public void ShouldInitializeArchive() { // Arrange - inStream.Dispose(); - inStream = new MemoryStream(); - inStream.Write(Encoding.ASCII.GetBytes("!\n")); - inStream.Seek(0, SeekOrigin.Begin); + _inStream.Dispose(); + _inStream = new MemoryStream(); + _inStream.Write(Encoding.ASCII.GetBytes("!\n")); + _inStream.Seek(0, SeekOrigin.Begin); // Act - var reader = new ArReader(inStream); + var reader = new ArReader(_inStream); // Assert Assert.IsNotNull(reader); @@ -107,7 +105,7 @@ namespace UnitTests.Common.Packing.Ar // Arrange // Act - var reader = new ArReader(inStream); + var reader = new ArReader(_inStream); // Assert Assert.IsNotNull(reader); @@ -118,7 +116,7 @@ namespace UnitTests.Common.Packing.Ar public void ShouldListFileNames() { // Arrange - var reader = new ArReader(inStream); + var reader = new ArReader(_inStream); // Act var fileList = reader.GetFileList().ToList(); @@ -136,7 +134,7 @@ namespace UnitTests.Common.Packing.Ar { // Arrange var infos = new List(); - var reader = new ArReader(inStream); + var reader = new ArReader(_inStream); // Act foreach (string name in _files.Keys) @@ -164,7 +162,7 @@ namespace UnitTests.Common.Packing.Ar { // Arrange var contents = new Dictionary(); - var reader = new ArReader(inStream); + var reader = new ArReader(_inStream); // Act foreach (string name in _files.Keys) @@ -198,7 +196,7 @@ namespace UnitTests.Common.Packing.Ar { // Arrange string tmpFile = Path.GetTempFileName(); - var reader = new ArReader(inStream); + var reader = new ArReader(_inStream); try { @@ -261,7 +259,7 @@ namespace UnitTests.Common.Packing.Ar stream.CanSeekOR = true; stream.CanWriteOR = false; - var reader = new ArReader(inStream); + var reader = new ArReader(_inStream); // Act reader.ReadFile("abcd.tmp", stream); @@ -275,10 +273,10 @@ namespace UnitTests.Common.Packing.Ar public void ShouldThrowExceptionOnInvalidArchive() { // Arrange - inStream.Seek(8, SeekOrigin.Begin); + _inStream.Seek(8, SeekOrigin.Begin); // Act - _ = new ArReader(inStream); + _ = new ArReader(_inStream); // Assert - FormatException Assert.Fail(); @@ -289,12 +287,12 @@ namespace UnitTests.Common.Packing.Ar public void ShouldThrowExceptionOnInvalidMagic() { // Arrange - inStream.Seek(0, SeekOrigin.End); - inStream.Write(Encoding.ASCII.GetBytes($"{"foo.bar",-16}{"123456789",-12}123 456 100644 {"0",-10}´\n")); - inStream.Seek(0, SeekOrigin.Begin); + _inStream.Seek(0, SeekOrigin.End); + _inStream.Write(Encoding.ASCII.GetBytes($"{"foo.bar",-16}{"123456789",-12}123 456 100644 {"0",-10}´\n")); + _inStream.Seek(0, SeekOrigin.Begin); // Act - _ = new ArReader(inStream); + _ = new ArReader(_inStream); // Assert - FormatException Assert.Fail(); @@ -304,7 +302,7 @@ namespace UnitTests.Common.Packing.Ar public void ShouldWriteNothingToStreamForMissingFile() { // Arrange - var reader = new ArReader(inStream); + var reader = new ArReader(_inStream); // Act using var ms = new MemoryStream(); @@ -321,7 +319,7 @@ namespace UnitTests.Common.Packing.Ar { // Arrange string tmpFile = Path.GetTempFileName(); - var reader = new ArReader(inStream); + var reader = new ArReader(_inStream); try { diff --git a/UnitTests/Common/Packing/Ar/ArWriterTests.cs b/test/AMWD.Common.Tests/Packing/Ar/ArWriterTest.cs similarity index 67% rename from UnitTests/Common/Packing/Ar/ArWriterTests.cs rename to test/AMWD.Common.Tests/Packing/Ar/ArWriterTest.cs index f872687..74be7bd 100644 --- a/UnitTests/Common/Packing/Ar/ArWriterTests.cs +++ b/test/AMWD.Common.Tests/Packing/Ar/ArWriterTest.cs @@ -5,43 +5,41 @@ using System.Linq; using System.Security.Cryptography; using System.Text; using AMWD.Common.Packing.Ar; -using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace UnitTests.Common.Packing.Ar +namespace AMWD.Common.Tests.Packing.Ar { [TestClass] - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - public class ArWriterTests + public class ArWriterTest { - private readonly DateTime fixedDateTime = new(2023, 03, 01, 10, 20, 30, 0, DateTimeKind.Utc); + private readonly DateTime _fixedDateTime = new(2023, 03, 01, 10, 20, 30, 0, DateTimeKind.Utc); - private readonly Dictionary files = new(); + private readonly Dictionary _files = []; - private Stream outStream; + private MemoryStream _outStream; [TestInitialize] public void Initialize() { - files.Clear(); + _files.Clear(); for (int i = 0; i < 3; i++) { var (filePath, content) = GenerateTestFile(); - files.Add(filePath, content); + _files.Add(filePath, content); } - outStream = new MemoryStream(); + _outStream = new MemoryStream(); } [TestCleanup] public void Cleanup() { - foreach (var kvp in files) + foreach (var kvp in _files) File.Delete(kvp.Key); - files.Clear(); + _files.Clear(); - outStream.Dispose(); - outStream = null; + _outStream.Dispose(); + _outStream = null; } [TestMethod] @@ -51,14 +49,14 @@ namespace UnitTests.Common.Packing.Ar byte[] initBytes = new byte[8]; // Act - _ = new ArWriter(outStream); + _ = new ArWriter(_outStream); - outStream.Seek(0, SeekOrigin.Begin); + _outStream.Seek(0, SeekOrigin.Begin); // Assert - Assert.AreEqual(initBytes.Length, outStream.Length); + Assert.AreEqual(initBytes.Length, _outStream.Length); - outStream.Read(initBytes, 0, initBytes.Length); + _outStream.Read(initBytes, 0, initBytes.Length); CollectionAssert.AreEqual(Encoding.ASCII.GetBytes("!\n"), initBytes); } @@ -66,22 +64,22 @@ namespace UnitTests.Common.Packing.Ar public void ShouldWriteOneFile() { // Arrange - var firstFileKvp = files.First(); + var firstFileKvp = _files.First(); byte[] headerBytes = new byte[60]; byte[] contentBytes = new byte[14]; - var writer = new ArWriter(outStream); + var writer = new ArWriter(_outStream); // Act writer.WriteFile(firstFileKvp.Key, 123, 456); - outStream.Seek(8, SeekOrigin.Begin); // set behind init bytes + _outStream.Seek(8, SeekOrigin.Begin); // set behind init bytes // Assert - Assert.AreEqual(8 + headerBytes.Length + contentBytes.Length, outStream.Length); + Assert.AreEqual(8 + headerBytes.Length + contentBytes.Length, _outStream.Length); - outStream.Read(headerBytes, 0, headerBytes.Length); - outStream.Read(contentBytes, 0, contentBytes.Length); + _outStream.Read(headerBytes, 0, headerBytes.Length); + _outStream.Read(contentBytes, 0, contentBytes.Length); string header = Encoding.ASCII.GetString(headerBytes); string content = Encoding.UTF8.GetString(contentBytes); @@ -94,24 +92,24 @@ namespace UnitTests.Common.Packing.Ar public void ShouldWriteMultipleFiles() { // Arrange - var writer = new ArWriter(outStream); + var writer = new ArWriter(_outStream); // Act - foreach (var kvp in files) + foreach (var kvp in _files) writer.WriteFile(kvp.Key, 123, 456); - outStream.Seek(8, SeekOrigin.Begin); + _outStream.Seek(8, SeekOrigin.Begin); // Assert - Assert.AreEqual((8 + 3 * 60 + 3 * 14), outStream.Length); + Assert.AreEqual(8 + 3 * 60 + 3 * 14, _outStream.Length); - foreach (var kvp in files) + foreach (var kvp in _files) { byte[] headerBytes = new byte[60]; byte[] contentBytes = new byte[14]; - outStream.Read(headerBytes, 0, headerBytes.Length); - outStream.Read(contentBytes, 0, contentBytes.Length); + _outStream.Read(headerBytes, 0, headerBytes.Length); + _outStream.Read(contentBytes, 0, contentBytes.Length); string header = Encoding.ASCII.GetString(headerBytes); string content = Encoding.UTF8.GetString(contentBytes); @@ -132,18 +130,18 @@ namespace UnitTests.Common.Packing.Ar byte[] headerBytes = new byte[60]; byte[] contentBytes = new byte[14]; - var writer = new ArWriter(outStream); + var writer = new ArWriter(_outStream); // Act writer.WriteFile(filePath, 123, 456); - outStream.Seek(8, SeekOrigin.Begin); + _outStream.Seek(8, SeekOrigin.Begin); // Assert - Assert.AreEqual(8 + headerBytes.Length + contentBytes.Length, outStream.Length); + Assert.AreEqual(8 + headerBytes.Length + contentBytes.Length, _outStream.Length); - outStream.Read(headerBytes, 0, headerBytes.Length); - outStream.Read(contentBytes, 0, contentBytes.Length); + _outStream.Read(headerBytes, 0, headerBytes.Length); + _outStream.Read(contentBytes, 0, contentBytes.Length); string header = Encoding.ASCII.GetString(headerBytes); string content = Encoding.UTF8.GetString(contentBytes); @@ -172,7 +170,7 @@ namespace UnitTests.Common.Packing.Ar File.Move(filePath, Path.Combine(path, fileName)); filePath = Path.Combine(path, fileName); - var writer = new ArWriter(outStream); + var writer = new ArWriter(_outStream); // Act writer.WriteFile(filePath, 123, 456); @@ -190,22 +188,22 @@ namespace UnitTests.Common.Packing.Ar public void ShouldWriteEmptyOnNegativeUserId() { // Arrange - var firstFileKvp = files.First(); + var firstFileKvp = _files.First(); byte[] headerBytes = new byte[60]; byte[] contentBytes = new byte[14]; - var writer = new ArWriter(outStream); + var writer = new ArWriter(_outStream); // Act writer.WriteFile(firstFileKvp.Key, -123, 456); - outStream.Seek(8, SeekOrigin.Begin); + _outStream.Seek(8, SeekOrigin.Begin); // Assert - Assert.AreEqual(8 + headerBytes.Length + contentBytes.Length, outStream.Length); + Assert.AreEqual(8 + headerBytes.Length + contentBytes.Length, _outStream.Length); - outStream.Read(headerBytes, 0, headerBytes.Length); - outStream.Read(contentBytes, 0, contentBytes.Length); + _outStream.Read(headerBytes, 0, headerBytes.Length); + _outStream.Read(contentBytes, 0, contentBytes.Length); string header = Encoding.ASCII.GetString(headerBytes); string content = Encoding.UTF8.GetString(contentBytes); @@ -218,22 +216,22 @@ namespace UnitTests.Common.Packing.Ar public void ShouldWriteEmptyOnNegativeGroupId() { // Arrange - var firstFileKvp = files.First(); + var firstFileKvp = _files.First(); byte[] headerBytes = new byte[60]; byte[] contentBytes = new byte[14]; - var writer = new ArWriter(outStream); + var writer = new ArWriter(_outStream); // Act writer.WriteFile(firstFileKvp.Key, 123, -456); - outStream.Seek(8, SeekOrigin.Begin); + _outStream.Seek(8, SeekOrigin.Begin); // Assert - Assert.AreEqual(8 + headerBytes.Length + contentBytes.Length, outStream.Length); + Assert.AreEqual(8 + headerBytes.Length + contentBytes.Length, _outStream.Length); - outStream.Read(headerBytes, 0, headerBytes.Length); - outStream.Read(contentBytes, 0, contentBytes.Length); + _outStream.Read(headerBytes, 0, headerBytes.Length); + _outStream.Read(contentBytes, 0, contentBytes.Length); string header = Encoding.ASCII.GetString(headerBytes); string content = Encoding.UTF8.GetString(contentBytes); @@ -246,22 +244,22 @@ namespace UnitTests.Common.Packing.Ar public void ShouldWriteEmptyOnNegativeMode() { // Arrange - var firstFileKvp = files.First(); + var firstFileKvp = _files.First(); byte[] headerBytes = new byte[60]; byte[] contentBytes = new byte[14]; - var writer = new ArWriter(outStream); + var writer = new ArWriter(_outStream); // Act writer.WriteFile(firstFileKvp.Key, 123, 456, -1); - outStream.Seek(8, SeekOrigin.Begin); + _outStream.Seek(8, SeekOrigin.Begin); // Assert - Assert.AreEqual(8 + headerBytes.Length + contentBytes.Length, outStream.Length); + Assert.AreEqual(8 + headerBytes.Length + contentBytes.Length, _outStream.Length); - outStream.Read(headerBytes, 0, headerBytes.Length); - outStream.Read(contentBytes, 0, contentBytes.Length); + _outStream.Read(headerBytes, 0, headerBytes.Length); + _outStream.Read(contentBytes, 0, contentBytes.Length); string header = Encoding.ASCII.GetString(headerBytes); string content = Encoding.UTF8.GetString(contentBytes); @@ -290,7 +288,7 @@ namespace UnitTests.Common.Packing.Ar string text = CryptographyHelper.GetRandomString(length); File.WriteAllText(filePath, text); - File.SetLastWriteTimeUtc(filePath, fixedDateTime); + File.SetLastWriteTimeUtc(filePath, _fixedDateTime); return (filePath, text); } diff --git a/UnitTests/Common/Utilities/AsyncQueueTests.cs b/test/AMWD.Common.Tests/Utilities/AsyncQueueTest.cs similarity index 93% rename from UnitTests/Common/Utilities/AsyncQueueTests.cs rename to test/AMWD.Common.Tests/Utilities/AsyncQueueTest.cs index b96cfd9..1d67706 100644 --- a/UnitTests/Common/Utilities/AsyncQueueTests.cs +++ b/test/AMWD.Common.Tests/Utilities/AsyncQueueTest.cs @@ -2,13 +2,11 @@ using System.Collections.Generic; using System.Reflection; using System.Threading.Tasks; -using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace UnitTests.Common.Utilities +namespace AMWD.Common.Tests.Utilities { [TestClass] - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - public class AsyncQueueTests + public class AsyncQueueTest { private Queue _internalQueue; diff --git a/UnitTests/Common/Utilities/CryptographyHelperTests.cs b/test/AMWD.Common.Tests/Utilities/CryptographyHelperTest.cs similarity index 95% rename from UnitTests/Common/Utilities/CryptographyHelperTests.cs rename to test/AMWD.Common.Tests/Utilities/CryptographyHelperTest.cs index 55b3b91..e50652c 100644 --- a/UnitTests/Common/Utilities/CryptographyHelperTests.cs +++ b/test/AMWD.Common.Tests/Utilities/CryptographyHelperTest.cs @@ -3,13 +3,11 @@ using System.Diagnostics; using System.IO; using System.Security.Cryptography; using System.Text.RegularExpressions; -using UnitTests.Common.Utils; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using AMWD.Common.Tests.Utils; namespace UnitTests.Common.Utilities { [TestClass] - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public partial class CryptographyHelperTests { private string _keyFile; diff --git a/UnitTests/Common/Utilities/DelayedTaskTests.cs b/test/AMWD.Common.Tests/Utilities/DelayedTaskTest.cs similarity index 94% rename from UnitTests/Common/Utilities/DelayedTaskTests.cs rename to test/AMWD.Common.Tests/Utilities/DelayedTaskTest.cs index dc6df00..fb60c5d 100644 --- a/UnitTests/Common/Utilities/DelayedTaskTests.cs +++ b/test/AMWD.Common.Tests/Utilities/DelayedTaskTest.cs @@ -3,13 +3,11 @@ using System.Diagnostics; using System.Threading; using System.Threading.Tasks; using AMWD.Common.Utilities; -using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace UnitTests.Common.Utilities +namespace AMWD.Common.Tests.Utilities { [TestClass] - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - public class DelayedTaskTests + public class DelayedTaskTest { [TestMethod] public void ShouldCreateNewDelayedTaskNotStarting() diff --git a/UnitTests/Common/Utilities/DelayedTaskWithResultTests.cs b/test/AMWD.Common.Tests/Utilities/DelayedTaskWithResultTest.cs similarity index 92% rename from UnitTests/Common/Utilities/DelayedTaskWithResultTests.cs rename to test/AMWD.Common.Tests/Utilities/DelayedTaskWithResultTest.cs index caf3673..886e509 100644 --- a/UnitTests/Common/Utilities/DelayedTaskWithResultTests.cs +++ b/test/AMWD.Common.Tests/Utilities/DelayedTaskWithResultTest.cs @@ -2,13 +2,11 @@ using System.Threading; using System.Threading.Tasks; using AMWD.Common.Utilities; -using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace UnitTests.Common.Utilities +namespace AMWD.Common.Tests.Utilities { [TestClass] - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - public class DelayedTaskWithResultTests + public class DelayedTaskWithResultTest { [TestMethod] public void ShouldCreateNewDelayedTaskNotStarting() diff --git a/UnitTests/Common/Utils/CryptographyHelperSaltMock.cs b/test/AMWD.Common.Tests/Utils/CryptographyHelperSaltMock.cs similarity index 91% rename from UnitTests/Common/Utils/CryptographyHelperSaltMock.cs rename to test/AMWD.Common.Tests/Utils/CryptographyHelperSaltMock.cs index b56caa9..d1f4783 100644 --- a/UnitTests/Common/Utils/CryptographyHelperSaltMock.cs +++ b/test/AMWD.Common.Tests/Utils/CryptographyHelperSaltMock.cs @@ -2,7 +2,7 @@ using System.Security.Cryptography; using ReflectionMagic; -namespace UnitTests.Common.Utils +namespace AMWD.Common.Tests.Utils { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] internal class CryptographyHelperSaltMock : IDisposable diff --git a/UnitTests/Common/Utils/CustomMultipleAttribute.cs b/test/AMWD.Common.Tests/Utils/CustomMultipleAttribute.cs similarity index 85% rename from UnitTests/Common/Utils/CustomMultipleAttribute.cs rename to test/AMWD.Common.Tests/Utils/CustomMultipleAttribute.cs index 2c2ddee..878de29 100644 --- a/UnitTests/Common/Utils/CustomMultipleAttribute.cs +++ b/test/AMWD.Common.Tests/Utils/CustomMultipleAttribute.cs @@ -1,6 +1,6 @@ using System; -namespace UnitTests.Common.Utils +namespace AMWD.Common.Tests.Utils { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] [AttributeUsage(AttributeTargets.All, AllowMultiple = true)] diff --git a/UnitTests/Common/Utils/JsonTestClass.cs b/test/AMWD.Common.Tests/Utils/JsonTestClass.cs similarity index 92% rename from UnitTests/Common/Utils/JsonTestClass.cs rename to test/AMWD.Common.Tests/Utils/JsonTestClass.cs index 5dfa4de..5410ca9 100644 --- a/UnitTests/Common/Utils/JsonTestClass.cs +++ b/test/AMWD.Common.Tests/Utils/JsonTestClass.cs @@ -1,6 +1,6 @@ using System; -namespace UnitTests.Common.Utils +namespace AMWD.Common.Tests.Utils { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] internal class JsonTestClass diff --git a/UnitTests/Common/Utils/TimeZoneInfoLocalMock.cs b/test/AMWD.Common.Tests/Utils/TimeZoneInfoLocalMock.cs similarity index 92% rename from UnitTests/Common/Utils/TimeZoneInfoLocalMock.cs rename to test/AMWD.Common.Tests/Utils/TimeZoneInfoLocalMock.cs index 4db4b7c..bea1381 100644 --- a/UnitTests/Common/Utils/TimeZoneInfoLocalMock.cs +++ b/test/AMWD.Common.Tests/Utils/TimeZoneInfoLocalMock.cs @@ -1,7 +1,7 @@ using System; using ReflectionMagic; -namespace UnitTests.Common.Utils +namespace AMWD.Common.Tests.Utils { [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] internal class TimeZoneInfoLocalMock : IDisposable diff --git a/test/Directory.Build.props b/test/Directory.Build.props new file mode 100644 index 0000000..ade4169 --- /dev/null +++ b/test/Directory.Build.props @@ -0,0 +1,25 @@ + + + false + true + true + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + +