diff --git a/Build/README.md b/Build/README.md index cf17b991..f5304836 100644 --- a/Build/README.md +++ b/Build/README.md @@ -3,14 +3,14 @@ build.ps1 is designed to run on windows - PowerShell Desktop 5.1 +- PowerShell [7.3.0](https://github.com/PowerShell/PowerShell/releases/tag/v7.3.0) for .net 7.0 tests - PowerShell [7.2.1](https://github.com/PowerShell/PowerShell/releases/tag/v7.2.1) for .net 6.0 tests - PowerShell [7.1.5](https://github.com/PowerShell/PowerShell/releases/tag/v7.1.5) for .net 5.0 tests - PowerShell [7.0.8](https://github.com/PowerShell/PowerShell/releases/tag/v7.0.8) for .net core 3.1 tests -- Install-Module -Name InvokeBuild -RequiredVersion 5.8.7 -- ThirdPartyLibraries https://www.nuget.org/packages/ThirdPartyLibraries.GlobalTool/ +- Install-Module -Name [InvokeBuild](https://www.powershellgallery.com/packages/InvokeBuild/5.9.12) -RequiredVersion 5.9.12 +- Install-Module -Name [ThirdPartyLibraries](https://www.powershellgallery.com/packages/ThirdPartyLibraries/3.1.2) -RequiredVersion 3.1.2 - .net framework 4.7.2+ sdk -- .net core 3.1 sdk -- .net 5.0 sdk +- .net 7.0 sdk - docker, switched to linux containers ## How to build @@ -19,7 +19,7 @@ build.ps1 is designed to run on windows PS> git clone https://github.com/max-ieremenko/SqlDatabase.git # build required docker images -PS> .\Build\create-images.ps1 +PS> .\Build\create-images.ps1 # run build PS> .\Build\build.ps1 diff --git a/Build/build-scripts.ps1 b/Build/build-scripts.ps1 index d28438c2..08afa64c 100644 --- a/Build/build-scripts.ps1 +++ b/Build/build-scripts.ps1 @@ -25,8 +25,7 @@ function Get-AssemblyVersion($assemblyInfoCsPath) { } function Get-RepositoryCommitId { - $response = (Invoke-RestMethod -Uri "https://api.github.com/repos/max-ieremenko/SqlDatabase/commits/master") - return $response.sha + git rev-parse HEAD } function Start-Mssql { @@ -157,26 +156,30 @@ function Wait-Connection { $timeout = 50 ) - $connection = New-Object -TypeName $connectionName -ArgumentList $connectionString - try { - for ($i = 0; $i -lt $timeout; $i++) { - try { - $connection.Open() - return - } - catch { - Start-Sleep -Seconds 1 - } + function Test-Connection { + $connection = New-Object -TypeName $connectionName -ArgumentList $connectionString + try { + $connection.Open() } + finally { + $connection.Dispose() + } + } + for ($i = 0; $i -lt $timeout; $i++) { try { - $connection.Open() + Test-Connection + return } catch { - throw "$connectionName $connectionString" + Start-Sleep -Seconds 1 } } - finally { - $connection.Dispose() + + try { + Test-Connection + } + catch { + throw "$connectionName $connectionString" } } \ No newline at end of file diff --git a/Build/build-tasks.it-tool-linux.ps1 b/Build/build-tasks.it-tool-linux.ps1 index ad7f1ad6..65431c39 100644 --- a/Build/build-tasks.it-tool-linux.ps1 +++ b/Build/build-tasks.it-tool-linux.ps1 @@ -32,7 +32,7 @@ task RunTest { $test = (Join-Path $settings.integrationTests $database) + ":/test" exec { - docker run --rm ` + docker run -it --rm ` -v $app ` -v $test ` --env connectionString=$connectionString ` diff --git a/Build/build-tasks.ps1 b/Build/build-tasks.ps1 index 947a2bb4..52261cd2 100644 --- a/Build/build-tasks.ps1 +++ b/Build/build-tasks.ps1 @@ -41,7 +41,7 @@ task Build { } task ThirdPartyNotices { - Invoke-Build -File build-tasks.third-party.ps1 -Task "ThirdParty" -settings $settings + Invoke-Build -File build-tasks.third-party.ps1 -settings $settings } task PackGlobalTool { @@ -103,25 +103,16 @@ task PackManualDownload PackGlobalTool, PackPoweShellModule, { $thirdParty = Join-Path $settings.bin "ThirdPartyNotices.txt" $packageVersion = $settings.version - $destination = Join-Path $out "SqlDatabase.$packageVersion-net452.zip" - $source = Join-Path $settings.bin "SqlDatabase\net452\*" - Compress-Archive -Path $source, $lic, $thirdParty -DestinationPath $destination - $destination = Join-Path $out "SqlDatabase.$packageVersion-PowerShell.zip" $source = Join-Path $settings.artifactsPowerShell "*" Compress-Archive -Path $source -DestinationPath $destination - $destination = Join-Path $out "SqlDatabase.$packageVersion-netcore31.zip" - $source = Join-Path $settings.bin "SqlDatabase\netcoreapp3.1\publish\*" - Compress-Archive -Path $source, $lic, $thirdParty -DestinationPath $destination - - $destination = Join-Path $out "SqlDatabase.$packageVersion-net50.zip" - $source = Join-Path $settings.bin "SqlDatabase\net5.0\publish\*" - Compress-Archive -Path $source, $lic, $thirdParty -DestinationPath $destination - - $destination = Join-Path $out "SqlDatabase.$packageVersion-net60.zip" - $source = Join-Path $settings.bin "SqlDatabase\net6.0\publish\*" - Compress-Archive -Path $source, $lic, $thirdParty -DestinationPath $destination + $targets = "net452", "netcoreapp3.1", "net5.0", "net6.0", "net7.0" + foreach ($target in $targets) { + $destination = Join-Path $out "SqlDatabase.$packageVersion-$target.zip" + $source = Join-Path $settings.bin "SqlDatabase\$target\*" + Compress-Archive -Path $source, $lic, $thirdParty -DestinationPath $destination + } } task UnitTest { @@ -130,6 +121,7 @@ task UnitTest { @{ File = "build-tasks.unit-test.ps1"; Task = "Test"; settings = $settings; targetFramework = "netcoreapp3.1" } @{ File = "build-tasks.unit-test.ps1"; Task = "Test"; settings = $settings; targetFramework = "net5.0" } @{ File = "build-tasks.unit-test.ps1"; Task = "Test"; settings = $settings; targetFramework = "net6.0" } + @{ File = "build-tasks.unit-test.ps1"; Task = "Test"; settings = $settings; targetFramework = "net7.0" } ) Build-Parallel $builds -ShowParameter targetFramework -MaximumBuilds 4 @@ -179,14 +171,14 @@ task PsCoreTest { # show-powershell-images.ps1 $images = $( "mcr.microsoft.com/powershell:6.1.0-ubuntu-18.04" - , "mcr.microsoft.com/powershell:6.1.1-alpine-3.8" - , "mcr.microsoft.com/powershell:6.1.2-alpine-3.8" - , "mcr.microsoft.com/powershell:6.1.3-alpine-3.8" - , "mcr.microsoft.com/powershell:6.2.0-alpine-3.8" - , "mcr.microsoft.com/powershell:6.2.1-alpine-3.8" - , "mcr.microsoft.com/powershell:6.2.2-alpine-3.8" + , "mcr.microsoft.com/powershell:6.1.1-ubuntu-18.04" + , "mcr.microsoft.com/powershell:6.1.2-ubuntu-18.04" + , "mcr.microsoft.com/powershell:6.1.3-ubuntu-18.04" + , "mcr.microsoft.com/powershell:6.2.0-ubuntu-18.04" + , "mcr.microsoft.com/powershell:6.2.1-ubuntu-18.04" + , "mcr.microsoft.com/powershell:6.2.2-ubuntu-18.04" , "mcr.microsoft.com/powershell:6.2.3-ubuntu-18.04" - , "mcr.microsoft.com/powershell:6.2.4-alpine-3.8" + , "mcr.microsoft.com/powershell:6.2.4-ubuntu-18.04" , "mcr.microsoft.com/powershell:7.0.0-ubuntu-18.04" , "mcr.microsoft.com/powershell:7.0.1-ubuntu-18.04" , "mcr.microsoft.com/powershell:7.0.2-ubuntu-18.04" @@ -198,7 +190,8 @@ task PsCoreTest { , "mcr.microsoft.com/powershell:7.1.4-ubuntu-20.04" , "mcr.microsoft.com/powershell:7.2.0-ubuntu-20.04" , "mcr.microsoft.com/powershell:7.2.1-ubuntu-20.04" - , "mcr.microsoft.com/powershell:7.3.0-preview.1-ubuntu-20.04") + , "mcr.microsoft.com/powershell:7.2.2-ubuntu-20.04" + , "mcr.microsoft.com/powershell:7.3-ubuntu-20.04") $builds = @() foreach ($image in $images) { @@ -220,7 +213,8 @@ task SdkToolTest { $images = $( "sqldatabase/dotnet_pwsh:3.1-sdk" , "sqldatabase/dotnet_pwsh:5.0-sdk" - , "sqldatabase/dotnet_pwsh:6.0-sdk") + , "sqldatabase/dotnet_pwsh:6.0-sdk" + , "sqldatabase/dotnet_pwsh:7.0-sdk") $builds = @() foreach ($image in $images) { @@ -240,9 +234,10 @@ task SdkToolTest { task NetRuntimeLinuxTest { $testCases = $( - @{ targetFramework = "netcore31"; image = "sqldatabase/dotnet_pwsh:3.1-runtime" } - , @{ targetFramework = "net50"; image = "sqldatabase/dotnet_pwsh:5.0-runtime" } - , @{ targetFramework = "net60"; image = "sqldatabase/dotnet_pwsh:6.0-runtime" } + @{ targetFramework = "netcoreapp3.1"; image = "sqldatabase/dotnet_pwsh:3.1-runtime" } + , @{ targetFramework = "net5.0"; image = "sqldatabase/dotnet_pwsh:5.0-runtime" } + , @{ targetFramework = "net6.0"; image = "sqldatabase/dotnet_pwsh:6.0-runtime" } + , @{ targetFramework = "net7.0"; image = "sqldatabase/dotnet_pwsh:7.0-runtime" } ) $builds = @() @@ -265,9 +260,10 @@ task NetRuntimeLinuxTest { task NetRuntimeWindowsTest { $testCases = $( "net452" - , "netcore31" - , "net50" - , "net60" + , "netcoreapp3.1" + , "net5.0" + , "net6.0" + , "net7.0" ) $builds = @() diff --git a/Build/build-tasks.third-party.ps1 b/Build/build-tasks.third-party.ps1 index ad3f751c..b0d83e82 100644 --- a/Build/build-tasks.third-party.ps1 +++ b/Build/build-tasks.third-party.ps1 @@ -2,47 +2,32 @@ param( $settings ) -function Write-ThirdPartyNotices($appName, $sources, $repository, $out) { - $source = $sources | ForEach-Object {"-source", $_} - $outTemp = Join-Path $out "Temp" +task Default Update, Test, Publish - Exec { - ThirdPartyLibraries update ` - -appName $appName ` - $source ` - -repository $repository - } +Enter-Build { + $repository = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot "third-party-libraries")) - Exec { - ThirdPartyLibraries validate ` - -appName $appName ` - $source ` - -repository $repository - } - - Exec { - ThirdPartyLibraries generate ` - -appName $appName ` - -repository $repository ` - -to $outTemp - } - - Move-Item (Join-Path $outTemp "ThirdPartyNotices.txt") $out -Force - Remove-Item -Path $outTemp -Recurse -Force -} - -task ThirdParty { $sourceDir = $settings.sources - $thirdPartyRepository = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot "third-party-libraries")) - $binDir = $settings.bin - - $sources = @( - (Join-Path $sourceDir "SqlDatabase"), + $sources = (Join-Path $sourceDir "SqlDatabase"), (Join-Path $sourceDir "SqlDatabase.Test"), (Join-Path $sourceDir "SqlDatabase.PowerShell"), (Join-Path $sourceDir "SqlDatabase.PowerShell.Test"), (Join-Path $sourceDir "SqlDatabase.Test") - ) - - Write-ThirdPartyNotices "SqlDatabase" $sources $thirdPartyRepository $binDir +} + +task Update { + Update-ThirdPartyLibrariesRepository -AppName "SqlDatabase" -Source $sources -Repository $repository +} + +task Test { + Test-ThirdPartyLibrariesRepository -AppName "SqlDatabase" -Source $sources -Repository $repository +} + +task Publish { + $outTemp = Join-Path $settings.bin "Temp" + $title = "SqlDatabase " + $settings.version + Publish-ThirdPartyNotices -AppName "SqlDatabase" -Repository $repository -Title $title -To $outTemp + + Move-Item (Join-Path $outTemp "ThirdPartyNotices.txt") $settings.bin -Force + Remove-Item -Path $outTemp -Recurse -Force } \ No newline at end of file diff --git a/Build/build.ps1 b/Build/build.ps1 index 408ef719..7cd2fd66 100644 --- a/Build/build.ps1 +++ b/Build/build.ps1 @@ -1,6 +1,8 @@ -#Requires -Modules @{ModuleName='InvokeBuild'; RequiredVersion='5.8.7'} +#Requires -Version "7.0" +#Requires -Modules @{ ModuleName="InvokeBuild"; ModuleVersion="5.9.12" } Set-StrictMode -Version Latest +$ErrorActionPreference = "Stop" $file = Join-Path $PSScriptRoot "build-tasks.ps1" Invoke-Build -File $file \ No newline at end of file diff --git a/Build/create-images-tasks.ps1 b/Build/create-images-tasks.ps1 index 2a9f1c8f..0747aec6 100644 --- a/Build/create-images-tasks.ps1 +++ b/Build/create-images-tasks.ps1 @@ -5,6 +5,8 @@ task Default ` , BuildDotnetRuntime50 ` , BuildDotnetSdk60 ` , BuildDotnetRuntime60 ` + , BuildDotnetSdk70 ` + , BuildDotnetRuntime70 ` , BuildMsSqlDatabase ` , BuildPgSqlDatabase ` , BuildMySqlDatabase @@ -92,3 +94,21 @@ task BuildDotnetRuntime60 { . } } + +task BuildDotnetSdk70 { + exec { + docker build ` + -f image-dotnet-sdk-7.0.dockerfile ` + -t sqldatabase/dotnet_pwsh:7.0-sdk ` + . + } +} + +task BuildDotnetRuntime70 { + exec { + docker build ` + -f image-dotnet-runtime-7.0.dockerfile ` + -t sqldatabase/dotnet_pwsh:7.0-runtime ` + . + } +} \ No newline at end of file diff --git a/Build/create-images.ps1 b/Build/create-images.ps1 index 6286c445..61280f6a 100644 --- a/Build/create-images.ps1 +++ b/Build/create-images.ps1 @@ -1,4 +1,5 @@ -#Requires -Modules @{ModuleName='InvokeBuild'; RequiredVersion='5.8.7'} +#Requires -Version "7.0" +#Requires -Modules @{ ModuleName="InvokeBuild"; ModuleVersion="5.9.12" } Set-StrictMode -Version Latest diff --git a/Build/image-dotnet-runtime-7.0.dockerfile b/Build/image-dotnet-runtime-7.0.dockerfile new file mode 100644 index 00000000..cab89d81 --- /dev/null +++ b/Build/image-dotnet-runtime-7.0.dockerfile @@ -0,0 +1,8 @@ +FROM mcr.microsoft.com/dotnet/runtime:7.0 + +RUN apt-get update && \ + apt-get install -y curl && \ + curl -L https://github.com/PowerShell/PowerShell/releases/download/v7.3.0/powershell_7.3.0-1.deb_amd64.deb --output powershell.deb && \ + dpkg -i powershell.deb && \ + apt-get install -f && \ + rm -f powershell.deb \ No newline at end of file diff --git a/Build/image-dotnet-sdk-7.0.dockerfile b/Build/image-dotnet-sdk-7.0.dockerfile new file mode 100644 index 00000000..a2e09e63 --- /dev/null +++ b/Build/image-dotnet-sdk-7.0.dockerfile @@ -0,0 +1,7 @@ +FROM mcr.microsoft.com/dotnet/sdk:7.0 + +RUN apt-get update && \ + curl -L https://github.com/PowerShell/PowerShell/releases/download/v7.3.0/powershell_7.3.0-1.deb_amd64.deb --output powershell.deb && \ + dpkg -i powershell.deb && \ + apt-get install -f && \ + rm -f powershell.deb \ No newline at end of file diff --git a/Build/third-party-libraries/configuration/third-party-notices-template.txt b/Build/third-party-libraries/configuration/third-party-notices-template.txt index 9d40365f..d1aa3308 100644 --- a/Build/third-party-libraries/configuration/third-party-notices-template.txt +++ b/Build/third-party-libraries/configuration/third-party-notices-template.txt @@ -1,5 +1,5 @@ -SqlDatabase -************ +{{Title}} +{% for i in (1..Title.size) %}*{% endfor %} THIRD-PARTY SOFTWARE NOTICES AND INFORMATION diff --git a/Build/third-party-libraries/packages/nuget.org/castle.core/4.4.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/castle.core/4.4.0/package.nuspec deleted file mode 100644 index 8162c5ed..00000000 --- a/Build/third-party-libraries/packages/nuget.org/castle.core/4.4.0/package.nuspec +++ /dev/null @@ -1,49 +0,0 @@ - - - - Castle.Core - 4.4.0 - Castle Project Contributors - Castle Project Contributors - false - http://www.apache.org/licenses/LICENSE-2.0.html - http://www.castleproject.org/ - http://www.castleproject.org/img/castle-logo.png - Castle Core, including DynamicProxy, Logging Abstractions and DictionaryAdapter - Copyright (c) 2004-2019 Castle Project - http://www.castleproject.org/ - castle dynamicproxy dynamic proxy dynamicproxy2 dictionaryadapter emailsender - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/castle.core/4.4.0/readme.md b/Build/third-party-libraries/packages/nuget.org/castle.core/4.4.0/readme.md deleted file mode 100644 index 7bc282f5..00000000 --- a/Build/third-party-libraries/packages/nuget.org/castle.core/4.4.0/readme.md +++ /dev/null @@ -1,35 +0,0 @@ -Castle.Core [4.4.0](https://www.nuget.org/packages/Castle.Core/4.4.0) --------------------- - -Used by: SqlDatabase internal - -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 - -License: [Apache-2.0](../../../../licenses/apache-2.0) - -- package license: [Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0.html) -- repository license: [Unknown](https://github.com/castleproject/Core) , License should be verified on https://github.com/castleproject/Core -- project license: [Unknown](http://www.castleproject.org/) , License should be verified on http://www.castleproject.org/ - -Description ------------ -Castle Core, including DynamicProxy, Logging Abstractions and DictionaryAdapter - -Remarks ------------ -no remarks - - -Dependencies 6 ------------ - -|Name|Version| -|----------|:----| -|[System.Collections.Specialized](../../../../packages/nuget.org/system.collections.specialized/4.3.0)|4.3.0| -|[System.ComponentModel](../../../../packages/nuget.org/system.componentmodel/4.3.0)|4.3.0| -|[System.ComponentModel.TypeConverter](../../../../packages/nuget.org/system.componentmodel.typeconverter/4.3.0)|4.3.0| -|[System.Dynamic.Runtime](../../../../packages/nuget.org/system.dynamic.runtime/4.3.0)|4.3.0| -|[System.Reflection.TypeExtensions](../../../../packages/nuget.org/system.reflection.typeextensions/4.3.0)|4.3.0| -|[System.Xml.XmlDocument](../../../../packages/nuget.org/system.xml.xmldocument/4.3.0)|4.3.0| - -*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/castle.core/4.4.0/index.json b/Build/third-party-libraries/packages/nuget.org/castle.core/5.1.0/index.json similarity index 57% rename from Build/third-party-libraries/packages/nuget.org/castle.core/4.4.0/index.json rename to Build/third-party-libraries/packages/nuget.org/castle.core/5.1.0/index.json index 7cd8bd57..8a94c743 100644 --- a/Build/third-party-libraries/packages/nuget.org/castle.core/4.4.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/castle.core/5.1.0/index.json @@ -11,32 +11,13 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net472" ], "Dependencies": [ { - "Name": "System.Collections.Specialized", - "Version": "4.3.0" - }, - { - "Name": "System.ComponentModel", - "Version": "4.3.0" - }, - { - "Name": "System.ComponentModel.TypeConverter", - "Version": "4.3.0" - }, - { - "Name": "System.Dynamic.Runtime", - "Version": "4.3.0" - }, - { - "Name": "System.Reflection.TypeExtensions", - "Version": "4.3.0" - }, - { - "Name": "System.Xml.XmlDocument", - "Version": "4.3.0" + "Name": "System.Diagnostics.EventLog", + "Version": "4.7.0" } ] } @@ -45,7 +26,7 @@ { "Subject": "package", "Code": "Apache-2.0", - "HRef": "http://www.apache.org/licenses/LICENSE-2.0.html", + "HRef": "https://licenses.nuget.org/Apache-2.0", "Description": null }, { diff --git a/Build/third-party-libraries/packages/nuget.org/castle.core/4.4.0/repository-LICENSE b/Build/third-party-libraries/packages/nuget.org/castle.core/5.1.0/package-LICENSE similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/castle.core/4.4.0/repository-LICENSE rename to Build/third-party-libraries/packages/nuget.org/castle.core/5.1.0/package-LICENSE diff --git a/Build/third-party-libraries/packages/nuget.org/castle.core/5.1.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/castle.core/5.1.0/package.nuspec new file mode 100644 index 00000000..04839f87 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/castle.core/5.1.0/package.nuspec @@ -0,0 +1,33 @@ + + + + Castle.Core + 5.1.0 + Castle Project Contributors + Apache-2.0 + https://licenses.nuget.org/Apache-2.0 + castle-logo.png + http://www.castleproject.org/ + http://www.castleproject.org/img/castle-logo.png + Castle Core, including DynamicProxy, Logging Abstractions and DictionaryAdapter + Copyright (c) 2004-2022 Castle Project - http://www.castleproject.org/ + castle dynamicproxy dynamic proxy dynamicproxy2 dictionaryadapter emailsender + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/castle.core/5.1.0/readme.md b/Build/third-party-libraries/packages/nuget.org/castle.core/5.1.0/readme.md new file mode 100644 index 00000000..6d4882ed --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/castle.core/5.1.0/readme.md @@ -0,0 +1,30 @@ +Castle.Core [5.1.0](https://www.nuget.org/packages/Castle.Core/5.1.0) +-------------------- + +Used by: SqlDatabase internal + +Target frameworks: net472, net5.0, net6.0, net7.0, netcoreapp3.1 + +License: [Apache-2.0](../../../../licenses/apache-2.0) + +- package license: [Apache-2.0](https://licenses.nuget.org/Apache-2.0) +- repository license: [Unknown](https://github.com/castleproject/Core) , License should be verified on https://github.com/castleproject/Core +- project license: [Unknown](http://www.castleproject.org/) , License should be verified on http://www.castleproject.org/ + +Description +----------- +Castle Core, including DynamicProxy, Logging Abstractions and DictionaryAdapter + +Remarks +----------- +no remarks + + +Dependencies 1 +----------- + +|Name|Version| +|----------|:----| +|[System.Diagnostics.EventLog](../../../../packages/nuget.org/system.diagnostics.eventlog/4.7.0)|4.7.0| + +*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/castle.core/4.4.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/castle.core/5.1.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/castle.core/4.4.0/remarks.md rename to Build/third-party-libraries/packages/nuget.org/castle.core/5.1.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/castle.core/4.4.0/package-LICENSE b/Build/third-party-libraries/packages/nuget.org/castle.core/5.1.0/repository-LICENSE similarity index 89% rename from Build/third-party-libraries/packages/nuget.org/castle.core/4.4.0/package-LICENSE rename to Build/third-party-libraries/packages/nuget.org/castle.core/5.1.0/repository-LICENSE index ebb9ac9f..c8680e41 100644 --- a/Build/third-party-libraries/packages/nuget.org/castle.core/4.4.0/package-LICENSE +++ b/Build/third-party-libraries/packages/nuget.org/castle.core/5.1.0/repository-LICENSE @@ -1,4 +1,4 @@ -Copyright 2004-2016 Castle Project - http://www.castleproject.org/ +Copyright 2004-2021 Castle Project - http://www.castleproject.org/ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/Build/third-party-libraries/packages/nuget.org/castle.core/4.4.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/castle.core/5.1.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/castle.core/4.4.0/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/castle.core/5.1.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.0.123/index.json b/Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.0.123/index.json index ec6c44a2..0f1a186f 100644 --- a/Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.0.123/index.json +++ b/Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.0.123/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net472" ] } diff --git a/Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.0.123/readme.md b/Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.0.123/readme.md index 6a65c08b..d9ad4978 100644 --- a/Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.0.123/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/dapper.strongname/2.0.123/readme.md @@ -3,7 +3,7 @@ Dapper.StrongName [2.0.123](https://www.nuget.org/packages/Dapper.StrongName/2.0 Used by: SqlDatabase internal -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 +Target frameworks: net472, net5.0, net6.0, net7.0, netcoreapp3.1 License: [Apache-2.0](../../../../licenses/apache-2.0) diff --git a/Build/third-party-libraries/packages/nuget.org/diffengine/6.4.9/index.json b/Build/third-party-libraries/packages/nuget.org/diffengine/10.0.0/index.json similarity index 85% rename from Build/third-party-libraries/packages/nuget.org/diffengine/6.4.9/index.json rename to Build/third-party-libraries/packages/nuget.org/diffengine/10.0.0/index.json index 09eb067b..5c6c8151 100644 --- a/Build/third-party-libraries/packages/nuget.org/diffengine/6.4.9/index.json +++ b/Build/third-party-libraries/packages/nuget.org/diffengine/10.0.0/index.json @@ -11,12 +11,17 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net472" ], "Dependencies": [ { "Name": "EmptyFiles", - "Version": "2.3.3" + "Version": "2.8.0" + }, + { + "Name": "System.Management", + "Version": "5.0.0" } ] } diff --git a/Build/third-party-libraries/packages/nuget.org/diffengine/10.0.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/diffengine/10.0.0/package.nuspec new file mode 100644 index 00000000..5929b640 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/diffengine/10.0.0/package.nuspec @@ -0,0 +1,63 @@ + + + + DiffEngine + 10.0.0 + https://github.com/VerifyTests/DiffEngine/graphs/contributors + MIT + https://licenses.nuget.org/MIT + icon.png + https://github.com/VerifyTests/DiffEngine + Launches diff tools based on file extensions. Designed to be consumed by snapshot testing libraries. + Copyright 2022. All rights reserved + Testing, Snapshot, Diff, Compare + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/diffengine/6.4.9/project-license.txt b/Build/third-party-libraries/packages/nuget.org/diffengine/10.0.0/project-license.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/diffengine/6.4.9/project-license.txt rename to Build/third-party-libraries/packages/nuget.org/diffengine/10.0.0/project-license.txt diff --git a/Build/third-party-libraries/packages/nuget.org/diffengine/6.4.9/readme.md b/Build/third-party-libraries/packages/nuget.org/diffengine/10.0.0/readme.md similarity index 64% rename from Build/third-party-libraries/packages/nuget.org/diffengine/6.4.9/readme.md rename to Build/third-party-libraries/packages/nuget.org/diffengine/10.0.0/readme.md index b2ecf707..00489c79 100644 --- a/Build/third-party-libraries/packages/nuget.org/diffengine/6.4.9/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/diffengine/10.0.0/readme.md @@ -1,9 +1,9 @@ -DiffEngine [6.4.9](https://www.nuget.org/packages/DiffEngine/6.4.9) +DiffEngine [10.0.0](https://www.nuget.org/packages/DiffEngine/10.0.0) -------------------- Used by: SqlDatabase internal -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 +Target frameworks: net472, net5.0, net6.0, net7.0, netcoreapp3.1 License: [MIT](../../../../licenses/mit) @@ -20,11 +20,12 @@ Remarks no remarks -Dependencies 1 +Dependencies 2 ----------- |Name|Version| |----------|:----| -|[EmptyFiles](../../../../packages/nuget.org/emptyfiles/2.3.3)|2.3.3| +|[EmptyFiles](../../../../packages/nuget.org/emptyfiles/2.8.0)|2.8.0| +|[System.Management](../../../../packages/nuget.org/system.management/5.0.0)|5.0.0| *This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/diffengine/6.4.9/remarks.md b/Build/third-party-libraries/packages/nuget.org/diffengine/10.0.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/diffengine/6.4.9/remarks.md rename to Build/third-party-libraries/packages/nuget.org/diffengine/10.0.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/diffengine/6.4.9/repository-license.txt b/Build/third-party-libraries/packages/nuget.org/diffengine/10.0.0/repository-license.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/diffengine/6.4.9/repository-license.txt rename to Build/third-party-libraries/packages/nuget.org/diffengine/10.0.0/repository-license.txt diff --git a/Build/third-party-libraries/packages/nuget.org/diffengine/6.4.9/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/diffengine/10.0.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/diffengine/6.4.9/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/diffengine/10.0.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/diffengine/6.4.9/package.nuspec b/Build/third-party-libraries/packages/nuget.org/diffengine/6.4.9/package.nuspec deleted file mode 100644 index 0b4ad7ad..00000000 --- a/Build/third-party-libraries/packages/nuget.org/diffengine/6.4.9/package.nuspec +++ /dev/null @@ -1,34 +0,0 @@ - - - - DiffEngine - 6.4.9 - https://github.com/VerifyTests/DiffEngine/graphs/contributors - false - MIT - https://licenses.nuget.org/MIT - icon.png - https://github.com/VerifyTests/DiffEngine - Launches diff tools based on file extensions. Designed to be consumed by snapshot testing libraries. - Copyright 2020. All rights reserved - Testing, Snapshot, Diff, Compare - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/emptyfiles/2.3.3/index.json b/Build/third-party-libraries/packages/nuget.org/emptyfiles/2.8.0/index.json similarity index 97% rename from Build/third-party-libraries/packages/nuget.org/emptyfiles/2.3.3/index.json rename to Build/third-party-libraries/packages/nuget.org/emptyfiles/2.8.0/index.json index 143e8d58..4d10c323 100644 --- a/Build/third-party-libraries/packages/nuget.org/emptyfiles/2.3.3/index.json +++ b/Build/third-party-libraries/packages/nuget.org/emptyfiles/2.8.0/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net472" ] } diff --git a/Build/third-party-libraries/packages/nuget.org/emptyfiles/2.3.3/package.nuspec b/Build/third-party-libraries/packages/nuget.org/emptyfiles/2.8.0/package.nuspec similarity index 78% rename from Build/third-party-libraries/packages/nuget.org/emptyfiles/2.3.3/package.nuspec rename to Build/third-party-libraries/packages/nuget.org/emptyfiles/2.8.0/package.nuspec index ff6883c5..27fce73e 100644 --- a/Build/third-party-libraries/packages/nuget.org/emptyfiles/2.3.3/package.nuspec +++ b/Build/third-party-libraries/packages/nuget.org/emptyfiles/2.8.0/package.nuspec @@ -2,16 +2,15 @@ EmptyFiles - 2.3.3 + 2.8.0 https://github.com/SimonCropp/EmptyFiles/graphs/contributors - false MIT https://licenses.nuget.org/MIT icon.png https://github.com/SimonCropp/EmptyFiles A collection of minimal binary files. - Copyright 2020. All rights reserved - + Copyright 2021. All rights reserved + diff --git a/Build/third-party-libraries/packages/nuget.org/emptyfiles/2.3.3/project-license.txt b/Build/third-party-libraries/packages/nuget.org/emptyfiles/2.8.0/project-license.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/emptyfiles/2.3.3/project-license.txt rename to Build/third-party-libraries/packages/nuget.org/emptyfiles/2.8.0/project-license.txt diff --git a/Build/third-party-libraries/packages/nuget.org/emptyfiles/2.3.3/readme.md b/Build/third-party-libraries/packages/nuget.org/emptyfiles/2.8.0/readme.md similarity index 77% rename from Build/third-party-libraries/packages/nuget.org/emptyfiles/2.3.3/readme.md rename to Build/third-party-libraries/packages/nuget.org/emptyfiles/2.8.0/readme.md index 5c6b0acc..9cd0372b 100644 --- a/Build/third-party-libraries/packages/nuget.org/emptyfiles/2.3.3/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/emptyfiles/2.8.0/readme.md @@ -1,9 +1,9 @@ -EmptyFiles [2.3.3](https://www.nuget.org/packages/EmptyFiles/2.3.3) +EmptyFiles [2.8.0](https://www.nuget.org/packages/EmptyFiles/2.8.0) -------------------- Used by: SqlDatabase internal -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 +Target frameworks: net472, net5.0, net6.0, net7.0, netcoreapp3.1 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/emptyfiles/2.3.3/remarks.md b/Build/third-party-libraries/packages/nuget.org/emptyfiles/2.8.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/emptyfiles/2.3.3/remarks.md rename to Build/third-party-libraries/packages/nuget.org/emptyfiles/2.8.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/emptyfiles/2.3.3/repository-license.txt b/Build/third-party-libraries/packages/nuget.org/emptyfiles/2.8.0/repository-license.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/emptyfiles/2.3.3/repository-license.txt rename to Build/third-party-libraries/packages/nuget.org/emptyfiles/2.8.0/repository-license.txt diff --git a/Build/third-party-libraries/packages/nuget.org/emptyfiles/2.3.3/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/emptyfiles/2.8.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/emptyfiles/2.3.3/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/emptyfiles/2.8.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.0.0/index.json b/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.4.0/index.json similarity index 93% rename from Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.0.0/index.json rename to Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.4.0/index.json index cf09ab3a..04920ef7 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.0.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.4.0/index.json @@ -1,6 +1,6 @@ { "License": { - "Code": "MIT", + "Code": "ms-net-library", "Status": "AutomaticallyApproved" }, "UsedBy": [ @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net472" ] } diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.0.0/package-LICENSE_NET.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.4.0/package-LICENSE_NET.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.0.0/package-LICENSE_NET.txt rename to Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.4.0/package-LICENSE_NET.txt diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.0.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.4.0/package.nuspec similarity index 83% rename from Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.0.0/package.nuspec rename to Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.4.0/package.nuspec index ca1fecf8..458733c3 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.0.0/package.nuspec +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.4.0/package.nuspec @@ -2,7 +2,7 @@ Microsoft.CodeCoverage - 17.0.0 + 17.4.0 Microsoft.CodeCoverage Microsoft Microsoft @@ -15,10 +15,10 @@ Microsoft.CodeCoverage package brings infra for collecting code coverage from vstest.console.exe and "dotnet test". © Microsoft Corporation. All rights reserved. vstest visual-studio unittest testplatform mstest microsoft test testing codecoverage code-coverage - + - - + + \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.0.0/project-LICENSE b/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.4.0/project-LICENSE similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.0.0/project-LICENSE rename to Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.4.0/project-LICENSE diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.0.0/readme.md b/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.4.0/readme.md similarity index 67% rename from Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.0.0/readme.md rename to Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.4.0/readme.md index 5263e0ed..205a4366 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.0.0/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.4.0/readme.md @@ -1,11 +1,11 @@ -Microsoft.CodeCoverage [17.0.0](https://www.nuget.org/packages/Microsoft.CodeCoverage/17.0.0) +Microsoft.CodeCoverage [17.4.0](https://www.nuget.org/packages/Microsoft.CodeCoverage/17.4.0) -------------------- Used by: SqlDatabase internal -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 +Target frameworks: net472, net5.0, net6.0, net7.0, netcoreapp3.1 -License: [MIT](../../../../licenses/mit) +License: [ms-net-library](../../../../licenses/ms-net-library) - package license: [Unknown]() - repository license: [MIT](https://github.com/microsoft/vstest) diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.0.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.4.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.0.0/remarks.md rename to Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.4.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.0.0/repository-LICENSE b/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.4.0/repository-LICENSE similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.0.0/repository-LICENSE rename to Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.4.0/repository-LICENSE diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.0.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.4.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.0.0/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/microsoft.codecoverage/17.4.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.0.0/index.json b/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.4.0/index.json similarity index 88% rename from Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.0.0/index.json rename to Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.4.0/index.json index 3657874a..48f4f38f 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.0.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.4.0/index.json @@ -1,6 +1,6 @@ { "License": { - "Code": "MIT", + "Code": "ms-net-library", "Status": "AutomaticallyApproved" }, "UsedBy": [ @@ -11,16 +11,17 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net472" ], "Dependencies": [ { "Name": "Microsoft.CodeCoverage", - "Version": "17.0.0" + "Version": "17.4.0" }, { "Name": "Microsoft.TestPlatform.TestHost", - "Version": "17.0.0" + "Version": "17.4.0" } ] } diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.0.0/package-LICENSE_NET.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.4.0/package-LICENSE_NET.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.0.0/package-LICENSE_NET.txt rename to Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.4.0/package-LICENSE_NET.txt diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.0.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.4.0/package.nuspec similarity index 53% rename from Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.0.0/package.nuspec rename to Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.4.0/package.nuspec index 40efdd6c..e1842716 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.0.0/package.nuspec +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.4.0/package.nuspec @@ -2,7 +2,7 @@ Microsoft.NET.Test.Sdk - 17.0.0 + 17.4.0 Microsoft.NET.Test.Sdk Microsoft Microsoft @@ -15,25 +15,14 @@ The MSbuild targets and properties for building .NET test projects. © Microsoft Corporation. All rights reserved. vstest visual-studio unittest testplatform mstest microsoft test testing - + - - - - - + + + - - - - - - - - - - - + + diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.0.0/project-LICENSE b/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.4.0/project-LICENSE similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.0.0/project-LICENSE rename to Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.4.0/project-LICENSE diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.0.0/readme.md b/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.4.0/readme.md similarity index 65% rename from Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.0.0/readme.md rename to Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.4.0/readme.md index e2fd0e1a..982ca39c 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.0.0/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.4.0/readme.md @@ -1,11 +1,11 @@ -Microsoft.NET.Test.Sdk [17.0.0](https://www.nuget.org/packages/Microsoft.NET.Test.Sdk/17.0.0) +Microsoft.NET.Test.Sdk [17.4.0](https://www.nuget.org/packages/Microsoft.NET.Test.Sdk/17.4.0) -------------------- Used by: SqlDatabase internal -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 +Target frameworks: net472, net5.0, net6.0, net7.0, netcoreapp3.1 -License: [MIT](../../../../licenses/mit) +License: [ms-net-library](../../../../licenses/ms-net-library) - package license: [Unknown]() - repository license: [MIT](https://github.com/microsoft/vstest) @@ -25,7 +25,7 @@ Dependencies 2 |Name|Version| |----------|:----| -|[Microsoft.CodeCoverage](../../../../packages/nuget.org/microsoft.codecoverage/17.0.0)|17.0.0| -|[Microsoft.TestPlatform.TestHost](../../../../packages/nuget.org/microsoft.testplatform.testhost/17.0.0)|17.0.0| +|[Microsoft.CodeCoverage](../../../../packages/nuget.org/microsoft.codecoverage/17.4.0)|17.4.0| +|[Microsoft.TestPlatform.TestHost](../../../../packages/nuget.org/microsoft.testplatform.testhost/17.4.0)|17.4.0| *This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.0.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.4.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.0.0/remarks.md rename to Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.4.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.0.0/repository-LICENSE b/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.4.0/repository-LICENSE similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.0.0/repository-LICENSE rename to Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.4.0/repository-LICENSE diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.0.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.4.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.0.0/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/microsoft.net.test.sdk/17.4.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.0.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.0.0/package.nuspec deleted file mode 100644 index 261b8360..00000000 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.0.0/package.nuspec +++ /dev/null @@ -1,79 +0,0 @@ - - - - Microsoft.TestPlatform.ObjectModel - 17.0.0 - Microsoft.TestPlatform.ObjectModel - Microsoft - Microsoft - true - LICENSE_NET.txt - https://aka.ms/deprecateLicenseUrl - Icon.png - https://github.com/microsoft/vstest/ - http://go.microsoft.com/fwlink/?LinkID=288859 - The Microsoft Test Platform Object Model. - © Microsoft Corporation. All rights reserved. - vstest visual-studio unittest testplatform mstest microsoft test testing - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.0.0/index.json b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.4.0/index.json similarity index 91% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.0.0/index.json rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.4.0/index.json index 4a8470df..dec14c1c 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.0.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.4.0/index.json @@ -1,6 +1,6 @@ { "License": { - "Code": "MIT", + "Code": "ms-net-library", "Status": "AutomaticallyApproved" }, "UsedBy": [ @@ -11,12 +11,13 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net472" ], "Dependencies": [ { "Name": "NuGet.Frameworks", - "Version": "5.0.0" + "Version": "5.11.0" }, { "Name": "System.Reflection.Metadata", diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.0.0/package-LICENSE_NET.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.4.0/package-LICENSE_NET.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.0.0/package-LICENSE_NET.txt rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.4.0/package-LICENSE_NET.txt diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.4.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.4.0/package.nuspec new file mode 100644 index 00000000..26886126 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.4.0/package.nuspec @@ -0,0 +1,44 @@ + + + + Microsoft.TestPlatform.ObjectModel + 17.4.0 + Microsoft.TestPlatform.ObjectModel + Microsoft + Microsoft + true + LICENSE_NET.txt + https://aka.ms/deprecateLicenseUrl + Icon.png + https://github.com/microsoft/vstest/ + http://go.microsoft.com/fwlink/?LinkID=288859 + The Microsoft Test Platform Object Model. + © Microsoft Corporation. All rights reserved. + vstest visual-studio unittest testplatform mstest microsoft test testing + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.0.0/project-LICENSE b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.4.0/project-LICENSE similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.0.0/project-LICENSE rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.4.0/project-LICENSE diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.0.0/readme.md b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.4.0/readme.md similarity index 68% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.0.0/readme.md rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.4.0/readme.md index 599e4fe4..57872dab 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.0.0/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.4.0/readme.md @@ -1,11 +1,11 @@ -Microsoft.TestPlatform.ObjectModel [17.0.0](https://www.nuget.org/packages/Microsoft.TestPlatform.ObjectModel/17.0.0) +Microsoft.TestPlatform.ObjectModel [17.4.0](https://www.nuget.org/packages/Microsoft.TestPlatform.ObjectModel/17.4.0) -------------------- Used by: SqlDatabase internal -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 +Target frameworks: net472, net5.0, net6.0, net7.0, netcoreapp3.1 -License: [MIT](../../../../licenses/mit) +License: [ms-net-library](../../../../licenses/ms-net-library) - package license: [Unknown]() - repository license: [MIT](https://github.com/microsoft/vstest) @@ -25,7 +25,7 @@ Dependencies 2 |Name|Version| |----------|:----| -|[NuGet.Frameworks](../../../../packages/nuget.org/nuget.frameworks/5.0.0)|5.0.0| +|[NuGet.Frameworks](../../../../packages/nuget.org/nuget.frameworks/5.11.0)|5.11.0| |[System.Reflection.Metadata](../../../../packages/nuget.org/system.reflection.metadata/1.6.0)|1.6.0| *This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.0.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.4.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.0.0/remarks.md rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.4.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.0.0/repository-LICENSE b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.4.0/repository-LICENSE similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.0.0/repository-LICENSE rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.4.0/repository-LICENSE diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.0.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.4.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.0.0/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.objectmodel/17.4.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.0.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.0.0/package.nuspec deleted file mode 100644 index d302d991..00000000 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.0.0/package.nuspec +++ /dev/null @@ -1,43 +0,0 @@ - - - - Microsoft.TestPlatform.TestHost - 17.0.0 - Microsoft.TestPlatform.TestHost - Microsoft - Microsoft - true - LICENSE_NET.txt - https://aka.ms/deprecateLicenseUrl - Icon.png - https://github.com/microsoft/vstest/ - http://go.microsoft.com/fwlink/?LinkID=288859 - Testplatform host executes the test using specified adapter. - © Microsoft Corporation. All rights reserved. - vstest visual-studio unittest testplatform mstest microsoft test testing - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.0.0/index.json b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.4.0/index.json similarity index 88% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.0.0/index.json rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.4.0/index.json index 9069baba..41da6a47 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.0.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.4.0/index.json @@ -1,6 +1,6 @@ { "License": { - "Code": "MIT", + "Code": "ms-net-library", "Status": "AutomaticallyApproved" }, "UsedBy": [ @@ -11,16 +11,17 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net472" ], "Dependencies": [ { "Name": "Microsoft.TestPlatform.ObjectModel", - "Version": "17.0.0" + "Version": "17.4.0" }, { "Name": "Newtonsoft.Json", - "Version": "13.0.1" + "Version": "13.0.2" } ] } diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.0.0/package-LICENSE_NET.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.4.0/package-LICENSE_NET.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.0.0/package-LICENSE_NET.txt rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.4.0/package-LICENSE_NET.txt diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.4.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.4.0/package.nuspec new file mode 100644 index 00000000..89e8256d --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.4.0/package.nuspec @@ -0,0 +1,27 @@ + + + + Microsoft.TestPlatform.TestHost + 17.4.0 + Microsoft.TestPlatform.TestHost + Microsoft + Microsoft + true + LICENSE_NET.txt + https://aka.ms/deprecateLicenseUrl + Icon.png + https://github.com/microsoft/vstest/ + http://go.microsoft.com/fwlink/?LinkID=288859 + Testplatform host executes the test using specified adapter. + © Microsoft Corporation. All rights reserved. + vstest visual-studio unittest testplatform mstest microsoft test testing + + + + + + + + + + \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.0.0/project-LICENSE b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.4.0/project-LICENSE similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.0.0/project-LICENSE rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.4.0/project-LICENSE diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.0.0/readme.md b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.4.0/readme.md similarity index 64% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.0.0/readme.md rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.4.0/readme.md index 7bf1e7ce..e4243974 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.0.0/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.4.0/readme.md @@ -1,11 +1,11 @@ -Microsoft.TestPlatform.TestHost [17.0.0](https://www.nuget.org/packages/Microsoft.TestPlatform.TestHost/17.0.0) +Microsoft.TestPlatform.TestHost [17.4.0](https://www.nuget.org/packages/Microsoft.TestPlatform.TestHost/17.4.0) -------------------- Used by: SqlDatabase internal -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 +Target frameworks: net472, net5.0, net6.0, net7.0, netcoreapp3.1 -License: [MIT](../../../../licenses/mit) +License: [ms-net-library](../../../../licenses/ms-net-library) - package license: [Unknown]() - repository license: [MIT](https://github.com/microsoft/vstest) @@ -25,7 +25,7 @@ Dependencies 2 |Name|Version| |----------|:----| -|[Microsoft.TestPlatform.ObjectModel](../../../../packages/nuget.org/microsoft.testplatform.objectmodel/17.0.0)|17.0.0| -|[Newtonsoft.Json](../../../../packages/nuget.org/newtonsoft.json/13.0.1)|13.0.1| +|[Microsoft.TestPlatform.ObjectModel](../../../../packages/nuget.org/microsoft.testplatform.objectmodel/17.4.0)|17.4.0| +|[Newtonsoft.Json](../../../../packages/nuget.org/newtonsoft.json/13.0.2)|13.0.2| *This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.0.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.4.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.0.0/remarks.md rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.4.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.0.0/repository-LICENSE b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.4.0/repository-LICENSE similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.0.0/repository-LICENSE rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.4.0/repository-LICENSE diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.0.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.4.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.0.0/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/microsoft.testplatform.testhost/17.4.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.5.0/index.json b/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.7.0/index.json similarity index 71% rename from Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.5.0/index.json rename to Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.7.0/index.json index fde45ad0..023f66fe 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.5.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.7.0/index.json @@ -11,17 +11,18 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net452", "netstandard2.0" ], "Dependencies": [ { "Name": "System.Security.AccessControl", - "Version": "4.5.0" + "Version": "4.7.0" }, { "Name": "System.Security.Principal.Windows", - "Version": "4.5.0" + "Version": "4.7.0" } ] } @@ -30,14 +31,14 @@ { "Subject": "package", "Code": "MIT", - "HRef": "https://github.com/dotnet/corefx/blob/master/LICENSE.TXT", + "HRef": "https://licenses.nuget.org/MIT", "Description": null }, { "Subject": "project", "Code": null, - "HRef": "https://dot.net/", - "Description": "License should be verified on https://dot.net/" + "HRef": "https://github.com/dotnet/corefx", + "Description": "License should be verified on https://github.com/dotnet/corefx" } ] } \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.5.0/package-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.7.0/package-LICENSE.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.5.0/package-LICENSE.txt rename to Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.7.0/package-LICENSE.txt diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.7.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.7.0/package.nuspec new file mode 100644 index 00000000..112fb74e --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.7.0/package.nuspec @@ -0,0 +1,95 @@ + + + + Microsoft.Win32.Registry + 4.7.0 + Microsoft.Win32.Registry + Microsoft + microsoft,dotnetframework + false + MIT + https://licenses.nuget.org/MIT + https://github.com/dotnet/corefx + http://go.microsoft.com/fwlink/?LinkID=288859 + Provides support for accessing and modifying the Windows Registry. + +Commonly Used Types: +Microsoft.Win32.RegistryKey +Microsoft.Win32.Registry +Microsoft.Win32.RegistryValueKind +Microsoft.Win32.RegistryHive +Microsoft.Win32.RegistryView + +When using NuGet 3.x this package requires at least version 3.4. + https://go.microsoft.com/fwlink/?LinkID=799421 + © Microsoft Corporation. All rights reserved. + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.5.0/readme.md b/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.7.0/readme.md similarity index 58% rename from Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.5.0/readme.md rename to Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.7.0/readme.md index 61034272..bf195d65 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.5.0/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.7.0/readme.md @@ -1,14 +1,14 @@ -Microsoft.Win32.Registry [4.5.0](https://www.nuget.org/packages/Microsoft.Win32.Registry/4.5.0) +Microsoft.Win32.Registry [4.7.0](https://www.nuget.org/packages/Microsoft.Win32.Registry/4.7.0) -------------------- Used by: SqlDatabase -Target frameworks: net452, net5.0, net6.0, netcoreapp3.1, netstandard2.0 +Target frameworks: net452, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 License: [MIT](../../../../licenses/mit) -- package license: [MIT](https://github.com/dotnet/corefx/blob/master/LICENSE.TXT) -- project license: [Unknown](https://dot.net/) , License should be verified on https://dot.net/ +- package license: [MIT](https://licenses.nuget.org/MIT) +- project license: [Unknown](https://github.com/dotnet/corefx) , License should be verified on https://github.com/dotnet/corefx Description ----------- @@ -21,7 +21,6 @@ Microsoft.Win32.RegistryValueKind Microsoft.Win32.RegistryHive Microsoft.Win32.RegistryView -30ab651fcb4354552bd4891619a0bdd81e0ebdbf When using NuGet 3.x this package requires at least version 3.4. Remarks @@ -34,7 +33,7 @@ Dependencies 2 |Name|Version| |----------|:----| -|[System.Security.AccessControl](../../../../packages/nuget.org/system.security.accesscontrol/4.5.0)|4.5.0| -|[System.Security.Principal.Windows](../../../../packages/nuget.org/system.security.principal.windows/4.5.0)|4.5.0| +|[System.Security.AccessControl](../../../../packages/nuget.org/system.security.accesscontrol/4.7.0)|4.7.0| +|[System.Security.Principal.Windows](../../../../packages/nuget.org/system.security.principal.windows/4.7.0)|4.7.0| *This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.5.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.7.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.5.0/remarks.md rename to Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.7.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.5.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.7.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.5.0/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.7.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/5.0.0/index.json b/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/5.0.0/index.json new file mode 100644 index 00000000..bfd0f20b --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/5.0.0/index.json @@ -0,0 +1,49 @@ +{ + "License": { + "Code": "MIT", + "Status": "AutomaticallyApproved" + }, + "UsedBy": [ + { + "Name": "SqlDatabase", + "InternalOnly": true, + "TargetFrameworks": [ + "netcoreapp3.1", + "net5.0", + "net6.0", + "net7.0", + "net472" + ], + "Dependencies": [ + { + "Name": "System.Security.AccessControl", + "Version": "5.0.0" + }, + { + "Name": "System.Security.Principal.Windows", + "Version": "5.0.0" + } + ] + } + ], + "Licenses": [ + { + "Subject": "package", + "Code": "MIT", + "HRef": "https://licenses.nuget.org/MIT", + "Description": null + }, + { + "Subject": "repository", + "Code": "MIT", + "HRef": "git://github.com/dotnet/runtime", + "Description": null + }, + { + "Subject": "project", + "Code": "MIT", + "HRef": "https://github.com/dotnet/runtime", + "Description": null + } + ] +} \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.5.1/package-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/5.0.0/package-LICENSE.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.5.1/package-LICENSE.txt rename to Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/5.0.0/package-LICENSE.txt diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.5.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/5.0.0/package.nuspec similarity index 70% rename from Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.5.0/package.nuspec rename to Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/5.0.0/package.nuspec index af8b2606..b90a7ea7 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/4.5.0/package.nuspec +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/5.0.0/package.nuspec @@ -2,13 +2,15 @@ Microsoft.Win32.Registry - 4.5.0 + 5.0.0 Microsoft.Win32.Registry Microsoft microsoft,dotnetframework false - https://github.com/dotnet/corefx/blob/master/LICENSE.TXT - https://dot.net/ + MIT + https://licenses.nuget.org/MIT + Icon.png + https://github.com/dotnet/runtime http://go.microsoft.com/fwlink/?LinkID=288859 Provides support for accessing and modifying the Windows Registry. @@ -19,68 +21,69 @@ Microsoft.Win32.RegistryValueKind Microsoft.Win32.RegistryHive Microsoft.Win32.RegistryView -30ab651fcb4354552bd4891619a0bdd81e0ebdbf When using NuGet 3.x this package requires at least version 3.4. https://go.microsoft.com/fwlink/?LinkID=799421 - © Microsoft Corporation. All rights reserved. + © Microsoft Corporation. All rights reserved. true + - - - + + + - - - + + + - - + + - - - + + + - - + + - - - - + + + + - + + + - - - - + + + - - - + + + - - - + + + - - - + + + diff --git a/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.5.0/package-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/5.0.0/project-LICENSE.TXT similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.5.0/package-LICENSE.txt rename to Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/5.0.0/project-LICENSE.TXT diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/5.0.0/readme.md b/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/5.0.0/readme.md new file mode 100644 index 00000000..a353f944 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/5.0.0/readme.md @@ -0,0 +1,40 @@ +Microsoft.Win32.Registry [5.0.0](https://www.nuget.org/packages/Microsoft.Win32.Registry/5.0.0) +-------------------- + +Used by: SqlDatabase internal + +Target frameworks: net472, net5.0, net6.0, net7.0, netcoreapp3.1 + +License: [MIT](../../../../licenses/mit) + +- package license: [MIT](https://licenses.nuget.org/MIT) +- repository license: [MIT](git://github.com/dotnet/runtime) +- project license: [MIT](https://github.com/dotnet/runtime) + +Description +----------- +Provides support for accessing and modifying the Windows Registry. + +Commonly Used Types: +Microsoft.Win32.RegistryKey +Microsoft.Win32.Registry +Microsoft.Win32.RegistryValueKind +Microsoft.Win32.RegistryHive +Microsoft.Win32.RegistryView + +When using NuGet 3.x this package requires at least version 3.4. + +Remarks +----------- +no remarks + + +Dependencies 2 +----------- + +|Name|Version| +|----------|:----| +|[System.Security.AccessControl](../../../../packages/nuget.org/system.security.accesscontrol/5.0.0)|5.0.0| +|[System.Security.Principal.Windows](../../../../packages/nuget.org/system.security.principal.windows/5.0.0)|5.0.0| + +*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/moq/4.16.1/remarks.md b/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/5.0.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/moq/4.16.1/remarks.md rename to Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/5.0.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.5.0/package-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/5.0.0/repository-LICENSE.TXT similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.5.0/package-LICENSE.txt rename to Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/5.0.0/repository-LICENSE.TXT diff --git a/Build/third-party-libraries/packages/nuget.org/moq/4.16.1/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/5.0.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/moq/4.16.1/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/microsoft.win32.registry/5.0.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.0.5/index.json b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.0.5/index.json index cb58cb5b..56922b42 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.0.5/index.json +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.0.5/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net452", "netstandard2.0" ] diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.0.5/readme.md b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.0.5/readme.md index 80e0cecd..86985d2d 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.0.5/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.0.5/readme.md @@ -3,7 +3,7 @@ Microsoft.WSMan.Runtime [7.0.5](https://www.nuget.org/packages/Microsoft.WSMan.R Used by: SqlDatabase -Target frameworks: net452, net5.0, net6.0, netcoreapp3.1, netstandard2.0 +Target frameworks: net452, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.1.2/index.json b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.1.2/index.json index b5a131f0..f207f9ee 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.1.2/index.json +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.1.2/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net452", "netstandard2.0" ] diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.1.2/readme.md b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.1.2/readme.md index f74e5020..50df30e6 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.1.2/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.1.2/readme.md @@ -3,7 +3,7 @@ Microsoft.WSMan.Runtime [7.1.2](https://www.nuget.org/packages/Microsoft.WSMan.R Used by: SqlDatabase -Target frameworks: net452, net5.0, net6.0, netcoreapp3.1, netstandard2.0 +Target frameworks: net452, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/index.json b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/index.json index b5a131f0..f207f9ee 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net452", "netstandard2.0" ] diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/readme.md b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/readme.md index 46a23dfe..b17c9a95 100644 --- a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.2.0/readme.md @@ -3,7 +3,7 @@ Microsoft.WSMan.Runtime [7.2.0](https://www.nuget.org/packages/Microsoft.WSMan.R Used by: SqlDatabase -Target frameworks: net452, net5.0, net6.0, netcoreapp3.1, netstandard2.0 +Target frameworks: net452, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/index.json b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/index.json new file mode 100644 index 00000000..f207f9ee --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/index.json @@ -0,0 +1,34 @@ +{ + "License": { + "Code": "MIT", + "Status": "AutomaticallyApproved" + }, + "UsedBy": [ + { + "Name": "SqlDatabase", + "InternalOnly": false, + "TargetFrameworks": [ + "netcoreapp3.1", + "net5.0", + "net6.0", + "net7.0", + "net452", + "netstandard2.0" + ] + } + ], + "Licenses": [ + { + "Subject": "package", + "Code": "MIT", + "HRef": "https://licenses.nuget.org/MIT", + "Description": null + }, + { + "Subject": "project", + "Code": "MIT", + "HRef": "https://github.com/PowerShell/PowerShell", + "Description": null + } + ] +} \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/package.nuspec new file mode 100644 index 00000000..a9602f65 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/package.nuspec @@ -0,0 +1,24 @@ + + + + Microsoft.WSMan.Runtime + 7.3.0 + Microsoft + Microsoft,PowerShell + false + MIT + https://licenses.nuget.org/MIT + Powershell_black_64.png + https://github.com/PowerShell/PowerShell + Runtime for hosting PowerShell + © Microsoft Corporation. All rights reserved. + en-US + PowerShell + + + + + + + + \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/project-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/project-LICENSE.txt new file mode 100644 index 00000000..b2f52a2b --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/project-LICENSE.txt @@ -0,0 +1,21 @@ +Copyright (c) Microsoft Corporation. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/readme.md b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/readme.md new file mode 100644 index 00000000..aa252a5e --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/readme.md @@ -0,0 +1,26 @@ +Microsoft.WSMan.Runtime [7.3.0](https://www.nuget.org/packages/Microsoft.WSMan.Runtime/7.3.0) +-------------------- + +Used by: SqlDatabase + +Target frameworks: net452, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 + +License: [MIT](../../../../licenses/mit) + +- package license: [MIT](https://licenses.nuget.org/MIT) +- project license: [MIT](https://github.com/PowerShell/PowerShell) + +Description +----------- +Runtime for hosting PowerShell + +Remarks +----------- +no remarks + + +Dependencies 0 +----------- + + +*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.1/remarks.md b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.1/remarks.md rename to Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.1/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.1/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/microsoft.wsman.runtime/7.3.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/moq/4.16.1/index.json b/Build/third-party-libraries/packages/nuget.org/moq/4.18.2/index.json similarity index 83% rename from Build/third-party-libraries/packages/nuget.org/moq/4.16.1/index.json rename to Build/third-party-libraries/packages/nuget.org/moq/4.18.2/index.json index 1569c3e7..a604858f 100644 --- a/Build/third-party-libraries/packages/nuget.org/moq/4.16.1/index.json +++ b/Build/third-party-libraries/packages/nuget.org/moq/4.18.2/index.json @@ -11,12 +11,13 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net472" ], "Dependencies": [ { "Name": "Castle.Core", - "Version": "4.4.0" + "Version": "5.1.0" } ] } @@ -25,8 +26,8 @@ { "Subject": "package", "Code": null, - "HRef": "https://raw.githubusercontent.com/moq/moq4/master/License.txt", - "Description": "License should be verified on https://raw.githubusercontent.com/moq/moq4/master/License.txt" + "HRef": "https://raw.githubusercontent.com/moq/moq4/main/License.txt", + "Description": "License should be verified on https://raw.githubusercontent.com/moq/moq4/main/License.txt" }, { "Subject": "repository", diff --git a/Build/third-party-libraries/packages/nuget.org/moq/4.16.1/package-License.txt b/Build/third-party-libraries/packages/nuget.org/moq/4.18.2/package-License.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/moq/4.16.1/package-License.txt rename to Build/third-party-libraries/packages/nuget.org/moq/4.18.2/package-License.txt diff --git a/Build/third-party-libraries/packages/nuget.org/moq/4.16.1/package.nuspec b/Build/third-party-libraries/packages/nuget.org/moq/4.18.2/package.nuspec similarity index 60% rename from Build/third-party-libraries/packages/nuget.org/moq/4.16.1/package.nuspec rename to Build/third-party-libraries/packages/nuget.org/moq/4.18.2/package.nuspec index 09cd6f84..65a776d4 100644 --- a/Build/third-party-libraries/packages/nuget.org/moq/4.16.1/package.nuspec +++ b/Build/third-party-libraries/packages/nuget.org/moq/4.18.2/package.nuspec @@ -2,31 +2,32 @@ Moq - 4.16.1 + 4.18.2 Moq: an enjoyable mocking library Daniel Cazzulino, kzu - false - https://raw.githubusercontent.com/moq/moq4/master/License.txt + https://raw.githubusercontent.com/moq/moq4/main/License.txt moq.png https://github.com/moq/moq4 Moq is the most popular and friendly mocking framework for .NET. -Built from https://github.com/moq/moq4/tree/fc484fb85 - A changelog is available at https://github.com/moq/moq4/blob/master/CHANGELOG.md. +Built from https://github.com/moq/moq4/tree/c60833da6 + A changelog is available at https://github.com/moq/moq4/blob/main/CHANGELOG.md. moq tdd mocking mocks unittesting agile unittest - + - - + + + + + - + - - + diff --git a/Build/third-party-libraries/packages/nuget.org/moq/4.16.1/project-License.txt b/Build/third-party-libraries/packages/nuget.org/moq/4.18.2/project-License.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/moq/4.16.1/project-License.txt rename to Build/third-party-libraries/packages/nuget.org/moq/4.18.2/project-License.txt diff --git a/Build/third-party-libraries/packages/nuget.org/moq/4.16.1/readme.md b/Build/third-party-libraries/packages/nuget.org/moq/4.18.2/readme.md similarity index 63% rename from Build/third-party-libraries/packages/nuget.org/moq/4.16.1/readme.md rename to Build/third-party-libraries/packages/nuget.org/moq/4.18.2/readme.md index aeec6f46..5aedd54e 100644 --- a/Build/third-party-libraries/packages/nuget.org/moq/4.16.1/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/moq/4.18.2/readme.md @@ -1,13 +1,13 @@ -Moq [4.16.1](https://www.nuget.org/packages/Moq/4.16.1) +Moq [4.18.2](https://www.nuget.org/packages/Moq/4.18.2) -------------------- Used by: SqlDatabase internal -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 +Target frameworks: net472, net5.0, net6.0, net7.0, netcoreapp3.1 License: [BSD-3-Clause](../../../../licenses/bsd-3-clause) -- package license: [Unknown](https://raw.githubusercontent.com/moq/moq4/master/License.txt) , License should be verified on https://raw.githubusercontent.com/moq/moq4/master/License.txt +- package license: [Unknown](https://raw.githubusercontent.com/moq/moq4/main/License.txt) , License should be verified on https://raw.githubusercontent.com/moq/moq4/main/License.txt - repository license: [Unknown](https://github.com/moq/moq4) , License should be verified on https://github.com/moq/moq4 - project license: [Unknown](https://github.com/moq/moq4) , License should be verified on https://github.com/moq/moq4 @@ -15,7 +15,7 @@ Description ----------- Moq is the most popular and friendly mocking framework for .NET. -Built from https://github.com/moq/moq4/tree/fc484fb85 +Built from https://github.com/moq/moq4/tree/c60833da6 Remarks ----------- @@ -27,6 +27,6 @@ Dependencies 1 |Name|Version| |----------|:----| -|[Castle.Core](../../../../packages/nuget.org/castle.core/4.4.0)|4.4.0| +|[Castle.Core](../../../../packages/nuget.org/castle.core/5.1.0)|5.1.0| *This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.0.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/moq/4.18.2/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.0.0/remarks.md rename to Build/third-party-libraries/packages/nuget.org/moq/4.18.2/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/moq/4.16.1/repository-License.txt b/Build/third-party-libraries/packages/nuget.org/moq/4.18.2/repository-License.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/moq/4.16.1/repository-License.txt rename to Build/third-party-libraries/packages/nuget.org/moq/4.18.2/repository-License.txt diff --git a/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.0.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/moq/4.18.2/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.0.0/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/moq/4.18.2/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/mysqlconnector/1.3.10/index.json b/Build/third-party-libraries/packages/nuget.org/mysqlconnector/1.3.10/index.json index 94493ffb..21b914d7 100644 --- a/Build/third-party-libraries/packages/nuget.org/mysqlconnector/1.3.10/index.json +++ b/Build/third-party-libraries/packages/nuget.org/mysqlconnector/1.3.10/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net452", "netstandard2.0" ] diff --git a/Build/third-party-libraries/packages/nuget.org/mysqlconnector/1.3.10/readme.md b/Build/third-party-libraries/packages/nuget.org/mysqlconnector/1.3.10/readme.md index 54be54d9..de5afb3d 100644 --- a/Build/third-party-libraries/packages/nuget.org/mysqlconnector/1.3.10/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/mysqlconnector/1.3.10/readme.md @@ -3,7 +3,7 @@ MySqlConnector [1.3.10](https://www.nuget.org/packages/MySqlConnector/1.3.10) Used by: SqlDatabase -Target frameworks: net452, net5.0, net6.0, netcoreapp3.1, netstandard2.0 +Target frameworks: net452, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/netstandard.library/2.0.3/index.json b/Build/third-party-libraries/packages/nuget.org/netstandard.library/2.0.3/index.json index e771e1ec..d6322f13 100644 --- a/Build/third-party-libraries/packages/nuget.org/netstandard.library/2.0.3/index.json +++ b/Build/third-party-libraries/packages/nuget.org/netstandard.library/2.0.3/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net452", "netstandard2.0" ] diff --git a/Build/third-party-libraries/packages/nuget.org/netstandard.library/2.0.3/readme.md b/Build/third-party-libraries/packages/nuget.org/netstandard.library/2.0.3/readme.md index 4b97e56f..60dff056 100644 --- a/Build/third-party-libraries/packages/nuget.org/netstandard.library/2.0.3/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/netstandard.library/2.0.3/readme.md @@ -3,7 +3,7 @@ NETStandard.Library [2.0.3](https://www.nuget.org/packages/NETStandard.Library/2 Used by: SqlDatabase -Target frameworks: net452, net5.0, net6.0, netcoreapp3.1, netstandard2.0 +Target frameworks: net452, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.1/index.json b/Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.2/index.json similarity index 97% rename from Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.1/index.json rename to Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.2/index.json index c349f976..fd77bf70 100644 --- a/Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.1/index.json +++ b/Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.2/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net472" ] } diff --git a/Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.1/package-LICENSE.md b/Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.2/package-LICENSE.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.1/package-LICENSE.md rename to Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.2/package-LICENSE.md diff --git a/Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.1/package.nuspec b/Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.2/package.nuspec similarity index 89% rename from Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.1/package.nuspec rename to Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.2/package.nuspec index 23ab73b3..9ef2e1f7 100644 --- a/Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.1/package.nuspec +++ b/Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.2/package.nuspec @@ -2,18 +2,19 @@ Newtonsoft.Json - 13.0.1 + 13.0.2 Json.NET James Newton-King - false MIT https://licenses.nuget.org/MIT packageIcon.png + README.md https://www.newtonsoft.com/json + https://www.newtonsoft.com/content/images/nugeticon.png Json.NET is a popular high-performance JSON framework for .NET Copyright © James Newton-King 2008 json - + @@ -33,6 +34,7 @@ + diff --git a/Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.1/readme.md b/Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.2/readme.md similarity index 78% rename from Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.1/readme.md rename to Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.2/readme.md index ba03f11f..af6f1f81 100644 --- a/Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.1/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.2/readme.md @@ -1,9 +1,9 @@ -Newtonsoft.Json [13.0.1](https://www.nuget.org/packages/Newtonsoft.Json/13.0.1) +Newtonsoft.Json [13.0.2](https://www.nuget.org/packages/Newtonsoft.Json/13.0.2) -------------------- Used by: SqlDatabase internal -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 +Target frameworks: net472, net5.0, net6.0, net7.0, netcoreapp3.1 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/nunit/3.13.2/remarks.md b/Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.2/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/nunit/3.13.2/remarks.md rename to Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.2/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.1/repository-LICENSE.md b/Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.2/repository-LICENSE.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.1/repository-LICENSE.md rename to Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.2/repository-LICENSE.md diff --git a/Build/third-party-libraries/packages/nuget.org/nunit/3.13.2/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.2/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/nunit/3.13.2/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/newtonsoft.json/13.0.2/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/npgsql/4.0.11/index.json b/Build/third-party-libraries/packages/nuget.org/npgsql/4.0.11/index.json index 0602ccf1..467268bf 100644 --- a/Build/third-party-libraries/packages/nuget.org/npgsql/4.0.11/index.json +++ b/Build/third-party-libraries/packages/nuget.org/npgsql/4.0.11/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net452", "netstandard2.0" ], diff --git a/Build/third-party-libraries/packages/nuget.org/npgsql/4.0.11/readme.md b/Build/third-party-libraries/packages/nuget.org/npgsql/4.0.11/readme.md index 0ff33d36..75475b97 100644 --- a/Build/third-party-libraries/packages/nuget.org/npgsql/4.0.11/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/npgsql/4.0.11/readme.md @@ -3,7 +3,7 @@ Npgsql [4.0.11](https://www.nuget.org/packages/Npgsql/4.0.11) Used by: SqlDatabase -Target frameworks: net452, net5.0, net6.0, netcoreapp3.1, netstandard2.0 +Target frameworks: net452, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 License: [PostgreSQL](../../../../licenses/postgresql) diff --git a/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.0.0/index.json b/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.11.0/index.json similarity index 97% rename from Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.0.0/index.json rename to Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.11.0/index.json index 089849f2..e2d3fe32 100644 --- a/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.0.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.11.0/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net472" ] } diff --git a/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.0.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.11.0/package.nuspec similarity index 72% rename from Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.0.0/package.nuspec rename to Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.11.0/package.nuspec index 24e1e4f9..5cb721d9 100644 --- a/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.0.0/package.nuspec +++ b/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.11.0/package.nuspec @@ -2,19 +2,18 @@ NuGet.Frameworks - 5.0.0+42a8779499c1d1ed2488c2e6b9e2ee6ff6107766 + 5.11.0 Microsoft - Microsoft true Apache-2.0 https://licenses.nuget.org/Apache-2.0 + icon.png https://aka.ms/nugetprj - https://raw.githubusercontent.com/NuGet/Media/master/Images/MainLogo/256x256/nuget_256.png - The understanding of target frameworks for NuGet.Packaging. + NuGet's understanding of target frameworks. © Microsoft Corporation. All rights reserved. nuget true - + diff --git a/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.0.0/readme.md b/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.11.0/readme.md similarity index 69% rename from Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.0.0/readme.md rename to Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.11.0/readme.md index 2fbff4e1..d812d5ac 100644 --- a/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.0.0/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.11.0/readme.md @@ -1,9 +1,9 @@ -NuGet.Frameworks [5.0.0](https://www.nuget.org/packages/NuGet.Frameworks/5.0.0%2b42a8779499c1d1ed2488c2e6b9e2ee6ff6107766) +NuGet.Frameworks [5.11.0](https://www.nuget.org/packages/NuGet.Frameworks/5.11.0) -------------------- Used by: SqlDatabase internal -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 +Target frameworks: net472, net5.0, net6.0, net7.0, netcoreapp3.1 License: [Apache-2.0](../../../../licenses/apache-2.0) @@ -13,7 +13,7 @@ License: [Apache-2.0](../../../../licenses/apache-2.0) Description ----------- -The understanding of target frameworks for NuGet.Packaging. +NuGet's understanding of target frameworks. Remarks ----------- diff --git a/Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.1.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.11.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.1.0/remarks.md rename to Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.11.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.0.0/repository-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.11.0/repository-LICENSE.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.0.0/repository-LICENSE.txt rename to Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.11.0/repository-LICENSE.txt diff --git a/Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.1.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.11.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.1.0/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/nuget.frameworks/5.11.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/nunit/3.13.2/index.json b/Build/third-party-libraries/packages/nuget.org/nunit/3.13.3/index.json similarity index 97% rename from Build/third-party-libraries/packages/nuget.org/nunit/3.13.2/index.json rename to Build/third-party-libraries/packages/nuget.org/nunit/3.13.3/index.json index 4cb70adb..5b0b9719 100644 --- a/Build/third-party-libraries/packages/nuget.org/nunit/3.13.2/index.json +++ b/Build/third-party-libraries/packages/nuget.org/nunit/3.13.3/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net472" ] } diff --git a/Build/third-party-libraries/packages/nuget.org/nunit/3.13.2/package-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/nunit/3.13.3/package-LICENSE.txt similarity index 95% rename from Build/third-party-libraries/packages/nuget.org/nunit/3.13.2/package-LICENSE.txt rename to Build/third-party-libraries/packages/nuget.org/nunit/3.13.3/package-LICENSE.txt index 29f0e2ea..ab7da19e 100644 --- a/Build/third-party-libraries/packages/nuget.org/nunit/3.13.2/package-LICENSE.txt +++ b/Build/third-party-libraries/packages/nuget.org/nunit/3.13.3/package-LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2021 Charlie Poole, Rob Prouse +Copyright (c) 2022 Charlie Poole, Rob Prouse Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Build/third-party-libraries/packages/nuget.org/nunit/3.13.2/package.nuspec b/Build/third-party-libraries/packages/nuget.org/nunit/3.13.3/package.nuspec similarity index 95% rename from Build/third-party-libraries/packages/nuget.org/nunit/3.13.2/package.nuspec rename to Build/third-party-libraries/packages/nuget.org/nunit/3.13.3/package.nuspec index 4fa9ee56..70a874bf 100644 --- a/Build/third-party-libraries/packages/nuget.org/nunit/3.13.2/package.nuspec +++ b/Build/third-party-libraries/packages/nuget.org/nunit/3.13.3/package.nuspec @@ -2,7 +2,7 @@ NUnit - 3.13.2 + 3.13.3 NUnit Charlie Poole, Rob Prouse Charlie Poole, Rob Prouse @@ -21,7 +21,7 @@ Supported platforms: - .NET Standard 2.0+ NUnit is a unit-testing framework for all .NET languages with a strong TDD focus. This package includes the NUnit 3 framework assembly, which is referenced by your tests. You will need to install version 3 of the nunit3-console program or a third-party runner that supports NUnit 3 in order to execute tests. Runners intended for use with NUnit 2.x will not run NUnit 3 tests correctly. - Copyright (c) 2021 Charlie Poole, Rob Prouse + Copyright (c) 2022 Charlie Poole, Rob Prouse en-US nunit test testing tdd framework fluent assert theory plugin addin diff --git a/Build/third-party-libraries/packages/nuget.org/nunit/3.13.2/readme.md b/Build/third-party-libraries/packages/nuget.org/nunit/3.13.3/readme.md similarity index 87% rename from Build/third-party-libraries/packages/nuget.org/nunit/3.13.2/readme.md rename to Build/third-party-libraries/packages/nuget.org/nunit/3.13.3/readme.md index a669f13e..b788b316 100644 --- a/Build/third-party-libraries/packages/nuget.org/nunit/3.13.2/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/nunit/3.13.3/readme.md @@ -1,9 +1,9 @@ -NUnit [3.13.2](https://www.nuget.org/packages/NUnit/3.13.2) +NUnit [3.13.3](https://www.nuget.org/packages/NUnit/3.13.3) -------------------- Used by: SqlDatabase internal -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 +Target frameworks: net472, net5.0, net6.0, net7.0, netcoreapp3.1 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/shouldly/4.0.3/remarks.md b/Build/third-party-libraries/packages/nuget.org/nunit/3.13.3/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/shouldly/4.0.3/remarks.md rename to Build/third-party-libraries/packages/nuget.org/nunit/3.13.3/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/nunit/3.13.2/repository-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/nunit/3.13.3/repository-LICENSE.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/nunit/3.13.2/repository-LICENSE.txt rename to Build/third-party-libraries/packages/nuget.org/nunit/3.13.3/repository-LICENSE.txt diff --git a/Build/third-party-libraries/packages/nuget.org/shouldly/4.0.3/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/nunit/3.13.3/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/shouldly/4.0.3/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/nunit/3.13.3/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.1.0/index.json b/Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.3.1/index.json similarity index 97% rename from Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.1.0/index.json rename to Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.3.1/index.json index 8756ce79..d8aa9087 100644 --- a/Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.1.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.3.1/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net472" ] } diff --git a/Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.1.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.3.1/package.nuspec similarity index 60% rename from Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.1.0/package.nuspec rename to Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.3.1/package.nuspec index 64a2df66..b703abf0 100644 --- a/Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.1.0/package.nuspec +++ b/Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.3.1/package.nuspec @@ -2,8 +2,8 @@ NUnit3TestAdapter - 4.1.0 - NUnit 3 Test Adapter for Visual Studio and DotNet + 4.3.1 + NUnit3 Test Adapter for Visual Studio and DotNet Charlie Poole, Terje Sandstrom false MIT @@ -12,13 +12,11 @@ https://cdn.rawgit.com/nunit/resources/master/images/icon/nunit_256.png The NUnit3 TestAdapter for Visual Studio, all versions from 2012 and onwards, and DotNet (incl. .Net core). - Note that this package ONLY contains the adapter, not the NUnit framework. - For VS 2017 and forward, you should add this package to every test project in your solution. (Earlier versions only require a single adapter package per solution.) - - Note that with this package you should not install the VSIX adapter package. - NUnit 3 adapter for running tests in Visual Studio and DotNet. Works with NUnit 3.x, use the NUnit 2 adapter for 2.x tests. + Note that this package ONLY contains the adapter, not the NUnit framework. + For VS 2017 and forward, you should add this package to every test project in your solution. (Earlier versions only require a single adapter package per solution.) + NUnit3 adapter for running tests in Visual Studio and DotNet. Works with NUnit 3.x, use the NUnit 2 adapter for 2.x tests. See https://docs.nunit.org/articles/vs-test-adapter/Adapter-Release-Notes.html - Copyright (c) 2011-2021 Charlie Poole, 2014-2021 Terje Sandstrom + Copyright (c) 2011-2021 Charlie Poole, 2014-2022 Terje Sandstrom en-US test visualstudio testadapter nunit nunit3 dotnet diff --git a/Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.1.0/readme.md b/Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.3.1/readme.md similarity index 56% rename from Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.1.0/readme.md rename to Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.3.1/readme.md index 2677b4e6..bcec9301 100644 --- a/Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.1.0/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.3.1/readme.md @@ -1,9 +1,9 @@ -NUnit3TestAdapter [4.1.0](https://www.nuget.org/packages/NUnit3TestAdapter/4.1.0) +NUnit3TestAdapter [4.3.1](https://www.nuget.org/packages/NUnit3TestAdapter/4.3.1) -------------------- Used by: SqlDatabase internal -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 +Target frameworks: net472, net5.0, net6.0, net7.0, netcoreapp3.1 License: [MIT](../../../../licenses/mit) @@ -15,10 +15,8 @@ Description ----------- The NUnit3 TestAdapter for Visual Studio, all versions from 2012 and onwards, and DotNet (incl. .Net core). - Note that this package ONLY contains the adapter, not the NUnit framework. - For VS 2017 and forward, you should add this package to every test project in your solution. (Earlier versions only require a single adapter package per solution.) - - Note that with this package you should not install the VSIX adapter package. + Note that this package ONLY contains the adapter, not the NUnit framework. + For VS 2017 and forward, you should add this package to every test project in your solution. (Earlier versions only require a single adapter package per solution.) Remarks ----------- diff --git a/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.376/remarks.md b/Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.3.1/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.376/remarks.md rename to Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.3.1/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.1.0/repository-LICENSE b/Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.3.1/repository-LICENSE similarity index 94% rename from Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.1.0/repository-LICENSE rename to Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.3.1/repository-LICENSE index c3628f78..3302bf8b 100644 --- a/Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.1.0/repository-LICENSE +++ b/Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.3.1/repository-LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2011-2020 Charlie Poole, 2014-2020 Terje Sandstrom +Copyright (c) 2011-2020 Charlie Poole, 2014-2022 Terje Sandstrom Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.376/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.3.1/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.376/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/nunit3testadapter/4.3.1/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.0/index.json b/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.0/index.json index c4600ba2..13bf1f8a 100644 --- a/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.0/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net452", "netstandard2.0", "net472" diff --git a/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.0/readme.md b/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.0/readme.md index 1fba9082..06c7815f 100644 --- a/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.0/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/powershellstandard.library/5.1.0/readme.md @@ -3,7 +3,7 @@ PowerShellStandard.Library [5.1.0](https://www.nuget.org/packages/PowerShellStan Used by: SqlDatabase -Target frameworks: net452, net472, net5.0, net6.0, netcoreapp3.1, netstandard2.0 +Target frameworks: net452, net472, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/shouldly/4.0.3/index.json b/Build/third-party-libraries/packages/nuget.org/shouldly/4.1.0/index.json similarity index 93% rename from Build/third-party-libraries/packages/nuget.org/shouldly/4.0.3/index.json rename to Build/third-party-libraries/packages/nuget.org/shouldly/4.1.0/index.json index 187b79ec..061e9015 100644 --- a/Build/third-party-libraries/packages/nuget.org/shouldly/4.0.3/index.json +++ b/Build/third-party-libraries/packages/nuget.org/shouldly/4.1.0/index.json @@ -11,16 +11,17 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net472" ], "Dependencies": [ { "Name": "DiffEngine", - "Version": "6.4.9" + "Version": "10.0.0" }, { "Name": "EmptyFiles", - "Version": "2.3.3" + "Version": "2.8.0" } ] } diff --git a/Build/third-party-libraries/packages/nuget.org/shouldly/4.0.3/package.nuspec b/Build/third-party-libraries/packages/nuget.org/shouldly/4.1.0/package.nuspec similarity index 67% rename from Build/third-party-libraries/packages/nuget.org/shouldly/4.0.3/package.nuspec rename to Build/third-party-libraries/packages/nuget.org/shouldly/4.1.0/package.nuspec index e21a4e0c..9942b38e 100644 --- a/Build/third-party-libraries/packages/nuget.org/shouldly/4.0.3/package.nuspec +++ b/Build/third-party-libraries/packages/nuget.org/shouldly/4.1.0/package.nuspec @@ -2,23 +2,21 @@ Shouldly - 4.0.3 + 4.1.0 Jake Ginnivan, Joseph Woodward, Simon Cropp - false BSD-2-Clause https://licenses.nuget.org/BSD-2-Clause assets/logo_128x128.png https://github.com/shouldly/shouldly Shouldly - Assertion framework for .NET. The way asserting *Should* be - https://github.com/shouldly/releases/tag/4.0.3 + https://github.com/shouldly/releases/tag/4.1.0 test unit testing TDD AAA should testunit rspec assert assertion framework - + - - + + - diff --git a/Build/third-party-libraries/packages/nuget.org/shouldly/4.0.3/project-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/shouldly/4.1.0/project-LICENSE.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/shouldly/4.0.3/project-LICENSE.txt rename to Build/third-party-libraries/packages/nuget.org/shouldly/4.1.0/project-LICENSE.txt diff --git a/Build/third-party-libraries/packages/nuget.org/shouldly/4.0.3/readme.md b/Build/third-party-libraries/packages/nuget.org/shouldly/4.1.0/readme.md similarity index 72% rename from Build/third-party-libraries/packages/nuget.org/shouldly/4.0.3/readme.md rename to Build/third-party-libraries/packages/nuget.org/shouldly/4.1.0/readme.md index 6d055d9d..34644969 100644 --- a/Build/third-party-libraries/packages/nuget.org/shouldly/4.0.3/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/shouldly/4.1.0/readme.md @@ -1,9 +1,9 @@ -Shouldly [4.0.3](https://www.nuget.org/packages/Shouldly/4.0.3) +Shouldly [4.1.0](https://www.nuget.org/packages/Shouldly/4.1.0) -------------------- Used by: SqlDatabase internal -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 +Target frameworks: net472, net5.0, net6.0, net7.0, netcoreapp3.1 License: [BSD-2-Clause](../../../../licenses/bsd-2-clause) @@ -25,7 +25,7 @@ Dependencies 2 |Name|Version| |----------|:----| -|[DiffEngine](../../../../packages/nuget.org/diffengine/6.4.9)|6.4.9| -|[EmptyFiles](../../../../packages/nuget.org/emptyfiles/2.3.3)|2.3.3| +|[DiffEngine](../../../../packages/nuget.org/diffengine/10.0.0)|10.0.0| +|[EmptyFiles](../../../../packages/nuget.org/emptyfiles/2.8.0)|2.8.0| *This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.collections.nongeneric/4.3.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/shouldly/4.1.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.collections.nongeneric/4.3.0/remarks.md rename to Build/third-party-libraries/packages/nuget.org/shouldly/4.1.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/shouldly/4.0.3/repository-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/shouldly/4.1.0/repository-LICENSE.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/shouldly/4.0.3/repository-LICENSE.txt rename to Build/third-party-libraries/packages/nuget.org/shouldly/4.1.0/repository-LICENSE.txt diff --git a/Build/third-party-libraries/packages/nuget.org/system.collections.nongeneric/4.3.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/shouldly/4.1.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.collections.nongeneric/4.3.0/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/shouldly/4.1.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.376/index.json b/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.435/index.json similarity index 97% rename from Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.376/index.json rename to Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.435/index.json index 5da73b59..64ec2c6e 100644 --- a/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.376/index.json +++ b/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.435/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net452", "netstandard2.0", "net472" diff --git a/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.376/package-LICENSE b/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.435/package-LICENSE similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.376/package-LICENSE rename to Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.435/package-LICENSE diff --git a/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.376/package.nuspec b/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.435/package.nuspec similarity index 92% rename from Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.376/package.nuspec rename to Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.435/package.nuspec index dd15edde..d0148958 100644 --- a/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.376/package.nuspec +++ b/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.435/package.nuspec @@ -2,7 +2,7 @@ StyleCop.Analyzers.Unstable - 1.2.0.376 + 1.2.0.435 StyleCop.Analyzers.Unstable Sam Harwell et. al. Sam Harwell @@ -12,7 +12,7 @@ https://licenses.nuget.org/MIT https://github.com/DotNetAnalyzers/StyleCopAnalyzers An implementation of StyleCop's rules using Roslyn analyzers and code fixes - https://github.com/DotNetAnalyzers/StyleCopAnalyzers/releases/1.2.0-beta.376 + https://github.com/DotNetAnalyzers/StyleCopAnalyzers/releases/1.2.0-beta.435 Copyright 2015 Tunnel Vision Laboratories, LLC StyleCop DotNetAnalyzers Roslyn Diagnostic Analyzer diff --git a/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.376/project-LICENSE b/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.435/project-LICENSE similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.376/project-LICENSE rename to Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.435/project-LICENSE diff --git a/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.376/readme.md b/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.435/readme.md similarity index 68% rename from Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.376/readme.md rename to Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.435/readme.md index 0049a99a..207ab7dc 100644 --- a/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.376/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.435/readme.md @@ -1,9 +1,9 @@ -StyleCop.Analyzers.Unstable [1.2.0.376](https://www.nuget.org/packages/StyleCop.Analyzers.Unstable/1.2.0.376) +StyleCop.Analyzers.Unstable [1.2.0.435](https://www.nuget.org/packages/StyleCop.Analyzers.Unstable/1.2.0.435) -------------------- Used by: SqlDatabase internal -Target frameworks: net452, net472, net5.0, net6.0, netcoreapp3.1, netstandard2.0 +Target frameworks: net452, net472, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/system.collections.specialized/4.3.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.435/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.collections.specialized/4.3.0/remarks.md rename to Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.435/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/system.collections.specialized/4.3.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.435/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.collections.specialized/4.3.0/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/stylecop.analyzers.unstable/1.2.0.435/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/system.buffers/4.4.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.buffers/4.4.0/index.json index a72233ce..79494e46 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.buffers/4.4.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.buffers/4.4.0/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net452", "netstandard2.0" ] diff --git a/Build/third-party-libraries/packages/nuget.org/system.buffers/4.4.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.buffers/4.4.0/readme.md index df0014e1..914652b9 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.buffers/4.4.0/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.buffers/4.4.0/readme.md @@ -3,7 +3,7 @@ System.Buffers [4.4.0](https://www.nuget.org/packages/System.Buffers/4.4.0) Used by: SqlDatabase -Target frameworks: net452, net5.0, net6.0, netcoreapp3.1, netstandard2.0 +Target frameworks: net452, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/system.buffers/4.5.1/index.json b/Build/third-party-libraries/packages/nuget.org/system.buffers/4.5.1/index.json index c19f5aa6..79494e46 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.buffers/4.5.1/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.buffers/4.5.1/index.json @@ -6,12 +6,14 @@ "UsedBy": [ { "Name": "SqlDatabase", - "InternalOnly": true, + "InternalOnly": false, "TargetFrameworks": [ "netcoreapp3.1", "net5.0", "net6.0", - "net472" + "net7.0", + "net452", + "netstandard2.0" ] } ], diff --git a/Build/third-party-libraries/packages/nuget.org/system.buffers/4.5.1/readme.md b/Build/third-party-libraries/packages/nuget.org/system.buffers/4.5.1/readme.md index bdbc9ed0..e50f8eb9 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.buffers/4.5.1/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.buffers/4.5.1/readme.md @@ -1,9 +1,9 @@ System.Buffers [4.5.1](https://www.nuget.org/packages/System.Buffers/4.5.1) -------------------- -Used by: SqlDatabase internal +Used by: SqlDatabase -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 +Target frameworks: net452, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/system.codedom/5.0.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.codedom/5.0.0/index.json new file mode 100644 index 00000000..cf67483a --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.codedom/5.0.0/index.json @@ -0,0 +1,39 @@ +{ + "License": { + "Code": "MIT", + "Status": "AutomaticallyApproved" + }, + "UsedBy": [ + { + "Name": "SqlDatabase", + "InternalOnly": true, + "TargetFrameworks": [ + "netcoreapp3.1", + "net5.0", + "net6.0", + "net7.0", + "net472" + ] + } + ], + "Licenses": [ + { + "Subject": "package", + "Code": "MIT", + "HRef": "https://licenses.nuget.org/MIT", + "Description": null + }, + { + "Subject": "repository", + "Code": "MIT", + "HRef": "git://github.com/dotnet/runtime", + "Description": null + }, + { + "Subject": "project", + "Code": "MIT", + "HRef": "https://github.com/dotnet/runtime", + "Description": null + } + ] +} \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.5.0/package-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/system.codedom/5.0.0/package-LICENSE.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.5.0/package-LICENSE.txt rename to Build/third-party-libraries/packages/nuget.org/system.codedom/5.0.0/package-LICENSE.txt diff --git a/Build/third-party-libraries/packages/nuget.org/system.codedom/5.0.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.codedom/5.0.0/package.nuspec new file mode 100644 index 00000000..81a09f5b --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.codedom/5.0.0/package.nuspec @@ -0,0 +1,37 @@ + + + + System.CodeDom + 5.0.0 + System.CodeDom + Microsoft + microsoft,dotnetframework + false + MIT + https://licenses.nuget.org/MIT + Icon.png + https://github.com/dotnet/runtime + http://go.microsoft.com/fwlink/?LinkID=288859 + Provides types that can be used to model the structure of a source code document and to output source code for that model in a supported language. + +Commonly Used Types: +System.CodeDom.CodeObject +System.CodeDom.Compiler.CodeDomProvider +Microsoft.CSharp.CSharpCodeProvider +Microsoft.VisualBasic.VBCodeProvider + +When using NuGet 3.x this package requires at least version 3.4. + https://go.microsoft.com/fwlink/?LinkID=799421 + © Microsoft Corporation. All rights reserved. + true + + + + + + + + + + + \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.5.0/package-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/system.codedom/5.0.0/project-LICENSE.TXT similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.5.0/package-LICENSE.txt rename to Build/third-party-libraries/packages/nuget.org/system.codedom/5.0.0/project-LICENSE.TXT diff --git a/Build/third-party-libraries/packages/nuget.org/system.codedom/5.0.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.codedom/5.0.0/readme.md new file mode 100644 index 00000000..296795bc --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.codedom/5.0.0/readme.md @@ -0,0 +1,35 @@ +System.CodeDom [5.0.0](https://www.nuget.org/packages/System.CodeDom/5.0.0) +-------------------- + +Used by: SqlDatabase internal + +Target frameworks: net472, net5.0, net6.0, net7.0, netcoreapp3.1 + +License: [MIT](../../../../licenses/mit) + +- package license: [MIT](https://licenses.nuget.org/MIT) +- repository license: [MIT](git://github.com/dotnet/runtime) +- project license: [MIT](https://github.com/dotnet/runtime) + +Description +----------- +Provides types that can be used to model the structure of a source code document and to output source code for that model in a supported language. + +Commonly Used Types: +System.CodeDom.CodeObject +System.CodeDom.Compiler.CodeDomProvider +Microsoft.CSharp.CSharpCodeProvider +Microsoft.VisualBasic.VBCodeProvider + +When using NuGet 3.x this package requires at least version 3.4. + +Remarks +----------- +no remarks + + +Dependencies 0 +----------- + + +*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.componentmodel.primitives/4.3.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/system.codedom/5.0.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.componentmodel.primitives/4.3.0/remarks.md rename to Build/third-party-libraries/packages/nuget.org/system.codedom/5.0.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.5.0/package-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/system.codedom/5.0.0/repository-LICENSE.TXT similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.5.0/package-LICENSE.txt rename to Build/third-party-libraries/packages/nuget.org/system.codedom/5.0.0/repository-LICENSE.TXT diff --git a/Build/third-party-libraries/packages/nuget.org/system.componentmodel.primitives/4.3.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/system.codedom/5.0.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.componentmodel.primitives/4.3.0/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/system.codedom/5.0.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/system.collections.nongeneric/4.3.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.collections.nongeneric/4.3.0/index.json deleted file mode 100644 index 330a9b8c..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.collections.nongeneric/4.3.0/index.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "License": { - "Code": "ms-net-library", - "Status": "AutomaticallyApproved" - }, - "UsedBy": [ - { - "Name": "SqlDatabase", - "InternalOnly": true, - "TargetFrameworks": [ - "netcoreapp3.1", - "net5.0", - "net6.0", - "net472" - ], - "Dependencies": [ - { - "Name": "System.Threading", - "Version": "4.3.0" - } - ] - } - ], - "Licenses": [ - { - "Subject": "package", - "Code": "ms-net-library", - "HRef": "http://go.microsoft.com/fwlink/?LinkId=329770", - "Description": null - }, - { - "Subject": "project", - "Code": null, - "HRef": "https://dot.net/", - "Description": "License should be verified on https://dot.net/" - } - ] -} \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.collections.nongeneric/4.3.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.collections.nongeneric/4.3.0/package.nuspec deleted file mode 100644 index 8ccec465..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.collections.nongeneric/4.3.0/package.nuspec +++ /dev/null @@ -1,53 +0,0 @@ - - - - System.Collections.NonGeneric - 4.3.0 - System.Collections.NonGeneric - Microsoft - microsoft,dotnetframework - true - http://go.microsoft.com/fwlink/?LinkId=329770 - https://dot.net/ - http://go.microsoft.com/fwlink/?LinkID=288859 - Provides classes that define older non-generic collections of objects, such as lists, queues, hash tables and dictionaries. Developers should prefer the generic collections in the System.Collections package. - -Commonly Used Types: -System.Collections.ArrayList -System.Collections.Hashtable -System.Collections.CollectionBase -System.Collections.ReadOnlyCollectionBase -System.Collections.Stack -System.Collections.SortedList -System.Collections.DictionaryBase -System.Collections.Queue -System.Collections.Comparer -System.Collections.CaseInsensitiveComparer - -When using NuGet 3.x this package requires at least version 3.4. - https://go.microsoft.com/fwlink/?LinkID=799421 - © Microsoft Corporation. All rights reserved. - true - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.collections.nongeneric/4.3.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.collections.nongeneric/4.3.0/readme.md deleted file mode 100644 index 3fd51179..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.collections.nongeneric/4.3.0/readme.md +++ /dev/null @@ -1,43 +0,0 @@ -System.Collections.NonGeneric [4.3.0](https://www.nuget.org/packages/System.Collections.NonGeneric/4.3.0) --------------------- - -Used by: SqlDatabase internal - -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 - -License: [ms-net-library](../../../../licenses/ms-net-library) - -- package license: [ms-net-library](http://go.microsoft.com/fwlink/?LinkId=329770) -- project license: [Unknown](https://dot.net/) , License should be verified on https://dot.net/ - -Description ------------ -Provides classes that define older non-generic collections of objects, such as lists, queues, hash tables and dictionaries. Developers should prefer the generic collections in the System.Collections package. - -Commonly Used Types: -System.Collections.ArrayList -System.Collections.Hashtable -System.Collections.CollectionBase -System.Collections.ReadOnlyCollectionBase -System.Collections.Stack -System.Collections.SortedList -System.Collections.DictionaryBase -System.Collections.Queue -System.Collections.Comparer -System.Collections.CaseInsensitiveComparer - -When using NuGet 3.x this package requires at least version 3.4. - -Remarks ------------ -no remarks - - -Dependencies 1 ------------ - -|Name|Version| -|----------|:----| -|[System.Threading](../../../../packages/nuget.org/system.threading/4.3.0)|4.3.0| - -*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.collections.specialized/4.3.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.collections.specialized/4.3.0/index.json deleted file mode 100644 index bf2a4599..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.collections.specialized/4.3.0/index.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "License": { - "Code": "ms-net-library", - "Status": "AutomaticallyApproved" - }, - "UsedBy": [ - { - "Name": "SqlDatabase", - "InternalOnly": true, - "TargetFrameworks": [ - "netcoreapp3.1", - "net5.0", - "net6.0", - "net472" - ], - "Dependencies": [ - { - "Name": "System.Collections.NonGeneric", - "Version": "4.3.0" - }, - { - "Name": "System.Threading", - "Version": "4.3.0" - } - ] - } - ], - "Licenses": [ - { - "Subject": "package", - "Code": "ms-net-library", - "HRef": "http://go.microsoft.com/fwlink/?LinkId=329770", - "Description": null - }, - { - "Subject": "project", - "Code": null, - "HRef": "https://dot.net/", - "Description": "License should be verified on https://dot.net/" - } - ] -} \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.collections.specialized/4.3.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.collections.specialized/4.3.0/package.nuspec deleted file mode 100644 index 96aa86b4..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.collections.specialized/4.3.0/package.nuspec +++ /dev/null @@ -1,53 +0,0 @@ - - - - System.Collections.Specialized - 4.3.0 - System.Collections.Specialized - Microsoft - microsoft,dotnetframework - true - http://go.microsoft.com/fwlink/?LinkId=329770 - https://dot.net/ - http://go.microsoft.com/fwlink/?LinkID=288859 - Provides older specialized non-generic collections; for example, a linked list dictionary, a bit vector, and collections that contain only strings. - -Commonly Used Types: -System.Collections.Specialized.NameValueCollection -System.Collections.Specialized.NameObjectCollectionBase -System.Collections.Specialized.StringCollection -System.Collections.Specialized.IOrderedDictionary -System.Collections.Specialized.HybridDictionary -System.Collections.Specialized.OrderedDictionary -System.Collections.Specialized.ListDictionary -System.Collections.Specialized.StringDictionary -System.Collections.Specialized.BitVector32 - -When using NuGet 3.x this package requires at least version 3.4. - https://go.microsoft.com/fwlink/?LinkID=799421 - © Microsoft Corporation. All rights reserved. - true - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.collections.specialized/4.3.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.collections.specialized/4.3.0/readme.md deleted file mode 100644 index 8eedb355..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.collections.specialized/4.3.0/readme.md +++ /dev/null @@ -1,43 +0,0 @@ -System.Collections.Specialized [4.3.0](https://www.nuget.org/packages/System.Collections.Specialized/4.3.0) --------------------- - -Used by: SqlDatabase internal - -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 - -License: [ms-net-library](../../../../licenses/ms-net-library) - -- package license: [ms-net-library](http://go.microsoft.com/fwlink/?LinkId=329770) -- project license: [Unknown](https://dot.net/) , License should be verified on https://dot.net/ - -Description ------------ -Provides older specialized non-generic collections; for example, a linked list dictionary, a bit vector, and collections that contain only strings. - -Commonly Used Types: -System.Collections.Specialized.NameValueCollection -System.Collections.Specialized.NameObjectCollectionBase -System.Collections.Specialized.StringCollection -System.Collections.Specialized.IOrderedDictionary -System.Collections.Specialized.HybridDictionary -System.Collections.Specialized.OrderedDictionary -System.Collections.Specialized.ListDictionary -System.Collections.Specialized.StringDictionary -System.Collections.Specialized.BitVector32 - -When using NuGet 3.x this package requires at least version 3.4. - -Remarks ------------ -no remarks - - -Dependencies 2 ------------ - -|Name|Version| -|----------|:----| -|[System.Collections.NonGeneric](../../../../packages/nuget.org/system.collections.nongeneric/4.3.0)|4.3.0| -|[System.Threading](../../../../packages/nuget.org/system.threading/4.3.0)|4.3.0| - -*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.componentmodel.primitives/4.3.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.componentmodel.primitives/4.3.0/index.json deleted file mode 100644 index 6021bb1b..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.componentmodel.primitives/4.3.0/index.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "License": { - "Code": "ms-net-library", - "Status": "AutomaticallyApproved" - }, - "UsedBy": [ - { - "Name": "SqlDatabase", - "InternalOnly": true, - "TargetFrameworks": [ - "netcoreapp3.1", - "net5.0", - "net6.0", - "net472" - ], - "Dependencies": [ - { - "Name": "System.ComponentModel", - "Version": "4.3.0" - } - ] - } - ], - "Licenses": [ - { - "Subject": "package", - "Code": "ms-net-library", - "HRef": "http://go.microsoft.com/fwlink/?LinkId=329770", - "Description": null - }, - { - "Subject": "project", - "Code": null, - "HRef": "https://dot.net/", - "Description": "License should be verified on https://dot.net/" - } - ] -} \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.componentmodel.primitives/4.3.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.componentmodel.primitives/4.3.0/package.nuspec deleted file mode 100644 index 4a9c5627..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.componentmodel.primitives/4.3.0/package.nuspec +++ /dev/null @@ -1,47 +0,0 @@ - - - - System.ComponentModel.Primitives - 4.3.0 - System.ComponentModel.Primitives - Microsoft - microsoft,dotnetframework - true - http://go.microsoft.com/fwlink/?LinkId=329770 - https://dot.net/ - http://go.microsoft.com/fwlink/?LinkID=288859 - Provides interfaces that are used to implement the run-time and design-time behavior of components. - -Commonly Used Types: -System.ComponentModel.IComponent -System.ComponentModel.IContainer -System.ComponentModel.ISite -System.ComponentModel.ComponentCollection - -When using NuGet 3.x this package requires at least version 3.4. - https://go.microsoft.com/fwlink/?LinkID=799421 - © Microsoft Corporation. All rights reserved. - true - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.componentmodel.primitives/4.3.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.componentmodel.primitives/4.3.0/readme.md deleted file mode 100644 index 506dd88f..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.componentmodel.primitives/4.3.0/readme.md +++ /dev/null @@ -1,37 +0,0 @@ -System.ComponentModel.Primitives [4.3.0](https://www.nuget.org/packages/System.ComponentModel.Primitives/4.3.0) --------------------- - -Used by: SqlDatabase internal - -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 - -License: [ms-net-library](../../../../licenses/ms-net-library) - -- package license: [ms-net-library](http://go.microsoft.com/fwlink/?LinkId=329770) -- project license: [Unknown](https://dot.net/) , License should be verified on https://dot.net/ - -Description ------------ -Provides interfaces that are used to implement the run-time and design-time behavior of components. - -Commonly Used Types: -System.ComponentModel.IComponent -System.ComponentModel.IContainer -System.ComponentModel.ISite -System.ComponentModel.ComponentCollection - -When using NuGet 3.x this package requires at least version 3.4. - -Remarks ------------ -no remarks - - -Dependencies 1 ------------ - -|Name|Version| -|----------|:----| -|[System.ComponentModel](../../../../packages/nuget.org/system.componentmodel/4.3.0)|4.3.0| - -*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.componentmodel.typeconverter/4.3.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.componentmodel.typeconverter/4.3.0/index.json deleted file mode 100644 index eb1de6c5..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.componentmodel.typeconverter/4.3.0/index.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "License": { - "Code": "ms-net-library", - "Status": "AutomaticallyApproved" - }, - "UsedBy": [ - { - "Name": "SqlDatabase", - "InternalOnly": true, - "TargetFrameworks": [ - "netcoreapp3.1", - "net5.0", - "net6.0", - "net472" - ], - "Dependencies": [ - { - "Name": "System.Collections.NonGeneric", - "Version": "4.3.0" - }, - { - "Name": "System.Collections.Specialized", - "Version": "4.3.0" - }, - { - "Name": "System.ComponentModel", - "Version": "4.3.0" - }, - { - "Name": "System.ComponentModel.Primitives", - "Version": "4.3.0" - }, - { - "Name": "System.Linq", - "Version": "4.3.0" - }, - { - "Name": "System.Reflection.TypeExtensions", - "Version": "4.3.0" - }, - { - "Name": "System.Threading", - "Version": "4.3.0" - } - ] - } - ], - "Licenses": [ - { - "Subject": "package", - "Code": "ms-net-library", - "HRef": "http://go.microsoft.com/fwlink/?LinkId=329770", - "Description": null - }, - { - "Subject": "project", - "Code": null, - "HRef": "https://dot.net/", - "Description": "License should be verified on https://dot.net/" - } - ] -} \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.componentmodel.typeconverter/4.3.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.componentmodel.typeconverter/4.3.0/package.nuspec deleted file mode 100644 index 7355cf21..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.componentmodel.typeconverter/4.3.0/package.nuspec +++ /dev/null @@ -1,92 +0,0 @@ - - - - System.ComponentModel.TypeConverter - 4.3.0 - System.ComponentModel.TypeConverter - Microsoft - microsoft,dotnetframework - true - http://go.microsoft.com/fwlink/?LinkId=329770 - https://dot.net/ - http://go.microsoft.com/fwlink/?LinkID=288859 - Provides the System.ComponentModel.TypeConverter class, which represents a unified way of converting types of values to other types. - -Commonly Used Types: -System.ComponentModel.TypeConverter -System.ComponentModel.TypeConverterAttribute -System.ComponentModel.PropertyDescriptor -System.ComponentModel.StringConverter -System.ComponentModel.ITypeDescriptorContext -System.ComponentModel.EnumConverter -System.ComponentModel.TypeDescriptor -System.ComponentModel.Int32Converter -System.ComponentModel.BooleanConverter -System.ComponentModel.DoubleConverter - -When using NuGet 3.x this package requires at least version 3.4. - https://go.microsoft.com/fwlink/?LinkID=799421 - © Microsoft Corporation. All rights reserved. - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.componentmodel.typeconverter/4.3.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.componentmodel.typeconverter/4.3.0/readme.md deleted file mode 100644 index cf75100e..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.componentmodel.typeconverter/4.3.0/readme.md +++ /dev/null @@ -1,49 +0,0 @@ -System.ComponentModel.TypeConverter [4.3.0](https://www.nuget.org/packages/System.ComponentModel.TypeConverter/4.3.0) --------------------- - -Used by: SqlDatabase internal - -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 - -License: [ms-net-library](../../../../licenses/ms-net-library) - -- package license: [ms-net-library](http://go.microsoft.com/fwlink/?LinkId=329770) -- project license: [Unknown](https://dot.net/) , License should be verified on https://dot.net/ - -Description ------------ -Provides the System.ComponentModel.TypeConverter class, which represents a unified way of converting types of values to other types. - -Commonly Used Types: -System.ComponentModel.TypeConverter -System.ComponentModel.TypeConverterAttribute -System.ComponentModel.PropertyDescriptor -System.ComponentModel.StringConverter -System.ComponentModel.ITypeDescriptorContext -System.ComponentModel.EnumConverter -System.ComponentModel.TypeDescriptor -System.ComponentModel.Int32Converter -System.ComponentModel.BooleanConverter -System.ComponentModel.DoubleConverter - -When using NuGet 3.x this package requires at least version 3.4. - -Remarks ------------ -no remarks - - -Dependencies 7 ------------ - -|Name|Version| -|----------|:----| -|[System.Collections.NonGeneric](../../../../packages/nuget.org/system.collections.nongeneric/4.3.0)|4.3.0| -|[System.Collections.Specialized](../../../../packages/nuget.org/system.collections.specialized/4.3.0)|4.3.0| -|[System.ComponentModel](../../../../packages/nuget.org/system.componentmodel/4.3.0)|4.3.0| -|[System.ComponentModel.Primitives](../../../../packages/nuget.org/system.componentmodel.primitives/4.3.0)|4.3.0| -|[System.Linq](../../../../packages/nuget.org/system.linq/4.3.0)|4.3.0| -|[System.Reflection.TypeExtensions](../../../../packages/nuget.org/system.reflection.typeextensions/4.3.0)|4.3.0| -|[System.Threading](../../../../packages/nuget.org/system.threading/4.3.0)|4.3.0| - -*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.componentmodel/4.3.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.componentmodel/4.3.0/index.json deleted file mode 100644 index e143dd9c..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.componentmodel/4.3.0/index.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "License": { - "Code": "ms-net-library", - "Status": "AutomaticallyApproved" - }, - "UsedBy": [ - { - "Name": "SqlDatabase", - "InternalOnly": true, - "TargetFrameworks": [ - "netcoreapp3.1", - "net5.0", - "net6.0", - "net472" - ] - } - ], - "Licenses": [ - { - "Subject": "package", - "Code": "ms-net-library", - "HRef": "http://go.microsoft.com/fwlink/?LinkId=329770", - "Description": null - }, - { - "Subject": "project", - "Code": null, - "HRef": "https://dot.net/", - "Description": "License should be verified on https://dot.net/" - } - ] -} \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.componentmodel/4.3.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.componentmodel/4.3.0/package.nuspec deleted file mode 100644 index 8e4b8c9a..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.componentmodel/4.3.0/package.nuspec +++ /dev/null @@ -1,52 +0,0 @@ - - - - System.ComponentModel - 4.3.0 - System.ComponentModel - Microsoft - microsoft,dotnetframework - true - http://go.microsoft.com/fwlink/?LinkId=329770 - https://dot.net/ - http://go.microsoft.com/fwlink/?LinkID=288859 - Provides interfaces for the editing and change tracking of objects used as data sources. - -Commonly Used Types: -System.ComponentModel.CancelEventArgs -System.IServiceProvider -System.ComponentModel.IEditableObject -System.ComponentModel.IChangeTracking -System.ComponentModel.IRevertibleChangeTracking - -When using NuGet 3.x this package requires at least version 3.4. - https://go.microsoft.com/fwlink/?LinkID=799421 - © Microsoft Corporation. All rights reserved. - true - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.componentmodel/4.3.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.componentmodel/4.3.0/readme.md deleted file mode 100644 index 1be96bc6..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.componentmodel/4.3.0/readme.md +++ /dev/null @@ -1,35 +0,0 @@ -System.ComponentModel [4.3.0](https://www.nuget.org/packages/System.ComponentModel/4.3.0) --------------------- - -Used by: SqlDatabase internal - -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 - -License: [ms-net-library](../../../../licenses/ms-net-library) - -- package license: [ms-net-library](http://go.microsoft.com/fwlink/?LinkId=329770) -- project license: [Unknown](https://dot.net/) , License should be verified on https://dot.net/ - -Description ------------ -Provides interfaces for the editing and change tracking of objects used as data sources. - -Commonly Used Types: -System.ComponentModel.CancelEventArgs -System.IServiceProvider -System.ComponentModel.IEditableObject -System.ComponentModel.IChangeTracking -System.ComponentModel.IRevertibleChangeTracking - -When using NuGet 3.x this package requires at least version 3.4. - -Remarks ------------ -no remarks - - -Dependencies 0 ------------ - - -*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.configuration.configurationmanager/4.5.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.configuration.configurationmanager/4.5.0/index.json index ca36c0cd..ebc0d666 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.configuration.configurationmanager/4.5.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.configuration.configurationmanager/4.5.0/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net452", "netstandard2.0" ], diff --git a/Build/third-party-libraries/packages/nuget.org/system.configuration.configurationmanager/4.5.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.configuration.configurationmanager/4.5.0/readme.md index f64fbaee..cccab090 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.configuration.configurationmanager/4.5.0/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.configuration.configurationmanager/4.5.0/readme.md @@ -3,7 +3,7 @@ System.Configuration.ConfigurationManager [4.5.0](https://www.nuget.org/packages Used by: SqlDatabase -Target frameworks: net452, net5.0, net6.0, netcoreapp3.1, netstandard2.0 +Target frameworks: net452, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.5.1/index.json b/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/index.json similarity index 65% rename from Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.5.1/index.json rename to Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/index.json index 010dc70b..b55c8262 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.5.1/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/index.json @@ -11,21 +11,18 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net452", "netstandard2.0" ], "Dependencies": [ { "Name": "Microsoft.Win32.Registry", - "Version": "4.5.0" + "Version": "4.7.0" }, { "Name": "System.Security.Principal.Windows", - "Version": "4.5.0" - }, - { - "Name": "System.Text.Encoding.CodePages", - "Version": "4.5.0" + "Version": "4.7.0" } ] } @@ -34,14 +31,14 @@ { "Subject": "package", "Code": "MIT", - "HRef": "https://github.com/dotnet/corefx/blob/master/LICENSE.TXT", + "HRef": "https://licenses.nuget.org/MIT", "Description": null }, { "Subject": "project", "Code": null, - "HRef": "https://dot.net/", - "Description": "License should be verified on https://dot.net/" + "HRef": "https://github.com/dotnet/corefx", + "Description": "License should be verified on https://github.com/dotnet/corefx" } ] } \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/package-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/package-LICENSE.txt new file mode 100644 index 00000000..984713a4 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/package-LICENSE.txt @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) .NET Foundation and Contributors + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.5.1/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/package.nuspec similarity index 73% rename from Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.5.1/package.nuspec rename to Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/package.nuspec index def3ca91..74d98029 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.5.1/package.nuspec +++ b/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/package.nuspec @@ -2,13 +2,15 @@ System.Data.SqlClient - 4.5.1 + 4.8.5 System.Data.SqlClient Microsoft microsoft,dotnetframework false - https://github.com/dotnet/corefx/blob/master/LICENSE.TXT - https://dot.net/ + MIT + https://licenses.nuget.org/MIT + Icon.png + https://github.com/dotnet/corefx http://go.microsoft.com/fwlink/?LinkID=288859 Provides the data provider for SQL Server. These classes provide access to versions of SQL Server and encapsulate database-specific protocols, including tabular data stream (TDS) @@ -23,10 +25,9 @@ System.Data.SqlClient.SqlTransaction System.Data.SqlClient.SqlParameterCollection System.Data.SqlClient.SqlClientFactory -7ee84596d92e178bce54c986df31ccc52479e772 When using NuGet 3.x this package requires at least version 3.4. https://go.microsoft.com/fwlink/?LinkID=799421 - © Microsoft Corporation. All rights reserved. + © Microsoft Corporation. All rights reserved. true @@ -39,18 +40,24 @@ When using NuGet 3.x this package requires at least version 3.4. - - - - - - + + + + + + - - - - + + + + + + + + + + @@ -58,35 +65,36 @@ When using NuGet 3.x this package requires at least version 3.4. - + - + - + - - + + - - - - - - - + + + + + + + - - - + + + + diff --git a/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.5.1/readme.md b/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/readme.md similarity index 61% rename from Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.5.1/readme.md rename to Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/readme.md index 608c0bca..67e11c15 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.5.1/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/readme.md @@ -1,14 +1,14 @@ -System.Data.SqlClient [4.5.1](https://www.nuget.org/packages/System.Data.SqlClient/4.5.1) +System.Data.SqlClient [4.8.5](https://www.nuget.org/packages/System.Data.SqlClient/4.8.5) -------------------- Used by: SqlDatabase -Target frameworks: net452, net5.0, net6.0, netcoreapp3.1, netstandard2.0 +Target frameworks: net452, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 License: [MIT](../../../../licenses/mit) -- package license: [MIT](https://github.com/dotnet/corefx/blob/master/LICENSE.TXT) -- project license: [Unknown](https://dot.net/) , License should be verified on https://dot.net/ +- package license: [MIT](https://licenses.nuget.org/MIT) +- project license: [Unknown](https://github.com/dotnet/corefx) , License should be verified on https://github.com/dotnet/corefx Description ----------- @@ -25,7 +25,6 @@ System.Data.SqlClient.SqlTransaction System.Data.SqlClient.SqlParameterCollection System.Data.SqlClient.SqlClientFactory -7ee84596d92e178bce54c986df31ccc52479e772 When using NuGet 3.x this package requires at least version 3.4. Remarks @@ -33,13 +32,12 @@ Remarks no remarks -Dependencies 3 +Dependencies 2 ----------- |Name|Version| |----------|:----| -|[Microsoft.Win32.Registry](../../../../packages/nuget.org/microsoft.win32.registry/4.5.0)|4.5.0| -|[System.Security.Principal.Windows](../../../../packages/nuget.org/system.security.principal.windows/4.5.0)|4.5.0| -|[System.Text.Encoding.CodePages](../../../../packages/nuget.org/system.text.encoding.codepages/4.5.0)|4.5.0| +|[Microsoft.Win32.Registry](../../../../packages/nuget.org/microsoft.win32.registry/4.7.0)|4.7.0| +|[System.Security.Principal.Windows](../../../../packages/nuget.org/system.security.principal.windows/4.7.0)|4.7.0| *This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.componentmodel.typeconverter/4.3.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.componentmodel.typeconverter/4.3.0/remarks.md rename to Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/system.componentmodel.typeconverter/4.3.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.componentmodel.typeconverter/4.3.0/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.8.5/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.7.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.7.0/index.json new file mode 100644 index 00000000..5d326378 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.7.0/index.json @@ -0,0 +1,40 @@ +{ + "License": { + "Code": "MIT", + "Status": "AutomaticallyApproved" + }, + "UsedBy": [ + { + "Name": "SqlDatabase", + "InternalOnly": false, + "TargetFrameworks": [ + "netcoreapp3.1", + "net5.0", + "net6.0", + "net7.0", + "net452", + "netstandard2.0" + ], + "Dependencies": [ + { + "Name": "System.Memory", + "Version": "4.5.4" + } + ] + } + ], + "Licenses": [ + { + "Subject": "package", + "Code": "MIT", + "HRef": "https://licenses.nuget.org/MIT", + "Description": null + }, + { + "Subject": "project", + "Code": null, + "HRef": "https://github.com/dotnet/corefx", + "Description": "License should be verified on https://github.com/dotnet/corefx" + } + ] +} \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.7.0/package-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.7.0/package-LICENSE.txt new file mode 100644 index 00000000..984713a4 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.7.0/package-LICENSE.txt @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) .NET Foundation and Contributors + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.5.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.7.0/package.nuspec similarity index 60% rename from Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.5.0/package.nuspec rename to Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.7.0/package.nuspec index 77278e69..2b3b3e94 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.5.0/package.nuspec +++ b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.7.0/package.nuspec @@ -2,13 +2,14 @@ System.Diagnostics.DiagnosticSource - 4.5.0 + 4.7.0 System.Diagnostics.DiagnosticSource Microsoft microsoft,dotnetframework false - https://github.com/dotnet/corefx/blob/master/LICENSE.TXT - https://dot.net/ + MIT + https://licenses.nuget.org/MIT + https://github.com/dotnet/corefx http://go.microsoft.com/fwlink/?LinkID=288859 Provides Classes that allow you to decouple code logging rich (unserializable) diagnostics/telemetry (e.g. framework) from code that consumes it (e.g. tools) @@ -16,34 +17,56 @@ Commonly Used Types: System.Diagnostics.DiagnosticListener System.Diagnostics.DiagnosticSource -30ab651fcb4354552bd4891619a0bdd81e0ebdbf When using NuGet 3.x this package requires at least version 3.4. https://go.microsoft.com/fwlink/?LinkID=799421 - © Microsoft Corporation. All rights reserved. + © Microsoft Corporation. All rights reserved. true - - + + + + + + + + + + + + + + + + - + + + + + + + + + + diff --git a/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.5.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.7.0/readme.md similarity index 50% rename from Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.5.0/readme.md rename to Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.7.0/readme.md index e99aa47e..90f71dd7 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.5.0/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.7.0/readme.md @@ -1,14 +1,14 @@ -System.Diagnostics.DiagnosticSource [4.5.0](https://www.nuget.org/packages/System.Diagnostics.DiagnosticSource/4.5.0) +System.Diagnostics.DiagnosticSource [4.7.0](https://www.nuget.org/packages/System.Diagnostics.DiagnosticSource/4.7.0) -------------------- Used by: SqlDatabase -Target frameworks: net452, net5.0, net6.0, netcoreapp3.1, netstandard2.0 +Target frameworks: net452, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 License: [MIT](../../../../licenses/mit) -- package license: [MIT](https://github.com/dotnet/corefx/blob/master/LICENSE.TXT) -- project license: [Unknown](https://dot.net/) , License should be verified on https://dot.net/ +- package license: [MIT](https://licenses.nuget.org/MIT) +- project license: [Unknown](https://github.com/dotnet/corefx) , License should be verified on https://github.com/dotnet/corefx Description ----------- @@ -18,7 +18,6 @@ Commonly Used Types: System.Diagnostics.DiagnosticListener System.Diagnostics.DiagnosticSource -30ab651fcb4354552bd4891619a0bdd81e0ebdbf When using NuGet 3.x this package requires at least version 3.4. Remarks @@ -26,8 +25,11 @@ Remarks no remarks -Dependencies 0 +Dependencies 1 ----------- +|Name|Version| +|----------|:----| +|[System.Memory](../../../../packages/nuget.org/system.memory/4.5.4)|4.5.4| *This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.componentmodel/4.3.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.7.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.componentmodel/4.3.0/remarks.md rename to Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.7.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/system.componentmodel/4.3.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.7.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.componentmodel/4.3.0/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.7.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/4.7.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/4.7.0/index.json new file mode 100644 index 00000000..89590aa6 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/4.7.0/index.json @@ -0,0 +1,43 @@ +{ + "License": { + "Code": "MIT", + "Status": "AutomaticallyApproved" + }, + "UsedBy": [ + { + "Name": "SqlDatabase", + "InternalOnly": true, + "TargetFrameworks": [ + "netcoreapp3.1", + "net5.0", + "net6.0", + "net7.0", + "net472" + ], + "Dependencies": [ + { + "Name": "Microsoft.Win32.Registry", + "Version": "5.0.0" + }, + { + "Name": "System.Security.Principal.Windows", + "Version": "5.0.0" + } + ] + } + ], + "Licenses": [ + { + "Subject": "package", + "Code": "MIT", + "HRef": "https://licenses.nuget.org/MIT", + "Description": null + }, + { + "Subject": "project", + "Code": null, + "HRef": "https://github.com/dotnet/corefx", + "Description": "License should be verified on https://github.com/dotnet/corefx" + } + ] +} \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/4.7.0/package-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/4.7.0/package-LICENSE.txt new file mode 100644 index 00000000..984713a4 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/4.7.0/package-LICENSE.txt @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) .NET Foundation and Contributors + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/4.7.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/4.7.0/package.nuspec new file mode 100644 index 00000000..3c247bb4 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/4.7.0/package.nuspec @@ -0,0 +1,49 @@ + + + + System.Diagnostics.EventLog + 4.7.0 + System.Diagnostics.EventLog + Microsoft + microsoft,dotnetframework + false + MIT + https://licenses.nuget.org/MIT + https://github.com/dotnet/corefx + http://go.microsoft.com/fwlink/?LinkID=288859 + Provides the System.Diagnostics.EventLog class, which allows the applications to use the windows event log service. + +Commonly Used Types: +System.Diagnostics.EventLog + +When using NuGet 3.x this package requires at least version 3.4. + https://go.microsoft.com/fwlink/?LinkID=799421 + © Microsoft Corporation. All rights reserved. + true + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/4.7.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/4.7.0/readme.md new file mode 100644 index 00000000..608ab741 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/4.7.0/readme.md @@ -0,0 +1,35 @@ +System.Diagnostics.EventLog [4.7.0](https://www.nuget.org/packages/System.Diagnostics.EventLog/4.7.0) +-------------------- + +Used by: SqlDatabase internal + +Target frameworks: net472, net5.0, net6.0, net7.0, netcoreapp3.1 + +License: [MIT](../../../../licenses/mit) + +- package license: [MIT](https://licenses.nuget.org/MIT) +- project license: [Unknown](https://github.com/dotnet/corefx) , License should be verified on https://github.com/dotnet/corefx + +Description +----------- +Provides the System.Diagnostics.EventLog class, which allows the applications to use the windows event log service. + +Commonly Used Types: +System.Diagnostics.EventLog + +When using NuGet 3.x this package requires at least version 3.4. + +Remarks +----------- +no remarks + + +Dependencies 2 +----------- + +|Name|Version| +|----------|:----| +|[Microsoft.Win32.Registry](../../../../packages/nuget.org/microsoft.win32.registry/5.0.0)|5.0.0| +|[System.Security.Principal.Windows](../../../../packages/nuget.org/system.security.principal.windows/5.0.0)|5.0.0| + +*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.5.1/remarks.md b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/4.7.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.5.1/remarks.md rename to Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/4.7.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.5.1/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/4.7.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.data.sqlclient/4.5.1/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/4.7.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.5.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/6.0.0/index.json similarity index 72% rename from Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.5.0/index.json rename to Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/6.0.0/index.json index c19f5aa6..3a4ffb5d 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.5.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/6.0.0/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net472" ] } @@ -19,7 +20,13 @@ { "Subject": "package", "Code": "MIT", - "HRef": "https://github.com/dotnet/corefx/blob/master/LICENSE.TXT", + "HRef": "https://licenses.nuget.org/MIT", + "Description": null + }, + { + "Subject": "repository", + "Code": "MIT", + "HRef": "https://github.com/dotnet/runtime", "Description": null }, { diff --git a/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/6.0.0/package-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/6.0.0/package-LICENSE.txt new file mode 100644 index 00000000..984713a4 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/6.0.0/package-LICENSE.txt @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) .NET Foundation and Contributors + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/6.0.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/6.0.0/package.nuspec new file mode 100644 index 00000000..292fa0aa --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/6.0.0/package.nuspec @@ -0,0 +1,33 @@ + + + + System.Diagnostics.EventLog + 6.0.0 + Microsoft + MIT + https://licenses.nuget.org/MIT + Icon.png + https://dot.net/ + Provides the System.Diagnostics.EventLog class, which allows the applications to use the windows event log service. + +Commonly Used Types: +System.Diagnostics.EventLog + https://go.microsoft.com/fwlink/?LinkID=799421 + © Microsoft Corporation. All rights reserved. + true + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/6.0.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/6.0.0/readme.md new file mode 100644 index 00000000..4b61a19a --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/6.0.0/readme.md @@ -0,0 +1,30 @@ +System.Diagnostics.EventLog [6.0.0](https://www.nuget.org/packages/System.Diagnostics.EventLog/6.0.0) +-------------------- + +Used by: SqlDatabase internal + +Target frameworks: net472, net5.0, net6.0, net7.0, netcoreapp3.1 + +License: [MIT](../../../../licenses/mit) + +- package license: [MIT](https://licenses.nuget.org/MIT) +- repository license: [MIT](https://github.com/dotnet/runtime) +- project license: [Unknown](https://dot.net/) , License should be verified on https://dot.net/ + +Description +----------- +Provides the System.Diagnostics.EventLog class, which allows the applications to use the windows event log service. + +Commonly Used Types: +System.Diagnostics.EventLog + +Remarks +----------- +no remarks + + +Dependencies 0 +----------- + + +*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.5.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/6.0.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.5.0/remarks.md rename to Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/6.0.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/6.0.0/repository-LICENSE.TXT b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/6.0.0/repository-LICENSE.TXT new file mode 100644 index 00000000..984713a4 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/6.0.0/repository-LICENSE.TXT @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) .NET Foundation and Contributors + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.5.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/6.0.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.5.0/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/system.diagnostics.eventlog/6.0.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/system.dynamic.runtime/4.3.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.dynamic.runtime/4.3.0/index.json deleted file mode 100644 index 8ded9a29..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.dynamic.runtime/4.3.0/index.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "License": { - "Code": "ms-net-library", - "Status": "AutomaticallyApproved" - }, - "UsedBy": [ - { - "Name": "SqlDatabase", - "InternalOnly": true, - "TargetFrameworks": [ - "netcoreapp3.1", - "net5.0", - "net6.0", - "net472" - ], - "Dependencies": [ - { - "Name": "System.Linq", - "Version": "4.3.0" - }, - { - "Name": "System.Linq.Expressions", - "Version": "4.3.0" - }, - { - "Name": "System.ObjectModel", - "Version": "4.3.0" - }, - { - "Name": "System.Reflection.TypeExtensions", - "Version": "4.3.0" - }, - { - "Name": "System.Threading", - "Version": "4.3.0" - } - ] - } - ], - "Licenses": [ - { - "Subject": "package", - "Code": "ms-net-library", - "HRef": "http://go.microsoft.com/fwlink/?LinkId=329770", - "Description": null - }, - { - "Subject": "project", - "Code": null, - "HRef": "https://dot.net/", - "Description": "License should be verified on https://dot.net/" - } - ] -} \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.dynamic.runtime/4.3.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.dynamic.runtime/4.3.0/package.nuspec deleted file mode 100644 index 7f9aca30..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.dynamic.runtime/4.3.0/package.nuspec +++ /dev/null @@ -1,84 +0,0 @@ - - - - System.Dynamic.Runtime - 4.3.0 - System.Dynamic.Runtime - Microsoft - microsoft,dotnetframework - true - http://go.microsoft.com/fwlink/?LinkId=329770 - https://dot.net/ - http://go.microsoft.com/fwlink/?LinkID=288859 - Provides classes and interfaces that support the Dynamic Language Runtime (DLR). - -Commonly Used Types: -System.Runtime.CompilerServices.CallSite -System.Runtime.CompilerServices.CallSite<T> -System.Dynamic.IDynamicMetaObjectProvider -System.Dynamic.DynamicMetaObject -System.Dynamic.SetMemberBinder -System.Dynamic.GetMemberBinder -System.Dynamic.ExpandoObject -System.Dynamic.DynamicObject -System.Runtime.CompilerServices.CallSiteBinder -System.Runtime.CompilerServices.ConditionalWeakTable<TKey, TValue> - -When using NuGet 3.x this package requires at least version 3.4. - https://go.microsoft.com/fwlink/?LinkID=799421 - © Microsoft Corporation. All rights reserved. - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.dynamic.runtime/4.3.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.dynamic.runtime/4.3.0/readme.md deleted file mode 100644 index c19a0d5c..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.dynamic.runtime/4.3.0/readme.md +++ /dev/null @@ -1,47 +0,0 @@ -System.Dynamic.Runtime [4.3.0](https://www.nuget.org/packages/System.Dynamic.Runtime/4.3.0) --------------------- - -Used by: SqlDatabase internal - -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 - -License: [ms-net-library](../../../../licenses/ms-net-library) - -- package license: [ms-net-library](http://go.microsoft.com/fwlink/?LinkId=329770) -- project license: [Unknown](https://dot.net/) , License should be verified on https://dot.net/ - -Description ------------ -Provides classes and interfaces that support the Dynamic Language Runtime (DLR). - -Commonly Used Types: -System.Runtime.CompilerServices.CallSite -System.Runtime.CompilerServices.CallSite -System.Dynamic.IDynamicMetaObjectProvider -System.Dynamic.DynamicMetaObject -System.Dynamic.SetMemberBinder -System.Dynamic.GetMemberBinder -System.Dynamic.ExpandoObject -System.Dynamic.DynamicObject -System.Runtime.CompilerServices.CallSiteBinder -System.Runtime.CompilerServices.ConditionalWeakTable - -When using NuGet 3.x this package requires at least version 3.4. - -Remarks ------------ -no remarks - - -Dependencies 5 ------------ - -|Name|Version| -|----------|:----| -|[System.Linq](../../../../packages/nuget.org/system.linq/4.3.0)|4.3.0| -|[System.Linq.Expressions](../../../../packages/nuget.org/system.linq.expressions/4.3.0)|4.3.0| -|[System.ObjectModel](../../../../packages/nuget.org/system.objectmodel/4.3.0)|4.3.0| -|[System.Reflection.TypeExtensions](../../../../packages/nuget.org/system.reflection.typeextensions/4.3.0)|4.3.0| -|[System.Threading](../../../../packages/nuget.org/system.threading/4.3.0)|4.3.0| - -*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.io.filesystem.primitives/4.3.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.io.filesystem.primitives/4.3.0/index.json deleted file mode 100644 index e143dd9c..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.io.filesystem.primitives/4.3.0/index.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "License": { - "Code": "ms-net-library", - "Status": "AutomaticallyApproved" - }, - "UsedBy": [ - { - "Name": "SqlDatabase", - "InternalOnly": true, - "TargetFrameworks": [ - "netcoreapp3.1", - "net5.0", - "net6.0", - "net472" - ] - } - ], - "Licenses": [ - { - "Subject": "package", - "Code": "ms-net-library", - "HRef": "http://go.microsoft.com/fwlink/?LinkId=329770", - "Description": null - }, - { - "Subject": "project", - "Code": null, - "HRef": "https://dot.net/", - "Description": "License should be verified on https://dot.net/" - } - ] -} \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.io.filesystem.primitives/4.3.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.io.filesystem.primitives/4.3.0/package.nuspec deleted file mode 100644 index 8f5e1854..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.io.filesystem.primitives/4.3.0/package.nuspec +++ /dev/null @@ -1,44 +0,0 @@ - - - - System.IO.FileSystem.Primitives - 4.3.0 - System.IO.FileSystem.Primitives - Microsoft - microsoft,dotnetframework - true - http://go.microsoft.com/fwlink/?LinkId=329770 - https://dot.net/ - http://go.microsoft.com/fwlink/?LinkID=288859 - Provides common enumerations and exceptions for path-based I/O libraries. - -Commonly Used Types: -System.IO.DirectoryNotFoundException -System.IO.FileAccess -System.IO.FileLoadException -System.IO.PathTooLongException -System.IO.FileMode -System.IO.FileShare -System.IO.FileAttributes - -When using NuGet 3.x this package requires at least version 3.4. - https://go.microsoft.com/fwlink/?LinkID=799421 - © Microsoft Corporation. All rights reserved. - true - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.io.filesystem.primitives/4.3.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.io.filesystem.primitives/4.3.0/readme.md deleted file mode 100644 index aaa88dfb..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.io.filesystem.primitives/4.3.0/readme.md +++ /dev/null @@ -1,37 +0,0 @@ -System.IO.FileSystem.Primitives [4.3.0](https://www.nuget.org/packages/System.IO.FileSystem.Primitives/4.3.0) --------------------- - -Used by: SqlDatabase internal - -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 - -License: [ms-net-library](../../../../licenses/ms-net-library) - -- package license: [ms-net-library](http://go.microsoft.com/fwlink/?LinkId=329770) -- project license: [Unknown](https://dot.net/) , License should be verified on https://dot.net/ - -Description ------------ -Provides common enumerations and exceptions for path-based I/O libraries. - -Commonly Used Types: -System.IO.DirectoryNotFoundException -System.IO.FileAccess -System.IO.FileLoadException -System.IO.PathTooLongException -System.IO.FileMode -System.IO.FileShare -System.IO.FileAttributes - -When using NuGet 3.x this package requires at least version 3.4. - -Remarks ------------ -no remarks - - -Dependencies 0 ------------ - - -*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.linq.expressions/4.3.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.linq.expressions/4.3.0/index.json deleted file mode 100644 index 8d68cc2f..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.linq.expressions/4.3.0/index.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "License": { - "Code": "ms-net-library", - "Status": "AutomaticallyApproved" - }, - "UsedBy": [ - { - "Name": "SqlDatabase", - "InternalOnly": true, - "TargetFrameworks": [ - "netcoreapp3.1", - "net5.0", - "net6.0", - "net472" - ], - "Dependencies": [ - { - "Name": "System.Linq", - "Version": "4.3.0" - }, - { - "Name": "System.ObjectModel", - "Version": "4.3.0" - }, - { - "Name": "System.Reflection.TypeExtensions", - "Version": "4.3.0" - }, - { - "Name": "System.Threading", - "Version": "4.3.0" - } - ] - } - ], - "Licenses": [ - { - "Subject": "package", - "Code": "ms-net-library", - "HRef": "http://go.microsoft.com/fwlink/?LinkId=329770", - "Description": null - }, - { - "Subject": "project", - "Code": null, - "HRef": "https://dot.net/", - "Description": "License should be verified on https://dot.net/" - } - ] -} \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.linq.expressions/4.3.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.linq.expressions/4.3.0/package.nuspec deleted file mode 100644 index 85bf78f7..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.linq.expressions/4.3.0/package.nuspec +++ /dev/null @@ -1,90 +0,0 @@ - - - - System.Linq.Expressions - 4.3.0 - System.Linq.Expressions - Microsoft - microsoft,dotnetframework - true - http://go.microsoft.com/fwlink/?LinkId=329770 - https://dot.net/ - http://go.microsoft.com/fwlink/?LinkID=288859 - Provides classes, interfaces and enumerations that enable language-level code expressions to be represented as objects in the form of expression trees. - -Commonly Used Types: -System.Linq.IQueryable<T> -System.Linq.IQueryable -System.Linq.Expressions.Expression<TDelegate> -System.Linq.Expressions.Expression -System.Linq.Expressions.ExpressionVisitor - -When using NuGet 3.x this package requires at least version 3.4. - https://go.microsoft.com/fwlink/?LinkID=799421 - © Microsoft Corporation. All rights reserved. - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.linq.expressions/4.3.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.linq.expressions/4.3.0/readme.md deleted file mode 100644 index cb979b66..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.linq.expressions/4.3.0/readme.md +++ /dev/null @@ -1,41 +0,0 @@ -System.Linq.Expressions [4.3.0](https://www.nuget.org/packages/System.Linq.Expressions/4.3.0) --------------------- - -Used by: SqlDatabase internal - -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 - -License: [ms-net-library](../../../../licenses/ms-net-library) - -- package license: [ms-net-library](http://go.microsoft.com/fwlink/?LinkId=329770) -- project license: [Unknown](https://dot.net/) , License should be verified on https://dot.net/ - -Description ------------ -Provides classes, interfaces and enumerations that enable language-level code expressions to be represented as objects in the form of expression trees. - -Commonly Used Types: -System.Linq.IQueryable -System.Linq.IQueryable -System.Linq.Expressions.Expression -System.Linq.Expressions.Expression -System.Linq.Expressions.ExpressionVisitor - -When using NuGet 3.x this package requires at least version 3.4. - -Remarks ------------ -no remarks - - -Dependencies 4 ------------ - -|Name|Version| -|----------|:----| -|[System.Linq](../../../../packages/nuget.org/system.linq/4.3.0)|4.3.0| -|[System.ObjectModel](../../../../packages/nuget.org/system.objectmodel/4.3.0)|4.3.0| -|[System.Reflection.TypeExtensions](../../../../packages/nuget.org/system.reflection.typeextensions/4.3.0)|4.3.0| -|[System.Threading](../../../../packages/nuget.org/system.threading/4.3.0)|4.3.0| - -*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.linq/4.3.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.linq/4.3.0/index.json deleted file mode 100644 index e143dd9c..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.linq/4.3.0/index.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "License": { - "Code": "ms-net-library", - "Status": "AutomaticallyApproved" - }, - "UsedBy": [ - { - "Name": "SqlDatabase", - "InternalOnly": true, - "TargetFrameworks": [ - "netcoreapp3.1", - "net5.0", - "net6.0", - "net472" - ] - } - ], - "Licenses": [ - { - "Subject": "package", - "Code": "ms-net-library", - "HRef": "http://go.microsoft.com/fwlink/?LinkId=329770", - "Description": null - }, - { - "Subject": "project", - "Code": null, - "HRef": "https://dot.net/", - "Description": "License should be verified on https://dot.net/" - } - ] -} \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.linq/4.3.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.linq/4.3.0/package.nuspec deleted file mode 100644 index 12a3b10e..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.linq/4.3.0/package.nuspec +++ /dev/null @@ -1,64 +0,0 @@ - - - - System.Linq - 4.3.0 - System.Linq - Microsoft - microsoft,dotnetframework - true - http://go.microsoft.com/fwlink/?LinkId=329770 - https://dot.net/ - http://go.microsoft.com/fwlink/?LinkID=288859 - Provides classes and interfaces that supports queries that use Language-Integrated Query (LINQ). - -Commonly Used Types: -System.Linq.Enumerable -System.Linq.IGrouping<TKey, TElement> -System.Linq.IOrderedEnumerable<TElement> -System.Linq.ILookup<TKey, TElement> -System.Linq.Lookup<TKey, TElement> - -When using NuGet 3.x this package requires at least version 3.4. - https://go.microsoft.com/fwlink/?LinkID=799421 - © Microsoft Corporation. All rights reserved. - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.linq/4.3.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.linq/4.3.0/readme.md deleted file mode 100644 index 31f8a38f..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.linq/4.3.0/readme.md +++ /dev/null @@ -1,35 +0,0 @@ -System.Linq [4.3.0](https://www.nuget.org/packages/System.Linq/4.3.0) --------------------- - -Used by: SqlDatabase internal - -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 - -License: [ms-net-library](../../../../licenses/ms-net-library) - -- package license: [ms-net-library](http://go.microsoft.com/fwlink/?LinkId=329770) -- project license: [Unknown](https://dot.net/) , License should be verified on https://dot.net/ - -Description ------------ -Provides classes and interfaces that supports queries that use Language-Integrated Query (LINQ). - -Commonly Used Types: -System.Linq.Enumerable -System.Linq.IGrouping -System.Linq.IOrderedEnumerable -System.Linq.ILookup -System.Linq.Lookup - -When using NuGet 3.x this package requires at least version 3.4. - -Remarks ------------ -no remarks - - -Dependencies 0 ------------ - - -*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.management/5.0.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.management/5.0.0/index.json new file mode 100644 index 00000000..905d5fee --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.management/5.0.0/index.json @@ -0,0 +1,49 @@ +{ + "License": { + "Code": "MIT", + "Status": "AutomaticallyApproved" + }, + "UsedBy": [ + { + "Name": "SqlDatabase", + "InternalOnly": true, + "TargetFrameworks": [ + "netcoreapp3.1", + "net5.0", + "net6.0", + "net7.0", + "net472" + ], + "Dependencies": [ + { + "Name": "Microsoft.Win32.Registry", + "Version": "5.0.0" + }, + { + "Name": "System.CodeDom", + "Version": "5.0.0" + } + ] + } + ], + "Licenses": [ + { + "Subject": "package", + "Code": "MIT", + "HRef": "https://licenses.nuget.org/MIT", + "Description": null + }, + { + "Subject": "repository", + "Code": "MIT", + "HRef": "git://github.com/dotnet/runtime", + "Description": null + }, + { + "Subject": "project", + "Code": "MIT", + "HRef": "https://github.com/dotnet/runtime", + "Description": null + } + ] +} \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.management/5.0.0/package-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/system.management/5.0.0/package-LICENSE.txt new file mode 100644 index 00000000..984713a4 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.management/5.0.0/package-LICENSE.txt @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) .NET Foundation and Contributors + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Build/third-party-libraries/packages/nuget.org/system.management/5.0.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.management/5.0.0/package.nuspec new file mode 100644 index 00000000..057dca93 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.management/5.0.0/package.nuspec @@ -0,0 +1,42 @@ + + + + System.Management + 5.0.0 + System.Management + Microsoft + microsoft,dotnetframework + false + MIT + https://licenses.nuget.org/MIT + Icon.png + https://github.com/dotnet/runtime + http://go.microsoft.com/fwlink/?LinkID=288859 + Provides access to a rich set of management information and management events about the system, devices, and applications instrumented to the Windows Management Instrumentation (WMI) infrastructure. + +Commonly Used Types: +System.Management.ManagementClass +System.Management.ManagementObject +System.Management.SelectQuery + +When using NuGet 3.x this package requires at least version 3.4. + https://go.microsoft.com/fwlink/?LinkID=799421 + © Microsoft Corporation. All rights reserved. + true + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.management/5.0.0/project-LICENSE.TXT b/Build/third-party-libraries/packages/nuget.org/system.management/5.0.0/project-LICENSE.TXT new file mode 100644 index 00000000..984713a4 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.management/5.0.0/project-LICENSE.TXT @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) .NET Foundation and Contributors + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Build/third-party-libraries/packages/nuget.org/system.management/5.0.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.management/5.0.0/readme.md new file mode 100644 index 00000000..668db812 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.management/5.0.0/readme.md @@ -0,0 +1,38 @@ +System.Management [5.0.0](https://www.nuget.org/packages/System.Management/5.0.0) +-------------------- + +Used by: SqlDatabase internal + +Target frameworks: net472, net5.0, net6.0, net7.0, netcoreapp3.1 + +License: [MIT](../../../../licenses/mit) + +- package license: [MIT](https://licenses.nuget.org/MIT) +- repository license: [MIT](git://github.com/dotnet/runtime) +- project license: [MIT](https://github.com/dotnet/runtime) + +Description +----------- +Provides access to a rich set of management information and management events about the system, devices, and applications instrumented to the Windows Management Instrumentation (WMI) infrastructure. + +Commonly Used Types: +System.Management.ManagementClass +System.Management.ManagementObject +System.Management.SelectQuery + +When using NuGet 3.x this package requires at least version 3.4. + +Remarks +----------- +no remarks + + +Dependencies 2 +----------- + +|Name|Version| +|----------|:----| +|[Microsoft.Win32.Registry](../../../../packages/nuget.org/microsoft.win32.registry/5.0.0)|5.0.0| +|[System.CodeDom](../../../../packages/nuget.org/system.codedom/5.0.0)|5.0.0| + +*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.dynamic.runtime/4.3.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/system.management/5.0.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.dynamic.runtime/4.3.0/remarks.md rename to Build/third-party-libraries/packages/nuget.org/system.management/5.0.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/system.management/5.0.0/repository-LICENSE.TXT b/Build/third-party-libraries/packages/nuget.org/system.management/5.0.0/repository-LICENSE.TXT new file mode 100644 index 00000000..984713a4 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.management/5.0.0/repository-LICENSE.TXT @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) .NET Foundation and Contributors + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Build/third-party-libraries/packages/nuget.org/system.dynamic.runtime/4.3.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/system.management/5.0.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.dynamic.runtime/4.3.0/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/system.management/5.0.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/system.memory/4.5.3/index.json b/Build/third-party-libraries/packages/nuget.org/system.memory/4.5.3/index.json index 65f22a83..45273c52 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.memory/4.5.3/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.memory/4.5.3/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net452", "netstandard2.0" ], diff --git a/Build/third-party-libraries/packages/nuget.org/system.memory/4.5.3/readme.md b/Build/third-party-libraries/packages/nuget.org/system.memory/4.5.3/readme.md index 97cbe0e8..5f16d3a0 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.memory/4.5.3/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.memory/4.5.3/readme.md @@ -3,7 +3,7 @@ System.Memory [4.5.3](https://www.nuget.org/packages/System.Memory/4.5.3) Used by: SqlDatabase -Target frameworks: net452, net5.0, net6.0, netcoreapp3.1, netstandard2.0 +Target frameworks: net452, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/system.memory/4.5.4/index.json b/Build/third-party-libraries/packages/nuget.org/system.memory/4.5.4/index.json index be8da353..490b41df 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.memory/4.5.4/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.memory/4.5.4/index.json @@ -6,12 +6,14 @@ "UsedBy": [ { "Name": "SqlDatabase", - "InternalOnly": true, + "InternalOnly": false, "TargetFrameworks": [ "netcoreapp3.1", "net5.0", "net6.0", - "net472" + "net7.0", + "net452", + "netstandard2.0" ], "Dependencies": [ { @@ -20,11 +22,11 @@ }, { "Name": "System.Numerics.Vectors", - "Version": "4.5.0" + "Version": "4.4.0" }, { "Name": "System.Runtime.CompilerServices.Unsafe", - "Version": "4.5.3" + "Version": "4.7.0" } ] } diff --git a/Build/third-party-libraries/packages/nuget.org/system.memory/4.5.4/readme.md b/Build/third-party-libraries/packages/nuget.org/system.memory/4.5.4/readme.md index 61f509d8..430ba24c 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.memory/4.5.4/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.memory/4.5.4/readme.md @@ -1,9 +1,9 @@ System.Memory [4.5.4](https://www.nuget.org/packages/System.Memory/4.5.4) -------------------- -Used by: SqlDatabase internal +Used by: SqlDatabase -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 +Target frameworks: net452, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 License: [MIT](../../../../licenses/mit) @@ -38,7 +38,7 @@ Dependencies 3 |Name|Version| |----------|:----| |[System.Buffers](../../../../packages/nuget.org/system.buffers/4.5.1)|4.5.1| -|[System.Numerics.Vectors](../../../../packages/nuget.org/system.numerics.vectors/4.5.0)|4.5.0| -|[System.Runtime.CompilerServices.Unsafe](../../../../packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.3)|4.5.3| +|[System.Numerics.Vectors](../../../../packages/nuget.org/system.numerics.vectors/4.4.0)|4.4.0| +|[System.Runtime.CompilerServices.Unsafe](../../../../packages/nuget.org/system.runtime.compilerservices.unsafe/4.7.0)|4.7.0| *This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.4.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.4.0/index.json index a72233ce..79494e46 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.4.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.4.0/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net452", "netstandard2.0" ] diff --git a/Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.4.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.4.0/readme.md index 9b77f8ea..90eaae20 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.4.0/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.4.0/readme.md @@ -3,7 +3,7 @@ System.Numerics.Vectors [4.4.0](https://www.nuget.org/packages/System.Numerics.V Used by: SqlDatabase -Target frameworks: net452, net5.0, net6.0, netcoreapp3.1, netstandard2.0 +Target frameworks: net452, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.5.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.5.0/package.nuspec deleted file mode 100644 index 8c699377..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.5.0/package.nuspec +++ /dev/null @@ -1,56 +0,0 @@ - - - - System.Numerics.Vectors - 4.5.0 - System.Numerics.Vectors - Microsoft - microsoft,dotnetframework - false - https://github.com/dotnet/corefx/blob/master/LICENSE.TXT - https://dot.net/ - http://go.microsoft.com/fwlink/?LinkID=288859 - Provides hardware-accelerated numeric types, suitable for high-performance processing and graphics applications. - -Commonly Used Types: -System.Numerics.Matrix3x2 -System.Numerics.Matrix4x4 -System.Numerics.Plane -System.Numerics.Quaternion -System.Numerics.Vector2 -System.Numerics.Vector3 -System.Numerics.Vector4 -System.Numerics.Vector -System.Numerics.Vector<T> - -30ab651fcb4354552bd4891619a0bdd81e0ebdbf - https://go.microsoft.com/fwlink/?LinkID=799421 - © Microsoft Corporation. All rights reserved. - true - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.5.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.5.0/readme.md deleted file mode 100644 index 00934de0..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.5.0/readme.md +++ /dev/null @@ -1,39 +0,0 @@ -System.Numerics.Vectors [4.5.0](https://www.nuget.org/packages/System.Numerics.Vectors/4.5.0) --------------------- - -Used by: SqlDatabase internal - -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 - -License: [MIT](../../../../licenses/mit) - -- package license: [MIT](https://github.com/dotnet/corefx/blob/master/LICENSE.TXT) -- project license: [Unknown](https://dot.net/) , License should be verified on https://dot.net/ - -Description ------------ -Provides hardware-accelerated numeric types, suitable for high-performance processing and graphics applications. - -Commonly Used Types: -System.Numerics.Matrix3x2 -System.Numerics.Matrix4x4 -System.Numerics.Plane -System.Numerics.Quaternion -System.Numerics.Vector2 -System.Numerics.Vector3 -System.Numerics.Vector4 -System.Numerics.Vector -System.Numerics.Vector - -30ab651fcb4354552bd4891619a0bdd81e0ebdbf - -Remarks ------------ -no remarks - - -Dependencies 0 ------------ - - -*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.objectmodel/4.3.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.objectmodel/4.3.0/index.json deleted file mode 100644 index 330a9b8c..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.objectmodel/4.3.0/index.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "License": { - "Code": "ms-net-library", - "Status": "AutomaticallyApproved" - }, - "UsedBy": [ - { - "Name": "SqlDatabase", - "InternalOnly": true, - "TargetFrameworks": [ - "netcoreapp3.1", - "net5.0", - "net6.0", - "net472" - ], - "Dependencies": [ - { - "Name": "System.Threading", - "Version": "4.3.0" - } - ] - } - ], - "Licenses": [ - { - "Subject": "package", - "Code": "ms-net-library", - "HRef": "http://go.microsoft.com/fwlink/?LinkId=329770", - "Description": null - }, - { - "Subject": "project", - "Code": null, - "HRef": "https://dot.net/", - "Description": "License should be verified on https://dot.net/" - } - ] -} \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.objectmodel/4.3.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.objectmodel/4.3.0/package.nuspec deleted file mode 100644 index f2d50b50..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.objectmodel/4.3.0/package.nuspec +++ /dev/null @@ -1,65 +0,0 @@ - - - - System.ObjectModel - 4.3.0 - System.ObjectModel - Microsoft - microsoft,dotnetframework - true - http://go.microsoft.com/fwlink/?LinkId=329770 - https://dot.net/ - http://go.microsoft.com/fwlink/?LinkID=288859 - Provides types and interfaces that allow the creation of observable types that provide notifications to clients when changes are made to it. - -Commonly Used Types: -System.ComponentModel.INotifyPropertyChanged -System.Collections.ObjectModel.ObservableCollection<T> -System.ComponentModel.PropertyChangedEventHandler -System.Windows.Input.ICommand -System.Collections.Specialized.INotifyCollectionChanged -System.Collections.Specialized.NotifyCollectionChangedEventArgs -System.Collections.Specialized.NotifyCollectionChangedEventHandler -System.Collections.ObjectModel.KeyedCollection<TKey, TItem> -System.ComponentModel.PropertyChangedEventArgs -System.Collections.ObjectModel.ReadOnlyDictionary<TKey, TValue> - -When using NuGet 3.x this package requires at least version 3.4. - https://go.microsoft.com/fwlink/?LinkID=799421 - © Microsoft Corporation. All rights reserved. - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.objectmodel/4.3.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.objectmodel/4.3.0/readme.md deleted file mode 100644 index 253335d3..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.objectmodel/4.3.0/readme.md +++ /dev/null @@ -1,43 +0,0 @@ -System.ObjectModel [4.3.0](https://www.nuget.org/packages/System.ObjectModel/4.3.0) --------------------- - -Used by: SqlDatabase internal - -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 - -License: [ms-net-library](../../../../licenses/ms-net-library) - -- package license: [ms-net-library](http://go.microsoft.com/fwlink/?LinkId=329770) -- project license: [Unknown](https://dot.net/) , License should be verified on https://dot.net/ - -Description ------------ -Provides types and interfaces that allow the creation of observable types that provide notifications to clients when changes are made to it. - -Commonly Used Types: -System.ComponentModel.INotifyPropertyChanged -System.Collections.ObjectModel.ObservableCollection -System.ComponentModel.PropertyChangedEventHandler -System.Windows.Input.ICommand -System.Collections.Specialized.INotifyCollectionChanged -System.Collections.Specialized.NotifyCollectionChangedEventArgs -System.Collections.Specialized.NotifyCollectionChangedEventHandler -System.Collections.ObjectModel.KeyedCollection -System.ComponentModel.PropertyChangedEventArgs -System.Collections.ObjectModel.ReadOnlyDictionary - -When using NuGet 3.x this package requires at least version 3.4. - -Remarks ------------ -no remarks - - -Dependencies 1 ------------ - -|Name|Version| -|----------|:----| -|[System.Threading](../../../../packages/nuget.org/system.threading/4.3.0)|4.3.0| - -*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.reflection.metadata/1.6.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.reflection.metadata/1.6.0/index.json index c19f5aa6..38ac01dc 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.reflection.metadata/1.6.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.reflection.metadata/1.6.0/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net472" ] } diff --git a/Build/third-party-libraries/packages/nuget.org/system.reflection.metadata/1.6.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.reflection.metadata/1.6.0/readme.md index b1ccbbe1..305a9aab 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.reflection.metadata/1.6.0/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.reflection.metadata/1.6.0/readme.md @@ -3,7 +3,7 @@ System.Reflection.Metadata [1.6.0](https://www.nuget.org/packages/System.Reflect Used by: SqlDatabase internal -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 +Target frameworks: net472, net5.0, net6.0, net7.0, netcoreapp3.1 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/system.reflection.typeextensions/4.3.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.reflection.typeextensions/4.3.0/index.json deleted file mode 100644 index e143dd9c..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.reflection.typeextensions/4.3.0/index.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "License": { - "Code": "ms-net-library", - "Status": "AutomaticallyApproved" - }, - "UsedBy": [ - { - "Name": "SqlDatabase", - "InternalOnly": true, - "TargetFrameworks": [ - "netcoreapp3.1", - "net5.0", - "net6.0", - "net472" - ] - } - ], - "Licenses": [ - { - "Subject": "package", - "Code": "ms-net-library", - "HRef": "http://go.microsoft.com/fwlink/?LinkId=329770", - "Description": null - }, - { - "Subject": "project", - "Code": null, - "HRef": "https://dot.net/", - "Description": "License should be verified on https://dot.net/" - } - ] -} \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.reflection.typeextensions/4.3.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.reflection.typeextensions/4.3.0/package.nuspec deleted file mode 100644 index d3513766..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.reflection.typeextensions/4.3.0/package.nuspec +++ /dev/null @@ -1,58 +0,0 @@ - - - - System.Reflection.TypeExtensions - 4.3.0 - System.Reflection.TypeExtensions - Microsoft - microsoft,dotnetframework - true - http://go.microsoft.com/fwlink/?LinkId=329770 - https://dot.net/ - http://go.microsoft.com/fwlink/?LinkID=288859 - Provides extensions methods for System.Type that are designed to be source-compatible with older framework reflection-based APIs. - -Commonly Used Types: -System.Reflection.TypeExtensions -System.Reflection.BindingFlags - -When using NuGet 3.x this package requires at least version 3.4. - https://go.microsoft.com/fwlink/?LinkID=799421 - © Microsoft Corporation. All rights reserved. - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.reflection.typeextensions/4.3.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.reflection.typeextensions/4.3.0/readme.md deleted file mode 100644 index 834d4b4e..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.reflection.typeextensions/4.3.0/readme.md +++ /dev/null @@ -1,32 +0,0 @@ -System.Reflection.TypeExtensions [4.3.0](https://www.nuget.org/packages/System.Reflection.TypeExtensions/4.3.0) --------------------- - -Used by: SqlDatabase internal - -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 - -License: [ms-net-library](../../../../licenses/ms-net-library) - -- package license: [ms-net-library](http://go.microsoft.com/fwlink/?LinkId=329770) -- project license: [Unknown](https://dot.net/) , License should be verified on https://dot.net/ - -Description ------------ -Provides extensions methods for System.Type that are designed to be source-compatible with older framework reflection-based APIs. - -Commonly Used Types: -System.Reflection.TypeExtensions -System.Reflection.BindingFlags - -When using NuGet 3.x this package requires at least version 3.4. - -Remarks ------------ -no remarks - - -Dependencies 0 ------------ - - -*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.2/index.json b/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.2/index.json index a72233ce..79494e46 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.2/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.2/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net452", "netstandard2.0" ] diff --git a/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.2/readme.md b/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.2/readme.md index af0ecc95..90d09d50 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.2/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.2/readme.md @@ -3,7 +3,7 @@ System.Runtime.CompilerServices.Unsafe [4.5.2](https://www.nuget.org/packages/Sy Used by: SqlDatabase -Target frameworks: net452, net5.0, net6.0, netcoreapp3.1, netstandard2.0 +Target frameworks: net452, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.3/index.json b/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.3/index.json index c19f5aa6..38ac01dc 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.3/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.3/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net472" ] } diff --git a/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.3/readme.md b/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.3/readme.md index 87b0d3de..f088c659 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.3/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.3/readme.md @@ -3,7 +3,7 @@ System.Runtime.CompilerServices.Unsafe [4.5.3](https://www.nuget.org/packages/Sy Used by: SqlDatabase internal -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 +Target frameworks: net472, net5.0, net6.0, net7.0, netcoreapp3.1 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.5.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.7.0/index.json similarity index 70% rename from Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.5.0/index.json rename to Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.7.0/index.json index a72233ce..385b2cc1 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.diagnostics.diagnosticsource/4.5.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.7.0/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net452", "netstandard2.0" ] @@ -20,14 +21,14 @@ { "Subject": "package", "Code": "MIT", - "HRef": "https://github.com/dotnet/corefx/blob/master/LICENSE.TXT", + "HRef": "https://licenses.nuget.org/MIT", "Description": null }, { "Subject": "project", "Code": null, - "HRef": "https://dot.net/", - "Description": "License should be verified on https://dot.net/" + "HRef": "https://github.com/dotnet/corefx", + "Description": "License should be verified on https://github.com/dotnet/corefx" } ] } \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.7.0/package-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.7.0/package-LICENSE.txt new file mode 100644 index 00000000..984713a4 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.7.0/package-LICENSE.txt @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) .NET Foundation and Contributors + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.7.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.7.0/package.nuspec new file mode 100644 index 00000000..e3c587dc --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.7.0/package.nuspec @@ -0,0 +1,36 @@ + + + + System.Runtime.CompilerServices.Unsafe + 4.7.0 + System.Runtime.CompilerServices.Unsafe + Microsoft + microsoft,dotnetframework + false + MIT + https://licenses.nuget.org/MIT + https://github.com/dotnet/corefx + http://go.microsoft.com/fwlink/?LinkID=288859 + Provides the System.Runtime.CompilerServices.Unsafe class, which provides generic, low-level functionality for manipulating pointers. + +Commonly Used Types: +System.Runtime.CompilerServices.Unsafe + +When using NuGet 3.x this package requires at least version 3.4. + https://go.microsoft.com/fwlink/?LinkID=799421 + © Microsoft Corporation. All rights reserved. + true + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.7.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.7.0/readme.md new file mode 100644 index 00000000..845ad510 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.7.0/readme.md @@ -0,0 +1,31 @@ +System.Runtime.CompilerServices.Unsafe [4.7.0](https://www.nuget.org/packages/System.Runtime.CompilerServices.Unsafe/4.7.0) +-------------------- + +Used by: SqlDatabase + +Target frameworks: net452, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 + +License: [MIT](../../../../licenses/mit) + +- package license: [MIT](https://licenses.nuget.org/MIT) +- project license: [Unknown](https://github.com/dotnet/corefx) , License should be verified on https://github.com/dotnet/corefx + +Description +----------- +Provides the System.Runtime.CompilerServices.Unsafe class, which provides generic, low-level functionality for manipulating pointers. + +Commonly Used Types: +System.Runtime.CompilerServices.Unsafe + +When using NuGet 3.x this package requires at least version 3.4. + +Remarks +----------- +no remarks + + +Dependencies 0 +----------- + + +*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.io.filesystem.primitives/4.3.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.7.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.io.filesystem.primitives/4.3.0/remarks.md rename to Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.7.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/system.io.filesystem.primitives/4.3.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.7.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.io.filesystem.primitives/4.3.0/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/system.runtime.compilerservices.unsafe/4.7.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/system.runtime.interopservices.runtimeinformation/4.3.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.runtime.interopservices.runtimeinformation/4.3.0/index.json index e143dd9c..167f0424 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.runtime.interopservices.runtimeinformation/4.3.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.runtime.interopservices.runtimeinformation/4.3.0/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net472" ] } diff --git a/Build/third-party-libraries/packages/nuget.org/system.runtime.interopservices.runtimeinformation/4.3.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.runtime.interopservices.runtimeinformation/4.3.0/readme.md index eee36a54..1e34e11e 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.runtime.interopservices.runtimeinformation/4.3.0/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.runtime.interopservices.runtimeinformation/4.3.0/readme.md @@ -3,7 +3,7 @@ System.Runtime.InteropServices.RuntimeInformation [4.3.0](https://www.nuget.org/ Used by: SqlDatabase internal -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 +Target frameworks: net472, net5.0, net6.0, net7.0, netcoreapp3.1 License: [ms-net-library](../../../../licenses/ms-net-library) diff --git a/Build/third-party-libraries/packages/nuget.org/system.runtime.loader/4.3.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.runtime.loader/4.3.0/index.json index 03a47284..a5362ddb 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.runtime.loader/4.3.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.runtime.loader/4.3.0/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net452", "netstandard2.0" ] diff --git a/Build/third-party-libraries/packages/nuget.org/system.runtime.loader/4.3.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.runtime.loader/4.3.0/readme.md index 70fbd084..7a0c1cde 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.runtime.loader/4.3.0/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.runtime.loader/4.3.0/readme.md @@ -3,7 +3,7 @@ System.Runtime.Loader [4.3.0](https://www.nuget.org/packages/System.Runtime.Load Used by: SqlDatabase -Target frameworks: net452, net5.0, net6.0, netcoreapp3.1, netstandard2.0 +Target frameworks: net452, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 License: [ms-net-library](../../../../licenses/ms-net-library) diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.5.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.5.0/remarks.md deleted file mode 100644 index e69de29b..00000000 diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.5.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.5.0/third-party-notices.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.5.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.7.0/index.json similarity index 71% rename from Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.5.0/index.json rename to Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.7.0/index.json index 9efa3cf7..f50d9fc5 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.5.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.7.0/index.json @@ -11,13 +11,14 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net452", "netstandard2.0" ], "Dependencies": [ { "Name": "System.Security.Principal.Windows", - "Version": "4.5.0" + "Version": "4.7.0" } ] } @@ -26,14 +27,14 @@ { "Subject": "package", "Code": "MIT", - "HRef": "https://github.com/dotnet/corefx/blob/master/LICENSE.TXT", + "HRef": "https://licenses.nuget.org/MIT", "Description": null }, { "Subject": "project", "Code": null, - "HRef": "https://dot.net/", - "Description": "License should be verified on https://dot.net/" + "HRef": "https://github.com/dotnet/corefx", + "Description": "License should be verified on https://github.com/dotnet/corefx" } ] } \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.7.0/package-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.7.0/package-LICENSE.txt new file mode 100644 index 00000000..984713a4 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.7.0/package-LICENSE.txt @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) .NET Foundation and Contributors + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.5.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.7.0/package.nuspec similarity index 83% rename from Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.5.0/package.nuspec rename to Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.7.0/package.nuspec index 9e730be6..95ec867c 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.5.0/package.nuspec +++ b/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.7.0/package.nuspec @@ -2,13 +2,14 @@ System.Security.AccessControl - 4.5.0 + 4.7.0 System.Security.AccessControl Microsoft microsoft,dotnetframework false - https://github.com/dotnet/corefx/blob/master/LICENSE.TXT - https://dot.net/ + MIT + https://licenses.nuget.org/MIT + https://github.com/dotnet/corefx http://go.microsoft.com/fwlink/?LinkID=288859 Provides base classes that enable managing access and audit control lists on securable objects. @@ -19,29 +20,28 @@ System.Security.AccessControl.ObjectAccessRule System.Security.AccessControl.ObjectAuditRule System.Security.AccessControl.ObjectSecurity -30ab651fcb4354552bd4891619a0bdd81e0ebdbf When using NuGet 3.x this package requires at least version 3.4. https://go.microsoft.com/fwlink/?LinkID=799421 - © Microsoft Corporation. All rights reserved. + © Microsoft Corporation. All rights reserved. true - + - + - - + + - + - + diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.5.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.7.0/readme.md similarity index 61% rename from Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.5.0/readme.md rename to Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.7.0/readme.md index 26fcf26a..b00cf455 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.5.0/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.7.0/readme.md @@ -1,14 +1,14 @@ -System.Security.AccessControl [4.5.0](https://www.nuget.org/packages/System.Security.AccessControl/4.5.0) +System.Security.AccessControl [4.7.0](https://www.nuget.org/packages/System.Security.AccessControl/4.7.0) -------------------- Used by: SqlDatabase -Target frameworks: net452, net5.0, net6.0, netcoreapp3.1, netstandard2.0 +Target frameworks: net452, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 License: [MIT](../../../../licenses/mit) -- package license: [MIT](https://github.com/dotnet/corefx/blob/master/LICENSE.TXT) -- project license: [Unknown](https://dot.net/) , License should be verified on https://dot.net/ +- package license: [MIT](https://licenses.nuget.org/MIT) +- project license: [Unknown](https://github.com/dotnet/corefx) , License should be verified on https://github.com/dotnet/corefx Description ----------- @@ -21,7 +21,6 @@ System.Security.AccessControl.ObjectAccessRule System.Security.AccessControl.ObjectAuditRule System.Security.AccessControl.ObjectSecurity -30ab651fcb4354552bd4891619a0bdd81e0ebdbf When using NuGet 3.x this package requires at least version 3.4. Remarks @@ -34,6 +33,6 @@ Dependencies 1 |Name|Version| |----------|:----| -|[System.Security.Principal.Windows](../../../../packages/nuget.org/system.security.principal.windows/4.5.0)|4.5.0| +|[System.Security.Principal.Windows](../../../../packages/nuget.org/system.security.principal.windows/4.7.0)|4.7.0| *This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.linq.expressions/4.3.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.7.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.linq.expressions/4.3.0/remarks.md rename to Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.7.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/system.linq.expressions/4.3.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.7.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.linq.expressions/4.3.0/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/4.7.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/5.0.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/5.0.0/index.json new file mode 100644 index 00000000..dd3e3159 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/5.0.0/index.json @@ -0,0 +1,45 @@ +{ + "License": { + "Code": "MIT", + "Status": "AutomaticallyApproved" + }, + "UsedBy": [ + { + "Name": "SqlDatabase", + "InternalOnly": true, + "TargetFrameworks": [ + "netcoreapp3.1", + "net5.0", + "net6.0", + "net7.0", + "net472" + ], + "Dependencies": [ + { + "Name": "System.Security.Principal.Windows", + "Version": "5.0.0" + } + ] + } + ], + "Licenses": [ + { + "Subject": "package", + "Code": "MIT", + "HRef": "https://licenses.nuget.org/MIT", + "Description": null + }, + { + "Subject": "repository", + "Code": "MIT", + "HRef": "git://github.com/dotnet/runtime", + "Description": null + }, + { + "Subject": "project", + "Code": "MIT", + "HRef": "https://github.com/dotnet/runtime", + "Description": null + } + ] +} \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/5.0.0/package-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/5.0.0/package-LICENSE.txt new file mode 100644 index 00000000..984713a4 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/5.0.0/package-LICENSE.txt @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) .NET Foundation and Contributors + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/5.0.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/5.0.0/package.nuspec new file mode 100644 index 00000000..532ae482 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/5.0.0/package.nuspec @@ -0,0 +1,55 @@ + + + + System.Security.AccessControl + 5.0.0 + System.Security.AccessControl + Microsoft + microsoft,dotnetframework + false + MIT + https://licenses.nuget.org/MIT + Icon.png + https://github.com/dotnet/runtime + http://go.microsoft.com/fwlink/?LinkID=288859 + Provides base classes that enable managing access and audit control lists on securable objects. + +Commonly Used Types: +System.Security.AccessControl.AccessRule +System.Security.AccessControl.AuditRule +System.Security.AccessControl.ObjectAccessRule +System.Security.AccessControl.ObjectAuditRule +System.Security.AccessControl.ObjectSecurity + +When using NuGet 3.x this package requires at least version 3.4. + https://go.microsoft.com/fwlink/?LinkID=799421 + © Microsoft Corporation. All rights reserved. + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/5.0.0/project-LICENSE.TXT b/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/5.0.0/project-LICENSE.TXT new file mode 100644 index 00000000..984713a4 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/5.0.0/project-LICENSE.TXT @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) .NET Foundation and Contributors + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/5.0.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/5.0.0/readme.md new file mode 100644 index 00000000..aa1a2b52 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/5.0.0/readme.md @@ -0,0 +1,39 @@ +System.Security.AccessControl [5.0.0](https://www.nuget.org/packages/System.Security.AccessControl/5.0.0) +-------------------- + +Used by: SqlDatabase internal + +Target frameworks: net472, net5.0, net6.0, net7.0, netcoreapp3.1 + +License: [MIT](../../../../licenses/mit) + +- package license: [MIT](https://licenses.nuget.org/MIT) +- repository license: [MIT](git://github.com/dotnet/runtime) +- project license: [MIT](https://github.com/dotnet/runtime) + +Description +----------- +Provides base classes that enable managing access and audit control lists on securable objects. + +Commonly Used Types: +System.Security.AccessControl.AccessRule +System.Security.AccessControl.AuditRule +System.Security.AccessControl.ObjectAccessRule +System.Security.AccessControl.ObjectAuditRule +System.Security.AccessControl.ObjectSecurity + +When using NuGet 3.x this package requires at least version 3.4. + +Remarks +----------- +no remarks + + +Dependencies 1 +----------- + +|Name|Version| +|----------|:----| +|[System.Security.Principal.Windows](../../../../packages/nuget.org/system.security.principal.windows/5.0.0)|5.0.0| + +*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.linq/4.3.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/5.0.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.linq/4.3.0/remarks.md rename to Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/5.0.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/5.0.0/repository-LICENSE.TXT b/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/5.0.0/repository-LICENSE.TXT new file mode 100644 index 00000000..984713a4 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/5.0.0/repository-LICENSE.TXT @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) .NET Foundation and Contributors + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Build/third-party-libraries/packages/nuget.org/system.linq/4.3.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/5.0.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.linq/4.3.0/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/system.security.accesscontrol/5.0.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.cryptography.protecteddata/4.5.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.security.cryptography.protecteddata/4.5.0/index.json index a72233ce..79494e46 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.security.cryptography.protecteddata/4.5.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.security.cryptography.protecteddata/4.5.0/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net452", "netstandard2.0" ] diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.cryptography.protecteddata/4.5.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.security.cryptography.protecteddata/4.5.0/readme.md index bb0ce692..1f0968e5 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.security.cryptography.protecteddata/4.5.0/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.security.cryptography.protecteddata/4.5.0/readme.md @@ -3,7 +3,7 @@ System.Security.Cryptography.ProtectedData [4.5.0](https://www.nuget.org/package Used by: SqlDatabase -Target frameworks: net452, net5.0, net6.0, netcoreapp3.1, netstandard2.0 +Target frameworks: net452, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.permissions/4.5.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.security.permissions/4.5.0/index.json index 87eeb6c2..faff1fec 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.security.permissions/4.5.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.security.permissions/4.5.0/index.json @@ -11,13 +11,14 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net452", "netstandard2.0" ], "Dependencies": [ { "Name": "System.Security.AccessControl", - "Version": "4.5.0" + "Version": "4.7.0" } ] } diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.permissions/4.5.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.security.permissions/4.5.0/readme.md index cd35829f..6d0b5d57 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.security.permissions/4.5.0/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.security.permissions/4.5.0/readme.md @@ -3,7 +3,7 @@ System.Security.Permissions [4.5.0](https://www.nuget.org/packages/System.Securi Used by: SqlDatabase -Target frameworks: net452, net5.0, net6.0, netcoreapp3.1, netstandard2.0 +Target frameworks: net452, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 License: [MIT](../../../../licenses/mit) @@ -26,6 +26,6 @@ Dependencies 1 |Name|Version| |----------|:----| -|[System.Security.AccessControl](../../../../packages/nuget.org/system.security.accesscontrol/4.5.0)|4.5.0| +|[System.Security.AccessControl](../../../../packages/nuget.org/system.security.accesscontrol/4.7.0)|4.7.0| *This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.5.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.5.0/remarks.md deleted file mode 100644 index e69de29b..00000000 diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.5.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.5.0/third-party-notices.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.5.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.7.0/index.json similarity index 70% rename from Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.5.0/index.json rename to Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.7.0/index.json index a72233ce..385b2cc1 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.5.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.7.0/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net452", "netstandard2.0" ] @@ -20,14 +21,14 @@ { "Subject": "package", "Code": "MIT", - "HRef": "https://github.com/dotnet/corefx/blob/master/LICENSE.TXT", + "HRef": "https://licenses.nuget.org/MIT", "Description": null }, { "Subject": "project", "Code": null, - "HRef": "https://dot.net/", - "Description": "License should be verified on https://dot.net/" + "HRef": "https://github.com/dotnet/corefx", + "Description": "License should be verified on https://github.com/dotnet/corefx" } ] } \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.7.0/package-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.7.0/package-LICENSE.txt new file mode 100644 index 00000000..984713a4 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.7.0/package-LICENSE.txt @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) .NET Foundation and Contributors + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.5.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.7.0/package.nuspec similarity index 85% rename from Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.5.0/package.nuspec rename to Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.7.0/package.nuspec index 7f32f6d7..fe9db1e5 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.5.0/package.nuspec +++ b/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.7.0/package.nuspec @@ -2,13 +2,14 @@ System.Security.Principal.Windows - 4.5.0 + 4.7.0 System.Security.Principal.Windows Microsoft microsoft,dotnetframework false - https://github.com/dotnet/corefx/blob/master/LICENSE.TXT - https://dot.net/ + MIT + https://licenses.nuget.org/MIT + https://github.com/dotnet/corefx http://go.microsoft.com/fwlink/?LinkID=288859 Provides classes for retrieving the current Windows user and for interacting with Windows users and groups. @@ -22,10 +23,9 @@ System.Security.Principal.IdentityNotMappedException System.Security.Principal.WindowsBuiltInRole System.Security.Principal.WellKnownSidType -30ab651fcb4354552bd4891619a0bdd81e0ebdbf When using NuGet 3.x this package requires at least version 3.4. https://go.microsoft.com/fwlink/?LinkID=799421 - © Microsoft Corporation. All rights reserved. + © Microsoft Corporation. All rights reserved. true @@ -33,8 +33,12 @@ When using NuGet 3.x this package requires at least version 3.4. - + + + + + diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.5.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.7.0/readme.md similarity index 65% rename from Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.5.0/readme.md rename to Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.7.0/readme.md index 79c80ff4..4c4644fa 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.5.0/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.7.0/readme.md @@ -1,14 +1,14 @@ -System.Security.Principal.Windows [4.5.0](https://www.nuget.org/packages/System.Security.Principal.Windows/4.5.0) +System.Security.Principal.Windows [4.7.0](https://www.nuget.org/packages/System.Security.Principal.Windows/4.7.0) -------------------- Used by: SqlDatabase -Target frameworks: net452, net5.0, net6.0, netcoreapp3.1, netstandard2.0 +Target frameworks: net452, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 License: [MIT](../../../../licenses/mit) -- package license: [MIT](https://github.com/dotnet/corefx/blob/master/LICENSE.TXT) -- project license: [Unknown](https://dot.net/) , License should be verified on https://dot.net/ +- package license: [MIT](https://licenses.nuget.org/MIT) +- project license: [Unknown](https://github.com/dotnet/corefx) , License should be verified on https://github.com/dotnet/corefx Description ----------- @@ -24,7 +24,6 @@ System.Security.Principal.IdentityNotMappedException System.Security.Principal.WindowsBuiltInRole System.Security.Principal.WellKnownSidType -30ab651fcb4354552bd4891619a0bdd81e0ebdbf When using NuGet 3.x this package requires at least version 3.4. Remarks diff --git a/Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.5.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.7.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.5.0/remarks.md rename to Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.7.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.5.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.7.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.numerics.vectors/4.5.0/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/4.7.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/5.0.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/5.0.0/index.json new file mode 100644 index 00000000..cf67483a --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/5.0.0/index.json @@ -0,0 +1,39 @@ +{ + "License": { + "Code": "MIT", + "Status": "AutomaticallyApproved" + }, + "UsedBy": [ + { + "Name": "SqlDatabase", + "InternalOnly": true, + "TargetFrameworks": [ + "netcoreapp3.1", + "net5.0", + "net6.0", + "net7.0", + "net472" + ] + } + ], + "Licenses": [ + { + "Subject": "package", + "Code": "MIT", + "HRef": "https://licenses.nuget.org/MIT", + "Description": null + }, + { + "Subject": "repository", + "Code": "MIT", + "HRef": "git://github.com/dotnet/runtime", + "Description": null + }, + { + "Subject": "project", + "Code": "MIT", + "HRef": "https://github.com/dotnet/runtime", + "Description": null + } + ] +} \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/5.0.0/package-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/5.0.0/package-LICENSE.txt new file mode 100644 index 00000000..984713a4 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/5.0.0/package-LICENSE.txt @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) .NET Foundation and Contributors + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/5.0.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/5.0.0/package.nuspec new file mode 100644 index 00000000..a1ff48c6 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/5.0.0/package.nuspec @@ -0,0 +1,68 @@ + + + + System.Security.Principal.Windows + 5.0.0 + System.Security.Principal.Windows + Microsoft + microsoft,dotnetframework + false + MIT + https://licenses.nuget.org/MIT + Icon.png + https://github.com/dotnet/runtime + http://go.microsoft.com/fwlink/?LinkID=288859 + Provides classes for retrieving the current Windows user and for interacting with Windows users and groups. + +Commonly Used Types: +System.Security.Principal.WindowsIdentity +System.Security.Principal.SecurityIdentifier +System.Security.Principal.NTAccount +System.Security.Principal.WindowsPrincipal +System.Security.Principal.IdentityReference +System.Security.Principal.IdentityNotMappedException +System.Security.Principal.WindowsBuiltInRole +System.Security.Principal.WellKnownSidType + +When using NuGet 3.x this package requires at least version 3.4. + https://go.microsoft.com/fwlink/?LinkID=799421 + © Microsoft Corporation. All rights reserved. + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/5.0.0/project-LICENSE.TXT b/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/5.0.0/project-LICENSE.TXT new file mode 100644 index 00000000..984713a4 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/5.0.0/project-LICENSE.TXT @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) .NET Foundation and Contributors + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/5.0.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/5.0.0/readme.md new file mode 100644 index 00000000..822481c5 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/5.0.0/readme.md @@ -0,0 +1,39 @@ +System.Security.Principal.Windows [5.0.0](https://www.nuget.org/packages/System.Security.Principal.Windows/5.0.0) +-------------------- + +Used by: SqlDatabase internal + +Target frameworks: net472, net5.0, net6.0, net7.0, netcoreapp3.1 + +License: [MIT](../../../../licenses/mit) + +- package license: [MIT](https://licenses.nuget.org/MIT) +- repository license: [MIT](git://github.com/dotnet/runtime) +- project license: [MIT](https://github.com/dotnet/runtime) + +Description +----------- +Provides classes for retrieving the current Windows user and for interacting with Windows users and groups. + +Commonly Used Types: +System.Security.Principal.WindowsIdentity +System.Security.Principal.SecurityIdentifier +System.Security.Principal.NTAccount +System.Security.Principal.WindowsPrincipal +System.Security.Principal.IdentityReference +System.Security.Principal.IdentityNotMappedException +System.Security.Principal.WindowsBuiltInRole +System.Security.Principal.WellKnownSidType + +When using NuGet 3.x this package requires at least version 3.4. + +Remarks +----------- +no remarks + + +Dependencies 0 +----------- + + +*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.objectmodel/4.3.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/5.0.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.objectmodel/4.3.0/remarks.md rename to Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/5.0.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/5.0.0/repository-LICENSE.TXT b/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/5.0.0/repository-LICENSE.TXT new file mode 100644 index 00000000..984713a4 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/5.0.0/repository-LICENSE.TXT @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) .NET Foundation and Contributors + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Build/third-party-libraries/packages/nuget.org/system.objectmodel/4.3.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/5.0.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.objectmodel/4.3.0/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/system.security.principal.windows/5.0.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.5.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.5.0/remarks.md deleted file mode 100644 index e69de29b..00000000 diff --git a/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.5.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.5.0/third-party-notices.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.5.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.7.0/index.json similarity index 71% rename from Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.5.0/index.json rename to Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.7.0/index.json index 62f000b1..4b2f1050 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.5.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.7.0/index.json @@ -11,13 +11,14 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net452", "netstandard2.0" ], "Dependencies": [ { "Name": "System.Runtime.CompilerServices.Unsafe", - "Version": "4.5.2" + "Version": "4.7.0" } ] } @@ -26,14 +27,14 @@ { "Subject": "package", "Code": "MIT", - "HRef": "https://github.com/dotnet/corefx/blob/master/LICENSE.TXT", + "HRef": "https://licenses.nuget.org/MIT", "Description": null }, { "Subject": "project", "Code": null, - "HRef": "https://dot.net/", - "Description": "License should be verified on https://dot.net/" + "HRef": "https://github.com/dotnet/corefx", + "Description": "License should be verified on https://github.com/dotnet/corefx" } ] } \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.7.0/package-LICENSE.txt b/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.7.0/package-LICENSE.txt new file mode 100644 index 00000000..984713a4 --- /dev/null +++ b/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.7.0/package-LICENSE.txt @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) .NET Foundation and Contributors + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.5.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.7.0/package.nuspec similarity index 76% rename from Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.5.0/package.nuspec rename to Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.7.0/package.nuspec index 3fe8aae9..4bc0ae54 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.5.0/package.nuspec +++ b/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.7.0/package.nuspec @@ -2,42 +2,44 @@ System.Text.Encoding.CodePages - 4.5.0 + 4.7.0 System.Text.Encoding.CodePages Microsoft microsoft,dotnetframework false - https://github.com/dotnet/corefx/blob/master/LICENSE.TXT - https://dot.net/ + MIT + https://licenses.nuget.org/MIT + https://github.com/dotnet/corefx http://go.microsoft.com/fwlink/?LinkID=288859 Provides support for code-page based encodings, including Windows-1252, Shift-JIS, and GB2312. Commonly Used Types: System.Text.CodePagesEncodingProvider -30ab651fcb4354552bd4891619a0bdd81e0ebdbf When using NuGet 3.x this package requires at least version 3.4. https://go.microsoft.com/fwlink/?LinkID=799421 - © Microsoft Corporation. All rights reserved. + © Microsoft Corporation. All rights reserved. true - + - - + + + + + - + - diff --git a/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.5.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.7.0/readme.md similarity index 53% rename from Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.5.0/readme.md rename to Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.7.0/readme.md index 54380aba..018b3667 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.5.0/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.7.0/readme.md @@ -1,14 +1,14 @@ -System.Text.Encoding.CodePages [4.5.0](https://www.nuget.org/packages/System.Text.Encoding.CodePages/4.5.0) +System.Text.Encoding.CodePages [4.7.0](https://www.nuget.org/packages/System.Text.Encoding.CodePages/4.7.0) -------------------- Used by: SqlDatabase -Target frameworks: net452, net5.0, net6.0, netcoreapp3.1, netstandard2.0 +Target frameworks: net452, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 License: [MIT](../../../../licenses/mit) -- package license: [MIT](https://github.com/dotnet/corefx/blob/master/LICENSE.TXT) -- project license: [Unknown](https://dot.net/) , License should be verified on https://dot.net/ +- package license: [MIT](https://licenses.nuget.org/MIT) +- project license: [Unknown](https://github.com/dotnet/corefx) , License should be verified on https://github.com/dotnet/corefx Description ----------- @@ -17,7 +17,6 @@ Provides support for code-page based encodings, including Windows-1252, Shift-JI Commonly Used Types: System.Text.CodePagesEncodingProvider -30ab651fcb4354552bd4891619a0bdd81e0ebdbf When using NuGet 3.x this package requires at least version 3.4. Remarks @@ -30,6 +29,6 @@ Dependencies 1 |Name|Version| |----------|:----| -|[System.Runtime.CompilerServices.Unsafe](../../../../packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.2)|4.5.2| +|[System.Runtime.CompilerServices.Unsafe](../../../../packages/nuget.org/system.runtime.compilerservices.unsafe/4.7.0)|4.7.0| *This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.reflection.typeextensions/4.3.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.7.0/remarks.md similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.reflection.typeextensions/4.3.0/remarks.md rename to Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.7.0/remarks.md diff --git a/Build/third-party-libraries/packages/nuget.org/system.reflection.typeextensions/4.3.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.7.0/third-party-notices.txt similarity index 100% rename from Build/third-party-libraries/packages/nuget.org/system.reflection.typeextensions/4.3.0/third-party-notices.txt rename to Build/third-party-libraries/packages/nuget.org/system.text.encoding.codepages/4.7.0/third-party-notices.txt diff --git a/Build/third-party-libraries/packages/nuget.org/system.text.regularexpressions/4.3.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.text.regularexpressions/4.3.0/index.json deleted file mode 100644 index e143dd9c..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.text.regularexpressions/4.3.0/index.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "License": { - "Code": "ms-net-library", - "Status": "AutomaticallyApproved" - }, - "UsedBy": [ - { - "Name": "SqlDatabase", - "InternalOnly": true, - "TargetFrameworks": [ - "netcoreapp3.1", - "net5.0", - "net6.0", - "net472" - ] - } - ], - "Licenses": [ - { - "Subject": "package", - "Code": "ms-net-library", - "HRef": "http://go.microsoft.com/fwlink/?LinkId=329770", - "Description": null - }, - { - "Subject": "project", - "Code": null, - "HRef": "https://dot.net/", - "Description": "License should be verified on https://dot.net/" - } - ] -} \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.text.regularexpressions/4.3.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.text.regularexpressions/4.3.0/package.nuspec deleted file mode 100644 index a751ea35..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.text.regularexpressions/4.3.0/package.nuspec +++ /dev/null @@ -1,72 +0,0 @@ - - - - System.Text.RegularExpressions - 4.3.0 - System.Text.RegularExpressions - Microsoft - microsoft,dotnetframework - true - http://go.microsoft.com/fwlink/?LinkId=329770 - https://dot.net/ - http://go.microsoft.com/fwlink/?LinkID=288859 - Provides the System.Text.RegularExpressions.Regex class, an implementation of a regular expression engine. - -Commonly Used Types: -System.Text.RegularExpressions.Regex -System.Text.RegularExpressions.RegexOptions -System.Text.RegularExpressions.Match -System.Text.RegularExpressions.Group -System.Text.RegularExpressions.Capture -System.Text.RegularExpressions.MatchEvaluator - -When using NuGet 3.x this package requires at least version 3.4. - https://go.microsoft.com/fwlink/?LinkID=799421 - © Microsoft Corporation. All rights reserved. - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.text.regularexpressions/4.3.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.text.regularexpressions/4.3.0/readme.md deleted file mode 100644 index 43891bfe..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.text.regularexpressions/4.3.0/readme.md +++ /dev/null @@ -1,36 +0,0 @@ -System.Text.RegularExpressions [4.3.0](https://www.nuget.org/packages/System.Text.RegularExpressions/4.3.0) --------------------- - -Used by: SqlDatabase internal - -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 - -License: [ms-net-library](../../../../licenses/ms-net-library) - -- package license: [ms-net-library](http://go.microsoft.com/fwlink/?LinkId=329770) -- project license: [Unknown](https://dot.net/) , License should be verified on https://dot.net/ - -Description ------------ -Provides the System.Text.RegularExpressions.Regex class, an implementation of a regular expression engine. - -Commonly Used Types: -System.Text.RegularExpressions.Regex -System.Text.RegularExpressions.RegexOptions -System.Text.RegularExpressions.Match -System.Text.RegularExpressions.Group -System.Text.RegularExpressions.Capture -System.Text.RegularExpressions.MatchEvaluator - -When using NuGet 3.x this package requires at least version 3.4. - -Remarks ------------ -no remarks - - -Dependencies 0 ------------ - - -*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.text.regularexpressions/4.3.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/system.text.regularexpressions/4.3.0/remarks.md deleted file mode 100644 index e69de29b..00000000 diff --git a/Build/third-party-libraries/packages/nuget.org/system.text.regularexpressions/4.3.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/system.text.regularexpressions/4.3.0/third-party-notices.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/Build/third-party-libraries/packages/nuget.org/system.threading.tasks.extensions/4.5.2/index.json b/Build/third-party-libraries/packages/nuget.org/system.threading.tasks.extensions/4.5.2/index.json index 62f000b1..ff360d3b 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.threading.tasks.extensions/4.5.2/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.threading.tasks.extensions/4.5.2/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net452", "netstandard2.0" ], diff --git a/Build/third-party-libraries/packages/nuget.org/system.threading.tasks.extensions/4.5.2/readme.md b/Build/third-party-libraries/packages/nuget.org/system.threading.tasks.extensions/4.5.2/readme.md index 58732516..aa5792bd 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.threading.tasks.extensions/4.5.2/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.threading.tasks.extensions/4.5.2/readme.md @@ -3,7 +3,7 @@ System.Threading.Tasks.Extensions [4.5.2](https://www.nuget.org/packages/System. Used by: SqlDatabase -Target frameworks: net452, net5.0, net6.0, netcoreapp3.1, netstandard2.0 +Target frameworks: net452, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/system.threading.tasks.extensions/4.5.4/index.json b/Build/third-party-libraries/packages/nuget.org/system.threading.tasks.extensions/4.5.4/index.json index 0a588a92..07520a84 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.threading.tasks.extensions/4.5.4/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.threading.tasks.extensions/4.5.4/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net472" ], "Dependencies": [ diff --git a/Build/third-party-libraries/packages/nuget.org/system.threading.tasks.extensions/4.5.4/readme.md b/Build/third-party-libraries/packages/nuget.org/system.threading.tasks.extensions/4.5.4/readme.md index 83dddd45..05629083 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.threading.tasks.extensions/4.5.4/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.threading.tasks.extensions/4.5.4/readme.md @@ -3,7 +3,7 @@ System.Threading.Tasks.Extensions [4.5.4](https://www.nuget.org/packages/System. Used by: SqlDatabase internal -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 +Target frameworks: net472, net5.0, net6.0, net7.0, netcoreapp3.1 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/system.threading/4.3.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.threading/4.3.0/index.json deleted file mode 100644 index e143dd9c..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.threading/4.3.0/index.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "License": { - "Code": "ms-net-library", - "Status": "AutomaticallyApproved" - }, - "UsedBy": [ - { - "Name": "SqlDatabase", - "InternalOnly": true, - "TargetFrameworks": [ - "netcoreapp3.1", - "net5.0", - "net6.0", - "net472" - ] - } - ], - "Licenses": [ - { - "Subject": "package", - "Code": "ms-net-library", - "HRef": "http://go.microsoft.com/fwlink/?LinkId=329770", - "Description": null - }, - { - "Subject": "project", - "Code": null, - "HRef": "https://dot.net/", - "Description": "License should be verified on https://dot.net/" - } - ] -} \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.threading/4.3.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.threading/4.3.0/package.nuspec deleted file mode 100644 index 0f975c95..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.threading/4.3.0/package.nuspec +++ /dev/null @@ -1,59 +0,0 @@ - - - - System.Threading - 4.3.0 - System.Threading - Microsoft - microsoft,dotnetframework - true - http://go.microsoft.com/fwlink/?LinkId=329770 - https://dot.net/ - http://go.microsoft.com/fwlink/?LinkID=288859 - Provides the fundamental synchronization primitives, including System.Threading.Monitor and System.Threading.Mutex, that are required when writing asynchronous code. - -Commonly Used Types: -System.Threading.Monitor -System.Threading.SynchronizationContext -System.Threading.ManualResetEvent -System.Threading.AutoResetEvent -System.Threading.ThreadLocal<T> -System.Threading.EventWaitHandle -System.Threading.SemaphoreSlim -System.Threading.Mutex - -When using NuGet 3.x this package requires at least version 3.4. - https://go.microsoft.com/fwlink/?LinkID=799421 - © Microsoft Corporation. All rights reserved. - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.threading/4.3.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.threading/4.3.0/readme.md deleted file mode 100644 index d8f2511f..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.threading/4.3.0/readme.md +++ /dev/null @@ -1,38 +0,0 @@ -System.Threading [4.3.0](https://www.nuget.org/packages/System.Threading/4.3.0) --------------------- - -Used by: SqlDatabase internal - -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 - -License: [ms-net-library](../../../../licenses/ms-net-library) - -- package license: [ms-net-library](http://go.microsoft.com/fwlink/?LinkId=329770) -- project license: [Unknown](https://dot.net/) , License should be verified on https://dot.net/ - -Description ------------ -Provides the fundamental synchronization primitives, including System.Threading.Monitor and System.Threading.Mutex, that are required when writing asynchronous code. - -Commonly Used Types: -System.Threading.Monitor -System.Threading.SynchronizationContext -System.Threading.ManualResetEvent -System.Threading.AutoResetEvent -System.Threading.ThreadLocal -System.Threading.EventWaitHandle -System.Threading.SemaphoreSlim -System.Threading.Mutex - -When using NuGet 3.x this package requires at least version 3.4. - -Remarks ------------ -no remarks - - -Dependencies 0 ------------ - - -*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.threading/4.3.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/system.threading/4.3.0/remarks.md deleted file mode 100644 index e69de29b..00000000 diff --git a/Build/third-party-libraries/packages/nuget.org/system.threading/4.3.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/system.threading/4.3.0/third-party-notices.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/Build/third-party-libraries/packages/nuget.org/system.valuetuple/4.5.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.valuetuple/4.5.0/index.json index a72233ce..79494e46 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.valuetuple/4.5.0/index.json +++ b/Build/third-party-libraries/packages/nuget.org/system.valuetuple/4.5.0/index.json @@ -11,6 +11,7 @@ "netcoreapp3.1", "net5.0", "net6.0", + "net7.0", "net452", "netstandard2.0" ] diff --git a/Build/third-party-libraries/packages/nuget.org/system.valuetuple/4.5.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.valuetuple/4.5.0/readme.md index 63cfdcd4..b989e0ee 100644 --- a/Build/third-party-libraries/packages/nuget.org/system.valuetuple/4.5.0/readme.md +++ b/Build/third-party-libraries/packages/nuget.org/system.valuetuple/4.5.0/readme.md @@ -3,7 +3,7 @@ System.ValueTuple [4.5.0](https://www.nuget.org/packages/System.ValueTuple/4.5.0 Used by: SqlDatabase -Target frameworks: net452, net5.0, net6.0, netcoreapp3.1, netstandard2.0 +Target frameworks: net452, net5.0, net6.0, net7.0, netcoreapp3.1, netstandard2.0 License: [MIT](../../../../licenses/mit) diff --git a/Build/third-party-libraries/packages/nuget.org/system.xml.readerwriter/4.3.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.xml.readerwriter/4.3.0/index.json deleted file mode 100644 index f12e98c2..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.xml.readerwriter/4.3.0/index.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "License": { - "Code": "ms-net-library", - "Status": "AutomaticallyApproved" - }, - "UsedBy": [ - { - "Name": "SqlDatabase", - "InternalOnly": true, - "TargetFrameworks": [ - "netcoreapp3.1", - "net5.0", - "net6.0", - "net472" - ], - "Dependencies": [ - { - "Name": "System.IO.FileSystem.Primitives", - "Version": "4.3.0" - }, - { - "Name": "System.Text.RegularExpressions", - "Version": "4.3.0" - } - ] - } - ], - "Licenses": [ - { - "Subject": "package", - "Code": "ms-net-library", - "HRef": "http://go.microsoft.com/fwlink/?LinkId=329770", - "Description": null - }, - { - "Subject": "project", - "Code": null, - "HRef": "https://dot.net/", - "Description": "License should be verified on https://dot.net/" - } - ] -} \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.xml.readerwriter/4.3.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.xml.readerwriter/4.3.0/package.nuspec deleted file mode 100644 index 3a7d6d6a..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.xml.readerwriter/4.3.0/package.nuspec +++ /dev/null @@ -1,90 +0,0 @@ - - - - System.Xml.ReaderWriter - 4.3.0 - System.Xml.ReaderWriter - Microsoft - microsoft,dotnetframework - true - http://go.microsoft.com/fwlink/?LinkId=329770 - https://dot.net/ - http://go.microsoft.com/fwlink/?LinkID=288859 - Provides provides a fast, non-cached, forward-only way to read and write Extensible Markup Language (XML) data. - -Commonly Used Types: -System.Xml.XmlNodeType -System.Xml.XmlException -System.Xml.XmlReader -System.Xml.XmlWriter -System.Xml.IXmlLineInfo -System.Xml.XmlNameTable -System.Xml.IXmlNamespaceResolver -System.Xml.XmlNamespaceManager -System.Xml.XmlQualifiedName - -When using NuGet 3.x this package requires at least version 3.4. - https://go.microsoft.com/fwlink/?LinkID=799421 - © Microsoft Corporation. All rights reserved. - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.xml.readerwriter/4.3.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.xml.readerwriter/4.3.0/readme.md deleted file mode 100644 index 85fb4c8e..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.xml.readerwriter/4.3.0/readme.md +++ /dev/null @@ -1,43 +0,0 @@ -System.Xml.ReaderWriter [4.3.0](https://www.nuget.org/packages/System.Xml.ReaderWriter/4.3.0) --------------------- - -Used by: SqlDatabase internal - -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 - -License: [ms-net-library](../../../../licenses/ms-net-library) - -- package license: [ms-net-library](http://go.microsoft.com/fwlink/?LinkId=329770) -- project license: [Unknown](https://dot.net/) , License should be verified on https://dot.net/ - -Description ------------ -Provides provides a fast, non-cached, forward-only way to read and write Extensible Markup Language (XML) data. - -Commonly Used Types: -System.Xml.XmlNodeType -System.Xml.XmlException -System.Xml.XmlReader -System.Xml.XmlWriter -System.Xml.IXmlLineInfo -System.Xml.XmlNameTable -System.Xml.IXmlNamespaceResolver -System.Xml.XmlNamespaceManager -System.Xml.XmlQualifiedName - -When using NuGet 3.x this package requires at least version 3.4. - -Remarks ------------ -no remarks - - -Dependencies 2 ------------ - -|Name|Version| -|----------|:----| -|[System.IO.FileSystem.Primitives](../../../../packages/nuget.org/system.io.filesystem.primitives/4.3.0)|4.3.0| -|[System.Text.RegularExpressions](../../../../packages/nuget.org/system.text.regularexpressions/4.3.0)|4.3.0| - -*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.xml.readerwriter/4.3.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/system.xml.readerwriter/4.3.0/remarks.md deleted file mode 100644 index e69de29b..00000000 diff --git a/Build/third-party-libraries/packages/nuget.org/system.xml.readerwriter/4.3.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/system.xml.readerwriter/4.3.0/third-party-notices.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/Build/third-party-libraries/packages/nuget.org/system.xml.xmldocument/4.3.0/index.json b/Build/third-party-libraries/packages/nuget.org/system.xml.xmldocument/4.3.0/index.json deleted file mode 100644 index 7366d71d..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.xml.xmldocument/4.3.0/index.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "License": { - "Code": "ms-net-library", - "Status": "AutomaticallyApproved" - }, - "UsedBy": [ - { - "Name": "SqlDatabase", - "InternalOnly": true, - "TargetFrameworks": [ - "netcoreapp3.1", - "net5.0", - "net6.0", - "net472" - ], - "Dependencies": [ - { - "Name": "System.Threading", - "Version": "4.3.0" - }, - { - "Name": "System.Xml.ReaderWriter", - "Version": "4.3.0" - } - ] - } - ], - "Licenses": [ - { - "Subject": "package", - "Code": "ms-net-library", - "HRef": "http://go.microsoft.com/fwlink/?LinkId=329770", - "Description": null - }, - { - "Subject": "project", - "Code": null, - "HRef": "https://dot.net/", - "Description": "License should be verified on https://dot.net/" - } - ] -} \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.xml.xmldocument/4.3.0/package.nuspec b/Build/third-party-libraries/packages/nuget.org/system.xml.xmldocument/4.3.0/package.nuspec deleted file mode 100644 index 224b4f2e..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.xml.xmldocument/4.3.0/package.nuspec +++ /dev/null @@ -1,57 +0,0 @@ - - - - System.Xml.XmlDocument - 4.3.0 - System.Xml.XmlDocument - Microsoft - microsoft,dotnetframework - true - http://go.microsoft.com/fwlink/?LinkId=329770 - https://dot.net/ - http://go.microsoft.com/fwlink/?LinkID=288859 - Provides an older in-memory Extensible Markup Language (XML) programming interface that enables you to modify XML documents. Developers should prefer the classes in the System.Xml.XDocument package. - -Commonly Used Types: -System.Xml.XmlNode -System.Xml.XmlElement -System.Xml.XmlAttribute -System.Xml.XmlDocument -System.Xml.XmlDeclaration -System.Xml.XmlText -System.Xml.XmlComment -System.Xml.XmlNodeList -System.Xml.XmlWhitespace -System.Xml.XmlCDataSection - -When using NuGet 3.x this package requires at least version 3.4. - https://go.microsoft.com/fwlink/?LinkID=799421 - © Microsoft Corporation. All rights reserved. - true - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.xml.xmldocument/4.3.0/readme.md b/Build/third-party-libraries/packages/nuget.org/system.xml.xmldocument/4.3.0/readme.md deleted file mode 100644 index eee2cef1..00000000 --- a/Build/third-party-libraries/packages/nuget.org/system.xml.xmldocument/4.3.0/readme.md +++ /dev/null @@ -1,44 +0,0 @@ -System.Xml.XmlDocument [4.3.0](https://www.nuget.org/packages/System.Xml.XmlDocument/4.3.0) --------------------- - -Used by: SqlDatabase internal - -Target frameworks: net472, net5.0, net6.0, netcoreapp3.1 - -License: [ms-net-library](../../../../licenses/ms-net-library) - -- package license: [ms-net-library](http://go.microsoft.com/fwlink/?LinkId=329770) -- project license: [Unknown](https://dot.net/) , License should be verified on https://dot.net/ - -Description ------------ -Provides an older in-memory Extensible Markup Language (XML) programming interface that enables you to modify XML documents. Developers should prefer the classes in the System.Xml.XDocument package. - -Commonly Used Types: -System.Xml.XmlNode -System.Xml.XmlElement -System.Xml.XmlAttribute -System.Xml.XmlDocument -System.Xml.XmlDeclaration -System.Xml.XmlText -System.Xml.XmlComment -System.Xml.XmlNodeList -System.Xml.XmlWhitespace -System.Xml.XmlCDataSection - -When using NuGet 3.x this package requires at least version 3.4. - -Remarks ------------ -no remarks - - -Dependencies 2 ------------ - -|Name|Version| -|----------|:----| -|[System.Threading](../../../../packages/nuget.org/system.threading/4.3.0)|4.3.0| -|[System.Xml.ReaderWriter](../../../../packages/nuget.org/system.xml.readerwriter/4.3.0)|4.3.0| - -*This page was generated by a tool.* \ No newline at end of file diff --git a/Build/third-party-libraries/packages/nuget.org/system.xml.xmldocument/4.3.0/remarks.md b/Build/third-party-libraries/packages/nuget.org/system.xml.xmldocument/4.3.0/remarks.md deleted file mode 100644 index e69de29b..00000000 diff --git a/Build/third-party-libraries/packages/nuget.org/system.xml.xmldocument/4.3.0/third-party-notices.txt b/Build/third-party-libraries/packages/nuget.org/system.xml.xmldocument/4.3.0/third-party-notices.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/Build/third-party-libraries/readme.md b/Build/third-party-libraries/readme.md index ecf5a807..158778a0 100644 --- a/Build/third-party-libraries/readme.md +++ b/Build/third-party-libraries/readme.md @@ -6,76 +6,69 @@ Licenses |[Apache-2.0](licenses/apache-2.0)|no|no|3| |[BSD-2-Clause](licenses/bsd-2-clause)|no|no|1| |[BSD-3-Clause](licenses/bsd-3-clause)|no|no|1| -|[MIT](licenses/mit)|no|no|37| -|[ms-net-library](licenses/ms-net-library)|no|no|17| +|[MIT](licenses/mit)|no|no|41| +|[ms-net-library](licenses/ms-net-library)|no|no|6| |[PostgreSQL](licenses/postgresql)|no|no|1| -Packages 60 +Packages 53 -------- |Name|Version|Source|License|Used by| |----------|:----|:----|:----|:----| -|[Castle.Core](packages/nuget.org/castle.core/4.4.0)|4.4.0|[nuget.org](https://www.nuget.org/packages/Castle.Core/4.4.0)|[Apache-2.0](licenses/apache-2.0)|SqlDatabase internal| +|[Castle.Core](packages/nuget.org/castle.core/5.1.0)|5.1.0|[nuget.org](https://www.nuget.org/packages/Castle.Core/5.1.0)|[Apache-2.0](licenses/apache-2.0)|SqlDatabase internal| |[Dapper.StrongName](packages/nuget.org/dapper.strongname/2.0.123)|2.0.123|[nuget.org](https://www.nuget.org/packages/Dapper.StrongName/2.0.123)|[Apache-2.0](licenses/apache-2.0)|SqlDatabase internal| -|[DiffEngine](packages/nuget.org/diffengine/6.4.9)|6.4.9|[nuget.org](https://www.nuget.org/packages/DiffEngine/6.4.9)|[MIT](licenses/mit)|SqlDatabase internal| -|[EmptyFiles](packages/nuget.org/emptyfiles/2.3.3)|2.3.3|[nuget.org](https://www.nuget.org/packages/EmptyFiles/2.3.3)|[MIT](licenses/mit)|SqlDatabase internal| -|[Microsoft.CodeCoverage](packages/nuget.org/microsoft.codecoverage/17.0.0)|17.0.0|[nuget.org](https://www.nuget.org/packages/Microsoft.CodeCoverage/17.0.0)|[MIT](licenses/mit)|SqlDatabase internal| -|[Microsoft.NET.Test.Sdk](packages/nuget.org/microsoft.net.test.sdk/17.0.0)|17.0.0|[nuget.org](https://www.nuget.org/packages/Microsoft.NET.Test.Sdk/17.0.0)|[MIT](licenses/mit)|SqlDatabase internal| -|[Microsoft.TestPlatform.ObjectModel](packages/nuget.org/microsoft.testplatform.objectmodel/17.0.0)|17.0.0|[nuget.org](https://www.nuget.org/packages/Microsoft.TestPlatform.ObjectModel/17.0.0)|[MIT](licenses/mit)|SqlDatabase internal| -|[Microsoft.TestPlatform.TestHost](packages/nuget.org/microsoft.testplatform.testhost/17.0.0)|17.0.0|[nuget.org](https://www.nuget.org/packages/Microsoft.TestPlatform.TestHost/17.0.0)|[MIT](licenses/mit)|SqlDatabase internal| -|[Microsoft.Win32.Registry](packages/nuget.org/microsoft.win32.registry/4.5.0)|4.5.0|[nuget.org](https://www.nuget.org/packages/Microsoft.Win32.Registry/4.5.0)|[MIT](licenses/mit)|SqlDatabase| +|[DiffEngine](packages/nuget.org/diffengine/10.0.0)|10.0.0|[nuget.org](https://www.nuget.org/packages/DiffEngine/10.0.0)|[MIT](licenses/mit)|SqlDatabase internal| +|[EmptyFiles](packages/nuget.org/emptyfiles/2.8.0)|2.8.0|[nuget.org](https://www.nuget.org/packages/EmptyFiles/2.8.0)|[MIT](licenses/mit)|SqlDatabase internal| +|[Microsoft.CodeCoverage](packages/nuget.org/microsoft.codecoverage/17.4.0)|17.4.0|[nuget.org](https://www.nuget.org/packages/Microsoft.CodeCoverage/17.4.0)|[ms-net-library](licenses/ms-net-library)|SqlDatabase internal| +|[Microsoft.NET.Test.Sdk](packages/nuget.org/microsoft.net.test.sdk/17.4.0)|17.4.0|[nuget.org](https://www.nuget.org/packages/Microsoft.NET.Test.Sdk/17.4.0)|[ms-net-library](licenses/ms-net-library)|SqlDatabase internal| +|[Microsoft.TestPlatform.ObjectModel](packages/nuget.org/microsoft.testplatform.objectmodel/17.4.0)|17.4.0|[nuget.org](https://www.nuget.org/packages/Microsoft.TestPlatform.ObjectModel/17.4.0)|[ms-net-library](licenses/ms-net-library)|SqlDatabase internal| +|[Microsoft.TestPlatform.TestHost](packages/nuget.org/microsoft.testplatform.testhost/17.4.0)|17.4.0|[nuget.org](https://www.nuget.org/packages/Microsoft.TestPlatform.TestHost/17.4.0)|[ms-net-library](licenses/ms-net-library)|SqlDatabase internal| +|[Microsoft.Win32.Registry](packages/nuget.org/microsoft.win32.registry/4.7.0)|4.7.0|[nuget.org](https://www.nuget.org/packages/Microsoft.Win32.Registry/4.7.0)|[MIT](licenses/mit)|SqlDatabase| +|[Microsoft.Win32.Registry](packages/nuget.org/microsoft.win32.registry/5.0.0)|5.0.0|[nuget.org](https://www.nuget.org/packages/Microsoft.Win32.Registry/5.0.0)|[MIT](licenses/mit)|SqlDatabase internal| |[Microsoft.WSMan.Runtime](packages/nuget.org/microsoft.wsman.runtime/7.0.5)|7.0.5|[nuget.org](https://www.nuget.org/packages/Microsoft.WSMan.Runtime/7.0.5)|[MIT](licenses/mit)|SqlDatabase| |[Microsoft.WSMan.Runtime](packages/nuget.org/microsoft.wsman.runtime/7.1.2)|7.1.2|[nuget.org](https://www.nuget.org/packages/Microsoft.WSMan.Runtime/7.1.2)|[MIT](licenses/mit)|SqlDatabase| |[Microsoft.WSMan.Runtime](packages/nuget.org/microsoft.wsman.runtime/7.2.0)|7.2.0|[nuget.org](https://www.nuget.org/packages/Microsoft.WSMan.Runtime/7.2.0)|[MIT](licenses/mit)|SqlDatabase| -|[Moq](packages/nuget.org/moq/4.16.1)|4.16.1|[nuget.org](https://www.nuget.org/packages/Moq/4.16.1)|[BSD-3-Clause](licenses/bsd-3-clause)|SqlDatabase internal| +|[Microsoft.WSMan.Runtime](packages/nuget.org/microsoft.wsman.runtime/7.3.0)|7.3.0|[nuget.org](https://www.nuget.org/packages/Microsoft.WSMan.Runtime/7.3.0)|[MIT](licenses/mit)|SqlDatabase| +|[Moq](packages/nuget.org/moq/4.18.2)|4.18.2|[nuget.org](https://www.nuget.org/packages/Moq/4.18.2)|[BSD-3-Clause](licenses/bsd-3-clause)|SqlDatabase internal| |[MySqlConnector](packages/nuget.org/mysqlconnector/1.3.10)|1.3.10|[nuget.org](https://www.nuget.org/packages/MySqlConnector/1.3.10)|[MIT](licenses/mit)|SqlDatabase| |[NETStandard.Library](packages/nuget.org/netstandard.library/2.0.3)|2.0.3|[nuget.org](https://www.nuget.org/packages/NETStandard.Library/2.0.3)|[MIT](licenses/mit)|SqlDatabase| -|[Newtonsoft.Json](packages/nuget.org/newtonsoft.json/13.0.1)|13.0.1|[nuget.org](https://www.nuget.org/packages/Newtonsoft.Json/13.0.1)|[MIT](licenses/mit)|SqlDatabase internal| +|[Newtonsoft.Json](packages/nuget.org/newtonsoft.json/13.0.2)|13.0.2|[nuget.org](https://www.nuget.org/packages/Newtonsoft.Json/13.0.2)|[MIT](licenses/mit)|SqlDatabase internal| |[Npgsql](packages/nuget.org/npgsql/4.0.11)|4.0.11|[nuget.org](https://www.nuget.org/packages/Npgsql/4.0.11)|[PostgreSQL](licenses/postgresql)|SqlDatabase| -|[NuGet.Frameworks](packages/nuget.org/nuget.frameworks/5.0.0)|5.0.0|[nuget.org](https://www.nuget.org/packages/NuGet.Frameworks/5.0.0%2b42a8779499c1d1ed2488c2e6b9e2ee6ff6107766)|[Apache-2.0](licenses/apache-2.0)|SqlDatabase internal| -|[NUnit](packages/nuget.org/nunit/3.13.2)|3.13.2|[nuget.org](https://www.nuget.org/packages/NUnit/3.13.2)|[MIT](licenses/mit)|SqlDatabase internal| -|[NUnit3TestAdapter](packages/nuget.org/nunit3testadapter/4.1.0)|4.1.0|[nuget.org](https://www.nuget.org/packages/NUnit3TestAdapter/4.1.0)|[MIT](licenses/mit)|SqlDatabase internal| +|[NuGet.Frameworks](packages/nuget.org/nuget.frameworks/5.11.0)|5.11.0|[nuget.org](https://www.nuget.org/packages/NuGet.Frameworks/5.11.0)|[Apache-2.0](licenses/apache-2.0)|SqlDatabase internal| +|[NUnit](packages/nuget.org/nunit/3.13.3)|3.13.3|[nuget.org](https://www.nuget.org/packages/NUnit/3.13.3)|[MIT](licenses/mit)|SqlDatabase internal| +|[NUnit3TestAdapter](packages/nuget.org/nunit3testadapter/4.3.1)|4.3.1|[nuget.org](https://www.nuget.org/packages/NUnit3TestAdapter/4.3.1)|[MIT](licenses/mit)|SqlDatabase internal| |[PowerShellStandard.Library](packages/nuget.org/powershellstandard.library/5.1.0)|5.1.0|[nuget.org](https://www.nuget.org/packages/PowerShellStandard.Library/5.1.0)|[MIT](licenses/mit)|SqlDatabase| -|[Shouldly](packages/nuget.org/shouldly/4.0.3)|4.0.3|[nuget.org](https://www.nuget.org/packages/Shouldly/4.0.3)|[BSD-2-Clause](licenses/bsd-2-clause)|SqlDatabase internal| -|[StyleCop.Analyzers.Unstable](packages/nuget.org/stylecop.analyzers.unstable/1.2.0.376)|1.2.0.376|[nuget.org](https://www.nuget.org/packages/StyleCop.Analyzers.Unstable/1.2.0.376)|[MIT](licenses/mit)|SqlDatabase internal| +|[Shouldly](packages/nuget.org/shouldly/4.1.0)|4.1.0|[nuget.org](https://www.nuget.org/packages/Shouldly/4.1.0)|[BSD-2-Clause](licenses/bsd-2-clause)|SqlDatabase internal| +|[StyleCop.Analyzers.Unstable](packages/nuget.org/stylecop.analyzers.unstable/1.2.0.435)|1.2.0.435|[nuget.org](https://www.nuget.org/packages/StyleCop.Analyzers.Unstable/1.2.0.435)|[MIT](licenses/mit)|SqlDatabase internal| |[System.Buffers](packages/nuget.org/system.buffers/4.4.0)|4.4.0|[nuget.org](https://www.nuget.org/packages/System.Buffers/4.4.0)|[MIT](licenses/mit)|SqlDatabase| -|[System.Buffers](packages/nuget.org/system.buffers/4.5.1)|4.5.1|[nuget.org](https://www.nuget.org/packages/System.Buffers/4.5.1)|[MIT](licenses/mit)|SqlDatabase internal| -|[System.Collections.NonGeneric](packages/nuget.org/system.collections.nongeneric/4.3.0)|4.3.0|[nuget.org](https://www.nuget.org/packages/System.Collections.NonGeneric/4.3.0)|[ms-net-library](licenses/ms-net-library)|SqlDatabase internal| -|[System.Collections.Specialized](packages/nuget.org/system.collections.specialized/4.3.0)|4.3.0|[nuget.org](https://www.nuget.org/packages/System.Collections.Specialized/4.3.0)|[ms-net-library](licenses/ms-net-library)|SqlDatabase internal| -|[System.ComponentModel](packages/nuget.org/system.componentmodel/4.3.0)|4.3.0|[nuget.org](https://www.nuget.org/packages/System.ComponentModel/4.3.0)|[ms-net-library](licenses/ms-net-library)|SqlDatabase internal| -|[System.ComponentModel.Primitives](packages/nuget.org/system.componentmodel.primitives/4.3.0)|4.3.0|[nuget.org](https://www.nuget.org/packages/System.ComponentModel.Primitives/4.3.0)|[ms-net-library](licenses/ms-net-library)|SqlDatabase internal| -|[System.ComponentModel.TypeConverter](packages/nuget.org/system.componentmodel.typeconverter/4.3.0)|4.3.0|[nuget.org](https://www.nuget.org/packages/System.ComponentModel.TypeConverter/4.3.0)|[ms-net-library](licenses/ms-net-library)|SqlDatabase internal| +|[System.Buffers](packages/nuget.org/system.buffers/4.5.1)|4.5.1|[nuget.org](https://www.nuget.org/packages/System.Buffers/4.5.1)|[MIT](licenses/mit)|SqlDatabase| +|[System.CodeDom](packages/nuget.org/system.codedom/5.0.0)|5.0.0|[nuget.org](https://www.nuget.org/packages/System.CodeDom/5.0.0)|[MIT](licenses/mit)|SqlDatabase internal| |[System.Configuration.ConfigurationManager](packages/nuget.org/system.configuration.configurationmanager/4.5.0)|4.5.0|[nuget.org](https://www.nuget.org/packages/System.Configuration.ConfigurationManager/4.5.0)|[MIT](licenses/mit)|SqlDatabase| -|[System.Data.SqlClient](packages/nuget.org/system.data.sqlclient/4.5.1)|4.5.1|[nuget.org](https://www.nuget.org/packages/System.Data.SqlClient/4.5.1)|[MIT](licenses/mit)|SqlDatabase| -|[System.Diagnostics.DiagnosticSource](packages/nuget.org/system.diagnostics.diagnosticsource/4.5.0)|4.5.0|[nuget.org](https://www.nuget.org/packages/System.Diagnostics.DiagnosticSource/4.5.0)|[MIT](licenses/mit)|SqlDatabase| -|[System.Dynamic.Runtime](packages/nuget.org/system.dynamic.runtime/4.3.0)|4.3.0|[nuget.org](https://www.nuget.org/packages/System.Dynamic.Runtime/4.3.0)|[ms-net-library](licenses/ms-net-library)|SqlDatabase internal| -|[System.IO.FileSystem.Primitives](packages/nuget.org/system.io.filesystem.primitives/4.3.0)|4.3.0|[nuget.org](https://www.nuget.org/packages/System.IO.FileSystem.Primitives/4.3.0)|[ms-net-library](licenses/ms-net-library)|SqlDatabase internal| -|[System.Linq](packages/nuget.org/system.linq/4.3.0)|4.3.0|[nuget.org](https://www.nuget.org/packages/System.Linq/4.3.0)|[ms-net-library](licenses/ms-net-library)|SqlDatabase internal| -|[System.Linq.Expressions](packages/nuget.org/system.linq.expressions/4.3.0)|4.3.0|[nuget.org](https://www.nuget.org/packages/System.Linq.Expressions/4.3.0)|[ms-net-library](licenses/ms-net-library)|SqlDatabase internal| +|[System.Data.SqlClient](packages/nuget.org/system.data.sqlclient/4.8.5)|4.8.5|[nuget.org](https://www.nuget.org/packages/System.Data.SqlClient/4.8.5)|[MIT](licenses/mit)|SqlDatabase| +|[System.Diagnostics.DiagnosticSource](packages/nuget.org/system.diagnostics.diagnosticsource/4.7.0)|4.7.0|[nuget.org](https://www.nuget.org/packages/System.Diagnostics.DiagnosticSource/4.7.0)|[MIT](licenses/mit)|SqlDatabase| +|[System.Diagnostics.EventLog](packages/nuget.org/system.diagnostics.eventlog/4.7.0)|4.7.0|[nuget.org](https://www.nuget.org/packages/System.Diagnostics.EventLog/4.7.0)|[MIT](licenses/mit)|SqlDatabase internal| +|[System.Diagnostics.EventLog](packages/nuget.org/system.diagnostics.eventlog/6.0.0)|6.0.0|[nuget.org](https://www.nuget.org/packages/System.Diagnostics.EventLog/6.0.0)|[MIT](licenses/mit)|SqlDatabase internal| +|[System.Management](packages/nuget.org/system.management/5.0.0)|5.0.0|[nuget.org](https://www.nuget.org/packages/System.Management/5.0.0)|[MIT](licenses/mit)|SqlDatabase internal| |[System.Memory](packages/nuget.org/system.memory/4.5.3)|4.5.3|[nuget.org](https://www.nuget.org/packages/System.Memory/4.5.3)|[MIT](licenses/mit)|SqlDatabase| -|[System.Memory](packages/nuget.org/system.memory/4.5.4)|4.5.4|[nuget.org](https://www.nuget.org/packages/System.Memory/4.5.4)|[MIT](licenses/mit)|SqlDatabase internal| +|[System.Memory](packages/nuget.org/system.memory/4.5.4)|4.5.4|[nuget.org](https://www.nuget.org/packages/System.Memory/4.5.4)|[MIT](licenses/mit)|SqlDatabase| |[System.Numerics.Vectors](packages/nuget.org/system.numerics.vectors/4.4.0)|4.4.0|[nuget.org](https://www.nuget.org/packages/System.Numerics.Vectors/4.4.0)|[MIT](licenses/mit)|SqlDatabase| -|[System.Numerics.Vectors](packages/nuget.org/system.numerics.vectors/4.5.0)|4.5.0|[nuget.org](https://www.nuget.org/packages/System.Numerics.Vectors/4.5.0)|[MIT](licenses/mit)|SqlDatabase internal| -|[System.ObjectModel](packages/nuget.org/system.objectmodel/4.3.0)|4.3.0|[nuget.org](https://www.nuget.org/packages/System.ObjectModel/4.3.0)|[ms-net-library](licenses/ms-net-library)|SqlDatabase internal| |[System.Reflection.Metadata](packages/nuget.org/system.reflection.metadata/1.6.0)|1.6.0|[nuget.org](https://www.nuget.org/packages/System.Reflection.Metadata/1.6.0)|[MIT](licenses/mit)|SqlDatabase internal| -|[System.Reflection.TypeExtensions](packages/nuget.org/system.reflection.typeextensions/4.3.0)|4.3.0|[nuget.org](https://www.nuget.org/packages/System.Reflection.TypeExtensions/4.3.0)|[ms-net-library](licenses/ms-net-library)|SqlDatabase internal| |[System.Runtime.CompilerServices.Unsafe](packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.2)|4.5.2|[nuget.org](https://www.nuget.org/packages/System.Runtime.CompilerServices.Unsafe/4.5.2)|[MIT](licenses/mit)|SqlDatabase| |[System.Runtime.CompilerServices.Unsafe](packages/nuget.org/system.runtime.compilerservices.unsafe/4.5.3)|4.5.3|[nuget.org](https://www.nuget.org/packages/System.Runtime.CompilerServices.Unsafe/4.5.3)|[MIT](licenses/mit)|SqlDatabase internal| +|[System.Runtime.CompilerServices.Unsafe](packages/nuget.org/system.runtime.compilerservices.unsafe/4.7.0)|4.7.0|[nuget.org](https://www.nuget.org/packages/System.Runtime.CompilerServices.Unsafe/4.7.0)|[MIT](licenses/mit)|SqlDatabase| |[System.Runtime.InteropServices.RuntimeInformation](packages/nuget.org/system.runtime.interopservices.runtimeinformation/4.3.0)|4.3.0|[nuget.org](https://www.nuget.org/packages/System.Runtime.InteropServices.RuntimeInformation/4.3.0)|[ms-net-library](licenses/ms-net-library)|SqlDatabase internal| |[System.Runtime.Loader](packages/nuget.org/system.runtime.loader/4.3.0)|4.3.0|[nuget.org](https://www.nuget.org/packages/System.Runtime.Loader/4.3.0)|[ms-net-library](licenses/ms-net-library)|SqlDatabase| -|[System.Security.AccessControl](packages/nuget.org/system.security.accesscontrol/4.5.0)|4.5.0|[nuget.org](https://www.nuget.org/packages/System.Security.AccessControl/4.5.0)|[MIT](licenses/mit)|SqlDatabase| +|[System.Security.AccessControl](packages/nuget.org/system.security.accesscontrol/4.7.0)|4.7.0|[nuget.org](https://www.nuget.org/packages/System.Security.AccessControl/4.7.0)|[MIT](licenses/mit)|SqlDatabase| +|[System.Security.AccessControl](packages/nuget.org/system.security.accesscontrol/5.0.0)|5.0.0|[nuget.org](https://www.nuget.org/packages/System.Security.AccessControl/5.0.0)|[MIT](licenses/mit)|SqlDatabase internal| |[System.Security.Cryptography.ProtectedData](packages/nuget.org/system.security.cryptography.protecteddata/4.5.0)|4.5.0|[nuget.org](https://www.nuget.org/packages/System.Security.Cryptography.ProtectedData/4.5.0)|[MIT](licenses/mit)|SqlDatabase| |[System.Security.Permissions](packages/nuget.org/system.security.permissions/4.5.0)|4.5.0|[nuget.org](https://www.nuget.org/packages/System.Security.Permissions/4.5.0)|[MIT](licenses/mit)|SqlDatabase| -|[System.Security.Principal.Windows](packages/nuget.org/system.security.principal.windows/4.5.0)|4.5.0|[nuget.org](https://www.nuget.org/packages/System.Security.Principal.Windows/4.5.0)|[MIT](licenses/mit)|SqlDatabase| -|[System.Text.Encoding.CodePages](packages/nuget.org/system.text.encoding.codepages/4.5.0)|4.5.0|[nuget.org](https://www.nuget.org/packages/System.Text.Encoding.CodePages/4.5.0)|[MIT](licenses/mit)|SqlDatabase| -|[System.Text.RegularExpressions](packages/nuget.org/system.text.regularexpressions/4.3.0)|4.3.0|[nuget.org](https://www.nuget.org/packages/System.Text.RegularExpressions/4.3.0)|[ms-net-library](licenses/ms-net-library)|SqlDatabase internal| -|[System.Threading](packages/nuget.org/system.threading/4.3.0)|4.3.0|[nuget.org](https://www.nuget.org/packages/System.Threading/4.3.0)|[ms-net-library](licenses/ms-net-library)|SqlDatabase internal| +|[System.Security.Principal.Windows](packages/nuget.org/system.security.principal.windows/4.7.0)|4.7.0|[nuget.org](https://www.nuget.org/packages/System.Security.Principal.Windows/4.7.0)|[MIT](licenses/mit)|SqlDatabase| +|[System.Security.Principal.Windows](packages/nuget.org/system.security.principal.windows/5.0.0)|5.0.0|[nuget.org](https://www.nuget.org/packages/System.Security.Principal.Windows/5.0.0)|[MIT](licenses/mit)|SqlDatabase internal| +|[System.Text.Encoding.CodePages](packages/nuget.org/system.text.encoding.codepages/4.7.0)|4.7.0|[nuget.org](https://www.nuget.org/packages/System.Text.Encoding.CodePages/4.7.0)|[MIT](licenses/mit)|SqlDatabase| |[System.Threading.Tasks.Extensions](packages/nuget.org/system.threading.tasks.extensions/4.5.2)|4.5.2|[nuget.org](https://www.nuget.org/packages/System.Threading.Tasks.Extensions/4.5.2)|[MIT](licenses/mit)|SqlDatabase| |[System.Threading.Tasks.Extensions](packages/nuget.org/system.threading.tasks.extensions/4.5.4)|4.5.4|[nuget.org](https://www.nuget.org/packages/System.Threading.Tasks.Extensions/4.5.4)|[MIT](licenses/mit)|SqlDatabase internal| |[System.ValueTuple](packages/nuget.org/system.valuetuple/4.5.0)|4.5.0|[nuget.org](https://www.nuget.org/packages/System.ValueTuple/4.5.0)|[MIT](licenses/mit)|SqlDatabase| -|[System.Xml.ReaderWriter](packages/nuget.org/system.xml.readerwriter/4.3.0)|4.3.0|[nuget.org](https://www.nuget.org/packages/System.Xml.ReaderWriter/4.3.0)|[ms-net-library](licenses/ms-net-library)|SqlDatabase internal| -|[System.Xml.XmlDocument](packages/nuget.org/system.xml.xmldocument/4.3.0)|4.3.0|[nuget.org](https://www.nuget.org/packages/System.Xml.XmlDocument/4.3.0)|[ms-net-library](licenses/ms-net-library)|SqlDatabase internal| *This page was generated by [ThirdPartyLibraries.GlobalTool](https://github.com/max-ieremenko/ThirdPartyLibraries).* \ No newline at end of file diff --git a/Examples/CSharpMirationStep/readme.md b/Examples/CSharpMirationStep/readme.md index c8d38867..e142106a 100644 --- a/Examples/CSharpMirationStep/readme.md +++ b/Examples/CSharpMirationStep/readme.md @@ -4,12 +4,12 @@ Any assembly script is - .exe or .dll for target framework is 4.5.2+ -- .dll for .net core 3.1 or .net5.0/6.0 +- .dll for .net 7.0, 6.0, 5.0 or .net core 3.1 - has exactly one class with script implementation This project is an example of script implementation. The build output is 2.1_2.2.dll with target framework 4.5.2. -Due to the current dependencies, 2.1_2.2.dll works well on .net core 3.1 and .net 5.0/6.0. +Due to the current dependencies, 2.1_2.2.dll works well on .net 7.0 - .net core 3.1. ## Script source diff --git a/Examples/MigrationStepsFolder/README.md b/Examples/MigrationStepsFolder/README.md index d8d67887..33f5dc18 100644 --- a/Examples/MigrationStepsFolder/README.md +++ b/Examples/MigrationStepsFolder/README.md @@ -1,4 +1,3 @@ - SqlDatabase supports [straight forward upgrade](StraightForward) and [modularity upgrade](Modularity). Upgrade an existing database diff --git a/Examples/PackageManagerConsole/SolutionScripts/SolutionScripts.csproj b/Examples/PackageManagerConsole/SolutionScripts/SolutionScripts.csproj index b0c44127..d8e0fab3 100644 --- a/Examples/PackageManagerConsole/SolutionScripts/SolutionScripts.csproj +++ b/Examples/PackageManagerConsole/SolutionScripts/SolutionScripts.csproj @@ -10,7 +10,7 @@ - + diff --git a/Examples/PackageManagerConsole/SomeApp/Program.cs b/Examples/PackageManagerConsole/SomeApp/Program.cs index 63c98128..e0c382f3 100644 --- a/Examples/PackageManagerConsole/SomeApp/Program.cs +++ b/Examples/PackageManagerConsole/SomeApp/Program.cs @@ -1,12 +1,11 @@ using System; -namespace SomeApp +namespace SomeApp; + +public static class Program { - public static class Program + public static void Main(string[] args) { - public static void Main(string[] args) - { - Console.WriteLine("Hello World!"); - } + Console.WriteLine("Hello World!"); } -} +} \ No newline at end of file diff --git a/Examples/PackageManagerConsole/SomeApp/SomeApp.csproj b/Examples/PackageManagerConsole/SomeApp/SomeApp.csproj index 568449f4..ba7c5d2a 100644 --- a/Examples/PackageManagerConsole/SomeApp/SomeApp.csproj +++ b/Examples/PackageManagerConsole/SomeApp/SomeApp.csproj @@ -1,12 +1,10 @@ - net452 - false + net7.0 true AnyCPU - false diff --git a/Examples/PowerShellScript/readme.md b/Examples/PowerShellScript/readme.md index 2c46721c..fd83bf0b 100644 --- a/Examples/PowerShellScript/readme.md +++ b/Examples/PowerShellScript/readme.md @@ -71,9 +71,10 @@ Installed Powershell Desktop version. [![NuGet](https://img.shields.io/nuget/v/SqlDatabase.GlobalTool.svg?style=flat-square&label=nuget%20dotnet%20tool)](https://www.nuget.org/packages/SqlDatabase.GlobalTool/) -Pre-installed Powershell Core is required, will be used by SqlDatabase as external component. Due to Powershell Core design, +Pre-installed Powershell Core is required, will be used by SqlDatabase as external component. Due to the Powershell Core design: -* SqlDatabase .net 6.0 can host Powershell Core versions below 7.3.1 +* SqlDatabase .net 7.0 can host Powershell Core versions below 7.4 +* SqlDatabase .net 6.0 can host Powershell Core versions below 7.3 * .net 5.0 can host Powershell Core versions below 7.2 * .net core 3.1 below 7.1 diff --git a/README.md b/README.md index 8acbe04e..78d5941c 100644 --- a/README.md +++ b/README.md @@ -13,16 +13,24 @@ Table of Contents +- [SqlDatabase](#sqldatabase) + - [Table of Contents](#table-of-contents) - [Installation](#installation) - - [Target database type selection ](#target-database-type-selection-) - - [Execute script(s) ](#execute-scripts-) - - [Export data from a database to sql script (file) ](#export-data-from-a-database-to-sql-script-file-) - - [Create a database ](#create-a-database-) - - [Migrate an existing database ](#migrate-an-existing-database-) + - [PowerShell, from gallery](#powershell-from-gallery) + - [PowerShell, manual release download](#powershell-manual-release-download) + - [Dotnet sdk tool](#dotnet-sdk-tool) + - [Target database type selection ](#target-database-type-selection-) + - [Execute script(s) ](#execute-scripts-) + - [Export data from a database to sql script (file) ](#export-data-from-a-database-to-sql-script-file-) + - [Create a database ](#create-a-database-) + - [Migrate an existing database ](#migrate-an-existing-database-) - [Scripts](#scripts) - [Variables](#variables) - - [*.zip files ](#zip-files-) - - [VS Package manager console ](#vs-package-manager-console-) + - [Example](#example) + - [Example how to hide variable value from a log output](#example-how-to-hide-variable-value-from-a-log-output) + - [Predefined variables](#predefined-variables) + - [\*.zip files ](#zip-files-) + - [VS Package manager console ](#vs-package-manager-console-) - [Examples](#examples) - [License](#license) @@ -33,9 +41,9 @@ Installation PowerShell module is compatible with Powershell Core 6.1+ and PowerShell Desktop 5.1. -.net tool requires SDK .Net 5.0/6.0 or .Net Core 3.1. +.net tool is compatible with .net sdk 7.0, 6.0, 5.0 and .net core 3.1. -Command-line tool is compatible with .net runtime 5.0/6.0, .net Core runtime 3.1 and .net Framework 4.5.2+. +Command-line tool is compatible with .net runtime 7.0, 6.0, 5.0, .net core runtime 3.1 and .net framework 4.5.2+. ### PowerShell, from gallery diff --git a/Sources/Directory.Build.props b/Sources/Directory.Build.props index d9c99767..a7fec37a 100644 --- a/Sources/Directory.Build.props +++ b/Sources/Directory.Build.props @@ -8,10 +8,14 @@ true ..\SqlDatabase.snk latest + + false + en + false - + diff --git a/Sources/GlobalAssemblyInfo.cs b/Sources/GlobalAssemblyInfo.cs index 62f73a4c..fd05e8aa 100644 --- a/Sources/GlobalAssemblyInfo.cs +++ b/Sources/GlobalAssemblyInfo.cs @@ -9,5 +9,5 @@ [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] -[assembly: AssemblyVersion("4.1.0.0")] -[assembly: AssemblyFileVersion("4.1.0.0")] +[assembly: AssemblyVersion("4.1.1.0")] +[assembly: AssemblyFileVersion("4.1.1.0")] diff --git a/Sources/SqlDatabase.PowerShell.Test/CreateCmdLetTest.cs b/Sources/SqlDatabase.PowerShell.Test/CreateCmdLetTest.cs index 1564ba2b..55858e6a 100644 --- a/Sources/SqlDatabase.PowerShell.Test/CreateCmdLetTest.cs +++ b/Sources/SqlDatabase.PowerShell.Test/CreateCmdLetTest.cs @@ -4,79 +4,78 @@ using SqlDatabase.Configuration; using SqlDatabase.PowerShell.TestApi; -namespace SqlDatabase.PowerShell +namespace SqlDatabase.PowerShell; + +[TestFixture] +public class CreateCmdLetTest : SqlDatabaseCmdLetTest { - [TestFixture] - public class CreateCmdLetTest : SqlDatabaseCmdLetTest + [Test] + [TestCase("New-SqlDatabase")] + [TestCase("Create-SqlDatabase")] + public void BuildCommandLine(string commandName) { - [Test] - [TestCase("New-SqlDatabase")] - [TestCase("Create-SqlDatabase")] - public void BuildCommandLine(string commandName) - { - var commandLines = InvokeSqlDatabase( - commandName, - c => - { - c.Parameters.Add(nameof(CreateCmdLet.Database), "connection string"); - c.Parameters.Add(nameof(CreateCmdLet.From), new[] { "file 1", "file 2" }); - c.Parameters.Add(nameof(CreateCmdLet.Configuration), "app.config"); - c.Parameters.Add(nameof(CreateCmdLet.Var), new[] { "x=1", "y=2" }); - c.Parameters.Add(nameof(CreateCmdLet.WhatIf)); - c.Parameters.Add(nameof(CreateCmdLet.Log), "log.txt"); - }); + var commandLines = InvokeSqlDatabase( + commandName, + c => + { + c.Parameters.Add(nameof(CreateCmdLet.Database), "connection string"); + c.Parameters.Add(nameof(CreateCmdLet.From), new[] { "file 1", "file 2" }); + c.Parameters.Add(nameof(CreateCmdLet.Configuration), "app.config"); + c.Parameters.Add(nameof(CreateCmdLet.Var), new[] { "x=1", "y=2" }); + c.Parameters.Add(nameof(CreateCmdLet.WhatIf)); + c.Parameters.Add(nameof(CreateCmdLet.Log), "log.txt"); + }); - commandLines.Length.ShouldBe(1); - var commandLine = commandLines[0]; + commandLines.Length.ShouldBe(1); + var commandLine = commandLines[0]; - commandLine.Command.ShouldBe(CommandLineFactory.CommandCreate); - commandLine.Connection.ShouldBe("connection string"); + commandLine.Command.ShouldBe(CommandLineFactory.CommandCreate); + commandLine.Connection.ShouldBe("connection string"); - commandLine.Scripts.Count.ShouldBe(2); - Path.IsPathRooted(commandLine.Scripts[0]).ShouldBeTrue(); - Path.GetFileName(commandLine.Scripts[0]).ShouldBe("file 1"); - Path.IsPathRooted(commandLine.Scripts[1]).ShouldBeTrue(); - Path.GetFileName(commandLine.Scripts[1]).ShouldBe("file 2"); + commandLine.Scripts.Count.ShouldBe(2); + Path.IsPathRooted(commandLine.Scripts[0]).ShouldBeTrue(); + Path.GetFileName(commandLine.Scripts[0]).ShouldBe("file 1"); + Path.IsPathRooted(commandLine.Scripts[1]).ShouldBeTrue(); + Path.GetFileName(commandLine.Scripts[1]).ShouldBe("file 2"); - Path.IsPathRooted(commandLine.ConfigurationFile).ShouldBeTrue(); - Path.GetFileName(commandLine.ConfigurationFile).ShouldBe("app.config"); + Path.IsPathRooted(commandLine.ConfigurationFile).ShouldBeTrue(); + Path.GetFileName(commandLine.ConfigurationFile).ShouldBe("app.config"); - Path.IsPathRooted(commandLine.LogFileName).ShouldBeTrue(); - Path.GetFileName(commandLine.LogFileName).ShouldBe("log.txt"); + Path.IsPathRooted(commandLine.LogFileName).ShouldBeTrue(); + Path.GetFileName(commandLine.LogFileName).ShouldBe("log.txt"); - commandLine.WhatIf.ShouldBeTrue(); + commandLine.WhatIf.ShouldBeTrue(); - commandLine.Variables.Keys.ShouldBe(new[] { "x", "y" }); - commandLine.Variables["x"].ShouldBe("1"); - commandLine.Variables["y"].ShouldBe("2"); - } + commandLine.Variables.Keys.ShouldBe(new[] { "x", "y" }); + commandLine.Variables["x"].ShouldBe("1"); + commandLine.Variables["y"].ShouldBe("2"); + } - [Test] - [TestCase("New-SqlDatabase")] - [TestCase("Create-SqlDatabase")] - public void BuildPipeCommandLine(string commandName) - { - var commandLines = InvokeInvokeSqlDatabasePipeLine( - commandName, - c => c.Parameters.Add(nameof(CreateCmdLet.Database), "connection string"), - "file 1", - "file 2"); + [Test] + [TestCase("New-SqlDatabase")] + [TestCase("Create-SqlDatabase")] + public void BuildPipeCommandLine(string commandName) + { + var commandLines = InvokeInvokeSqlDatabasePipeLine( + commandName, + c => c.Parameters.Add(nameof(CreateCmdLet.Database), "connection string"), + "file 1", + "file 2"); - commandLines.Length.ShouldBe(2); + commandLines.Length.ShouldBe(2); - commandLines[0].Command.ShouldBe(CommandLineFactory.CommandCreate); - commandLines[0].Connection.ShouldBe("connection string"); - commandLines[0].Scripts.Count.ShouldBe(1); - Path.IsPathRooted(commandLines[0].Scripts[0]).ShouldBeTrue(); - Path.GetFileName(commandLines[0].Scripts[0]).ShouldBe("file 1"); - commandLines[0].InLineScript.Count.ShouldBe(0); + commandLines[0].Command.ShouldBe(CommandLineFactory.CommandCreate); + commandLines[0].Connection.ShouldBe("connection string"); + commandLines[0].Scripts.Count.ShouldBe(1); + Path.IsPathRooted(commandLines[0].Scripts[0]).ShouldBeTrue(); + Path.GetFileName(commandLines[0].Scripts[0]).ShouldBe("file 1"); + commandLines[0].InLineScript.Count.ShouldBe(0); - commandLines[1].Command.ShouldBe(CommandLineFactory.CommandCreate); - commandLines[1].Connection.ShouldBe("connection string"); - commandLines[1].Scripts.Count.ShouldBe(1); - Path.IsPathRooted(commandLines[1].Scripts[0]).ShouldBeTrue(); - Path.GetFileName(commandLines[1].Scripts[0]).ShouldBe("file 2"); - commandLines[1].InLineScript.Count.ShouldBe(0); - } + commandLines[1].Command.ShouldBe(CommandLineFactory.CommandCreate); + commandLines[1].Connection.ShouldBe("connection string"); + commandLines[1].Scripts.Count.ShouldBe(1); + Path.IsPathRooted(commandLines[1].Scripts[0]).ShouldBeTrue(); + Path.GetFileName(commandLines[1].Scripts[0]).ShouldBe("file 2"); + commandLines[1].InLineScript.Count.ShouldBe(0); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell.Test/ExecuteCmdLetTest.cs b/Sources/SqlDatabase.PowerShell.Test/ExecuteCmdLetTest.cs index 766c8873..c0db652c 100644 --- a/Sources/SqlDatabase.PowerShell.Test/ExecuteCmdLetTest.cs +++ b/Sources/SqlDatabase.PowerShell.Test/ExecuteCmdLetTest.cs @@ -4,84 +4,83 @@ using SqlDatabase.Configuration; using SqlDatabase.PowerShell.TestApi; -namespace SqlDatabase.PowerShell +namespace SqlDatabase.PowerShell; + +[TestFixture] +public class ExecuteCmdLetTest : SqlDatabaseCmdLetTest { - [TestFixture] - public class ExecuteCmdLetTest : SqlDatabaseCmdLetTest + [Test] + [TestCase("Invoke-SqlDatabase")] + [TestCase("Execute-SqlDatabase")] + public void BuildCommandLine(string commandName) { - [Test] - [TestCase("Invoke-SqlDatabase")] - [TestCase("Execute-SqlDatabase")] - public void BuildCommandLine(string commandName) - { - var commandLines = InvokeSqlDatabase( - commandName, - c => - { - c.Parameters.Add(nameof(ExecuteCmdLet.Database), "connection string"); - c.Parameters.Add(nameof(ExecuteCmdLet.From), new[] { "file 1", "file 2" }); - c.Parameters.Add(nameof(ExecuteCmdLet.FromSql), new[] { "sql text 1", "sql text 2" }); - c.Parameters.Add(nameof(ExecuteCmdLet.Transaction), TransactionMode.PerStep); - c.Parameters.Add(nameof(ExecuteCmdLet.Configuration), "app.config"); - c.Parameters.Add(nameof(ExecuteCmdLet.Var), new[] { "x=1", "y=2" }); - c.Parameters.Add(nameof(ExecuteCmdLet.WhatIf)); - c.Parameters.Add(nameof(CreateCmdLet.Log), "log.txt"); - }); + var commandLines = InvokeSqlDatabase( + commandName, + c => + { + c.Parameters.Add(nameof(ExecuteCmdLet.Database), "connection string"); + c.Parameters.Add(nameof(ExecuteCmdLet.From), new[] { "file 1", "file 2" }); + c.Parameters.Add(nameof(ExecuteCmdLet.FromSql), new[] { "sql text 1", "sql text 2" }); + c.Parameters.Add(nameof(ExecuteCmdLet.Transaction), TransactionMode.PerStep); + c.Parameters.Add(nameof(ExecuteCmdLet.Configuration), "app.config"); + c.Parameters.Add(nameof(ExecuteCmdLet.Var), new[] { "x=1", "y=2" }); + c.Parameters.Add(nameof(ExecuteCmdLet.WhatIf)); + c.Parameters.Add(nameof(CreateCmdLet.Log), "log.txt"); + }); - commandLines.Length.ShouldBe(1); - var commandLine = commandLines[0]; + commandLines.Length.ShouldBe(1); + var commandLine = commandLines[0]; - commandLine.Command.ShouldBe(CommandLineFactory.CommandExecute); - commandLine.Connection.ShouldBe("connection string"); + commandLine.Command.ShouldBe(CommandLineFactory.CommandExecute); + commandLine.Connection.ShouldBe("connection string"); - commandLine.Scripts.Count.ShouldBe(2); - Path.IsPathRooted(commandLine.Scripts[0]).ShouldBeTrue(); - Path.GetFileName(commandLine.Scripts[0]).ShouldBe("file 1"); - Path.IsPathRooted(commandLine.Scripts[1]).ShouldBeTrue(); - Path.GetFileName(commandLine.Scripts[1]).ShouldBe("file 2"); + commandLine.Scripts.Count.ShouldBe(2); + Path.IsPathRooted(commandLine.Scripts[0]).ShouldBeTrue(); + Path.GetFileName(commandLine.Scripts[0]).ShouldBe("file 1"); + Path.IsPathRooted(commandLine.Scripts[1]).ShouldBeTrue(); + Path.GetFileName(commandLine.Scripts[1]).ShouldBe("file 2"); - commandLine.InLineScript.ShouldBe(new[] { "sql text 1", "sql text 2" }); - commandLine.Transaction.ShouldBe(TransactionMode.PerStep); + commandLine.InLineScript.ShouldBe(new[] { "sql text 1", "sql text 2" }); + commandLine.Transaction.ShouldBe(TransactionMode.PerStep); - Path.IsPathRooted(commandLine.ConfigurationFile).ShouldBeTrue(); - Path.GetFileName(commandLine.ConfigurationFile).ShouldBe("app.config"); + Path.IsPathRooted(commandLine.ConfigurationFile).ShouldBeTrue(); + Path.GetFileName(commandLine.ConfigurationFile).ShouldBe("app.config"); - Path.IsPathRooted(commandLine.LogFileName).ShouldBeTrue(); - Path.GetFileName(commandLine.LogFileName).ShouldBe("log.txt"); + Path.IsPathRooted(commandLine.LogFileName).ShouldBeTrue(); + Path.GetFileName(commandLine.LogFileName).ShouldBe("log.txt"); - commandLine.WhatIf.ShouldBeTrue(); + commandLine.WhatIf.ShouldBeTrue(); - commandLine.Variables.Keys.ShouldBe(new[] { "x", "y" }); - commandLine.Variables["x"].ShouldBe("1"); - commandLine.Variables["y"].ShouldBe("2"); - } + commandLine.Variables.Keys.ShouldBe(new[] { "x", "y" }); + commandLine.Variables["x"].ShouldBe("1"); + commandLine.Variables["y"].ShouldBe("2"); + } - [Test] - [TestCase("Invoke-SqlDatabase")] - [TestCase("Execute-SqlDatabase")] - public void BuildPipeCommandLine(string commandName) - { - var commandLines = InvokeInvokeSqlDatabasePipeLine( - commandName, - c => c.Parameters.Add(nameof(ExecuteCmdLet.Database), "connection string"), - "file 1", - "file 2"); + [Test] + [TestCase("Invoke-SqlDatabase")] + [TestCase("Execute-SqlDatabase")] + public void BuildPipeCommandLine(string commandName) + { + var commandLines = InvokeInvokeSqlDatabasePipeLine( + commandName, + c => c.Parameters.Add(nameof(ExecuteCmdLet.Database), "connection string"), + "file 1", + "file 2"); - commandLines.Length.ShouldBe(2); + commandLines.Length.ShouldBe(2); - commandLines[0].Command.ShouldBe(CommandLineFactory.CommandExecute); - commandLines[0].Connection.ShouldBe("connection string"); - commandLines[0].Scripts.Count.ShouldBe(1); - Path.IsPathRooted(commandLines[0].Scripts[0]).ShouldBeTrue(); - Path.GetFileName(commandLines[0].Scripts[0]).ShouldBe("file 1"); - commandLines[0].InLineScript.Count.ShouldBe(0); + commandLines[0].Command.ShouldBe(CommandLineFactory.CommandExecute); + commandLines[0].Connection.ShouldBe("connection string"); + commandLines[0].Scripts.Count.ShouldBe(1); + Path.IsPathRooted(commandLines[0].Scripts[0]).ShouldBeTrue(); + Path.GetFileName(commandLines[0].Scripts[0]).ShouldBe("file 1"); + commandLines[0].InLineScript.Count.ShouldBe(0); - commandLines[1].Command.ShouldBe(CommandLineFactory.CommandExecute); - commandLines[1].Connection.ShouldBe("connection string"); - commandLines[1].Scripts.Count.ShouldBe(1); - Path.IsPathRooted(commandLines[1].Scripts[0]).ShouldBeTrue(); - Path.GetFileName(commandLines[1].Scripts[0]).ShouldBe("file 2"); - commandLines[1].InLineScript.Count.ShouldBe(0); - } + commandLines[1].Command.ShouldBe(CommandLineFactory.CommandExecute); + commandLines[1].Connection.ShouldBe("connection string"); + commandLines[1].Scripts.Count.ShouldBe(1); + Path.IsPathRooted(commandLines[1].Scripts[0]).ShouldBeTrue(); + Path.GetFileName(commandLines[1].Scripts[0]).ShouldBe("file 2"); + commandLines[1].InLineScript.Count.ShouldBe(0); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell.Test/ExportCmdLetTest.cs b/Sources/SqlDatabase.PowerShell.Test/ExportCmdLetTest.cs index 5c2c68dc..527194ca 100644 --- a/Sources/SqlDatabase.PowerShell.Test/ExportCmdLetTest.cs +++ b/Sources/SqlDatabase.PowerShell.Test/ExportCmdLetTest.cs @@ -4,53 +4,52 @@ using SqlDatabase.Configuration; using SqlDatabase.PowerShell.TestApi; -namespace SqlDatabase.PowerShell +namespace SqlDatabase.PowerShell; + +[TestFixture] +public class ExportCmdLetTest : SqlDatabaseCmdLetTest { - [TestFixture] - public class ExportCmdLetTest : SqlDatabaseCmdLetTest + [Test] + public void BuildCommandLine() { - [Test] - public void BuildCommandLine() - { - var commandLines = InvokeSqlDatabase( - "Export-SqlDatabase", - c => - { - c.Parameters.Add(nameof(ExportCmdLet.Database), "connection string"); - c.Parameters.Add(nameof(ExportCmdLet.From), new[] { "file 1", "file 2" }); - c.Parameters.Add(nameof(ExportCmdLet.FromSql), new[] { "sql text 1", "sql text 2" }); - c.Parameters.Add(nameof(ExportCmdLet.ToFile), "to file"); - c.Parameters.Add(nameof(ExportCmdLet.ToTable), "to table"); - c.Parameters.Add(nameof(ExportCmdLet.Configuration), "app.config"); - c.Parameters.Add(nameof(ExportCmdLet.Var), new[] { "x=1", "y=2" }); - c.Parameters.Add(nameof(CreateCmdLet.Log), "log.txt"); - }); - - commandLines.Length.ShouldBe(1); - var commandLine = commandLines[0]; - - commandLine.Command.ShouldBe(CommandLineFactory.CommandExport); - commandLine.Connection.ShouldBe("connection string"); - - commandLine.Scripts.Count.ShouldBe(2); - Path.IsPathRooted(commandLine.Scripts[0]).ShouldBeTrue(); - Path.GetFileName(commandLine.Scripts[0]).ShouldBe("file 1"); - Path.IsPathRooted(commandLine.Scripts[1]).ShouldBeTrue(); - Path.GetFileName(commandLine.Scripts[1]).ShouldBe("file 2"); - - commandLine.InLineScript.ShouldBe(new[] { "sql text 1", "sql text 2" }); - commandLine.ExportToFile.ShouldBe("to file"); - commandLine.ExportToTable.ShouldBe("to table"); - - Path.IsPathRooted(commandLine.ConfigurationFile).ShouldBeTrue(); - Path.GetFileName(commandLine.ConfigurationFile).ShouldBe("app.config"); - - Path.IsPathRooted(commandLine.LogFileName).ShouldBeTrue(); - Path.GetFileName(commandLine.LogFileName).ShouldBe("log.txt"); - - commandLine.Variables.Keys.ShouldBe(new[] { "x", "y" }); - commandLine.Variables["x"].ShouldBe("1"); - commandLine.Variables["y"].ShouldBe("2"); - } + var commandLines = InvokeSqlDatabase( + "Export-SqlDatabase", + c => + { + c.Parameters.Add(nameof(ExportCmdLet.Database), "connection string"); + c.Parameters.Add(nameof(ExportCmdLet.From), new[] { "file 1", "file 2" }); + c.Parameters.Add(nameof(ExportCmdLet.FromSql), new[] { "sql text 1", "sql text 2" }); + c.Parameters.Add(nameof(ExportCmdLet.ToFile), "to file"); + c.Parameters.Add(nameof(ExportCmdLet.ToTable), "to table"); + c.Parameters.Add(nameof(ExportCmdLet.Configuration), "app.config"); + c.Parameters.Add(nameof(ExportCmdLet.Var), new[] { "x=1", "y=2" }); + c.Parameters.Add(nameof(CreateCmdLet.Log), "log.txt"); + }); + + commandLines.Length.ShouldBe(1); + var commandLine = commandLines[0]; + + commandLine.Command.ShouldBe(CommandLineFactory.CommandExport); + commandLine.Connection.ShouldBe("connection string"); + + commandLine.Scripts.Count.ShouldBe(2); + Path.IsPathRooted(commandLine.Scripts[0]).ShouldBeTrue(); + Path.GetFileName(commandLine.Scripts[0]).ShouldBe("file 1"); + Path.IsPathRooted(commandLine.Scripts[1]).ShouldBeTrue(); + Path.GetFileName(commandLine.Scripts[1]).ShouldBe("file 2"); + + commandLine.InLineScript.ShouldBe(new[] { "sql text 1", "sql text 2" }); + commandLine.ExportToFile.ShouldBe("to file"); + commandLine.ExportToTable.ShouldBe("to table"); + + Path.IsPathRooted(commandLine.ConfigurationFile).ShouldBeTrue(); + Path.GetFileName(commandLine.ConfigurationFile).ShouldBe("app.config"); + + Path.IsPathRooted(commandLine.LogFileName).ShouldBeTrue(); + Path.GetFileName(commandLine.LogFileName).ShouldBe("log.txt"); + + commandLine.Variables.Keys.ShouldBe(new[] { "x", "y" }); + commandLine.Variables["x"].ShouldBe("1"); + commandLine.Variables["y"].ShouldBe("2"); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell.Test/InfoCmdLetTest.cs b/Sources/SqlDatabase.PowerShell.Test/InfoCmdLetTest.cs index c1ee26f5..1c5d3f2c 100644 --- a/Sources/SqlDatabase.PowerShell.Test/InfoCmdLetTest.cs +++ b/Sources/SqlDatabase.PowerShell.Test/InfoCmdLetTest.cs @@ -4,29 +4,28 @@ using Shouldly; using SqlDatabase.PowerShell.TestApi; -namespace SqlDatabase.PowerShell +namespace SqlDatabase.PowerShell; + +[TestFixture] +public class InfoCmdLetTest : SqlDatabaseCmdLetTest { - [TestFixture] - public class InfoCmdLetTest : SqlDatabaseCmdLetTest + [Test] + public void ProcessRecord() { - [Test] - public void ProcessRecord() - { - var actual = InvokeCommand("Show-SqlDatabaseInfo"); + var actual = InvokeCommand("Show-SqlDatabaseInfo"); - actual.Count.ShouldBe(1); - Console.WriteLine(actual[0]); + actual.Count.ShouldBe(1); + Console.WriteLine(actual[0]); - actual[0].Properties["PSEdition"].Value.ShouldBeOfType().ShouldNotBeNullOrWhiteSpace(); - actual[0].Properties["PSVersion"].Value.ShouldBeOfType().ShouldNotBeNullOrWhiteSpace(); - actual[0].Properties["Version"].Value.ShouldBeOfType().ShouldNotBeNull(); - actual[0].Properties["FrameworkDescription"].Value.ShouldBeOfType().ShouldNotBeNullOrWhiteSpace(); - actual[0].Properties["OSDescription"].Value.ShouldBeOfType().ShouldNotBeNullOrWhiteSpace(); - actual[0].Properties["OSArchitecture"].Value.ShouldBeOfType(); - actual[0].Properties["ProcessArchitecture"].Value.ShouldBeOfType(); - actual[0].Properties["Location"].Value.ShouldBeOfType().ShouldNotBeNullOrWhiteSpace(); - actual[0].Properties["WorkingDirectory"].Value.ShouldBeOfType().ShouldNotBeNullOrWhiteSpace(); - actual[0].Properties["DefaultConfigurationFile"].Value.ShouldBeOfType().ShouldNotBeNullOrWhiteSpace(); - } + actual[0].Properties["PSEdition"].Value.ShouldBeOfType().ShouldNotBeNullOrWhiteSpace(); + actual[0].Properties["PSVersion"].Value.ShouldBeOfType().ShouldNotBeNullOrWhiteSpace(); + actual[0].Properties["Version"].Value.ShouldBeOfType().ShouldNotBeNull(); + actual[0].Properties["FrameworkDescription"].Value.ShouldBeOfType().ShouldNotBeNullOrWhiteSpace(); + actual[0].Properties["OSDescription"].Value.ShouldBeOfType().ShouldNotBeNullOrWhiteSpace(); + actual[0].Properties["OSArchitecture"].Value.ShouldBeOfType(); + actual[0].Properties["ProcessArchitecture"].Value.ShouldBeOfType(); + actual[0].Properties["Location"].Value.ShouldBeOfType().ShouldNotBeNullOrWhiteSpace(); + actual[0].Properties["WorkingDirectory"].Value.ShouldBeOfType().ShouldNotBeNullOrWhiteSpace(); + actual[0].Properties["DefaultConfigurationFile"].Value.ShouldBeOfType().ShouldNotBeNullOrWhiteSpace(); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell.Test/Internal/DependencyResolverFactoryTest.cs b/Sources/SqlDatabase.PowerShell.Test/Internal/DependencyResolverFactoryTest.cs index 946d5228..763d1b73 100644 --- a/Sources/SqlDatabase.PowerShell.Test/Internal/DependencyResolverFactoryTest.cs +++ b/Sources/SqlDatabase.PowerShell.Test/Internal/DependencyResolverFactoryTest.cs @@ -3,26 +3,25 @@ using NUnit.Framework; using Shouldly; -namespace SqlDatabase.PowerShell.Internal +namespace SqlDatabase.PowerShell.Internal; + +[TestFixture] +public class DependencyResolverFactoryTest { - [TestFixture] - public class DependencyResolverFactoryTest + [Test] + [TestCase("Desktop", typeof(PowerShellDesktopDependencyResolver))] + [TestCase(null, typeof(PowerShellDesktopDependencyResolver))] + [TestCase("Core", typeof(PowerShellCoreDependencyResolver))] + public void CreateProgram(string psEdition, Type expected) { - [Test] - [TestCase("Desktop", typeof(PowerShellDesktopDependencyResolver))] - [TestCase(null, typeof(PowerShellDesktopDependencyResolver))] - [TestCase("Core", typeof(PowerShellCoreDependencyResolver))] - public void CreateProgram(string psEdition, Type expected) + var psVersionTable = new Hashtable(); + if (psEdition != null) { - var psVersionTable = new Hashtable(); - if (psEdition != null) - { - psVersionTable.Add("PSEdition", psEdition); - } + psVersionTable.Add("PSEdition", psEdition); + } - var actual = DependencyResolverFactory.Create(new PSVersionTable(psVersionTable)); + var actual = DependencyResolverFactory.Create(new PSVersionTable(psVersionTable)); - actual.ShouldBeOfType(expected); - } + actual.ShouldBeOfType(expected); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell.Test/Internal/PowerShellCommandBaseTest.cs b/Sources/SqlDatabase.PowerShell.Test/Internal/PowerShellCommandBaseTest.cs index eef69600..bf524275 100644 --- a/Sources/SqlDatabase.PowerShell.Test/Internal/PowerShellCommandBaseTest.cs +++ b/Sources/SqlDatabase.PowerShell.Test/Internal/PowerShellCommandBaseTest.cs @@ -1,19 +1,18 @@ using NUnit.Framework; using SqlDatabase.Configuration; -namespace SqlDatabase.PowerShell.Internal +namespace SqlDatabase.PowerShell.Internal; + +[TestFixture] +public class PowerShellCommandBaseTest { - [TestFixture] - public class PowerShellCommandBaseTest + [Test] + public void AppendDefaultConfiguration() { - [Test] - public void AppendDefaultConfiguration() - { - var command = new GenericCommandLine(); + var command = new GenericCommandLine(); - PowerShellCommandBase.AppendDefaultConfiguration(command); + PowerShellCommandBase.AppendDefaultConfiguration(command); - FileAssert.Exists(command.ConfigurationFile); - } + FileAssert.Exists(command.ConfigurationFile); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell.Test/SqlDatabase.PowerShell.Test.csproj b/Sources/SqlDatabase.PowerShell.Test/SqlDatabase.PowerShell.Test.csproj index db1b7d5f..9917b25d 100644 --- a/Sources/SqlDatabase.PowerShell.Test/SqlDatabase.PowerShell.Test.csproj +++ b/Sources/SqlDatabase.PowerShell.Test/SqlDatabase.PowerShell.Test.csproj @@ -7,15 +7,15 @@ - - + + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/Sources/SqlDatabase.PowerShell.Test/TestApi/SqlDatabaseCmdLetTest.cs b/Sources/SqlDatabase.PowerShell.Test/TestApi/SqlDatabaseCmdLetTest.cs index 2b16d07e..7c3e756b 100644 --- a/Sources/SqlDatabase.PowerShell.Test/TestApi/SqlDatabaseCmdLetTest.cs +++ b/Sources/SqlDatabase.PowerShell.Test/TestApi/SqlDatabaseCmdLetTest.cs @@ -12,94 +12,93 @@ using SqlDatabase.PowerShell.Internal; using Command = System.Management.Automation.Runspaces.Command; -namespace SqlDatabase.PowerShell.TestApi +namespace SqlDatabase.PowerShell.TestApi; + +public abstract class SqlDatabaseCmdLetTest { - public abstract class SqlDatabaseCmdLetTest + private readonly IList _commandLines = new List(); + private Runspace _runSpace; + private System.Management.Automation.PowerShell _powerShell; + + [SetUp] + public void BeforeEachTest() { - private readonly IList _commandLines = new List(); - private Runspace _runSpace; - private System.Management.Automation.PowerShell _powerShell; + var sessionState = InitialSessionState.CreateDefault(); - [SetUp] - public void BeforeEachTest() + foreach (var alias in ResolveAliases()) { - var sessionState = InitialSessionState.CreateDefault(); + sessionState.Commands.Add(new SessionStateCmdletEntry(alias, typeof(TSubject), null)); + } - foreach (var alias in ResolveAliases()) - { - sessionState.Commands.Add(new SessionStateCmdletEntry(alias, typeof(TSubject), null)); - } + _runSpace = RunspaceFactory.CreateRunspace(sessionState); + _runSpace.Open(); - _runSpace = RunspaceFactory.CreateRunspace(sessionState); - _runSpace.Open(); + _powerShell = System.Management.Automation.PowerShell.Create(); + _powerShell.Runspace = _runSpace; - _powerShell = System.Management.Automation.PowerShell.Create(); - _powerShell.Runspace = _runSpace; + var program = new Mock(MockBehavior.Strict); + program + .Setup(p => p.ExecuteCommand(It.IsNotNull())) + .Callback(cmd => _commandLines.Add(cmd)); - var program = new Mock(MockBehavior.Strict); - program - .Setup(p => p.ExecuteCommand(It.IsNotNull())) - .Callback(cmd => _commandLines.Add(cmd)); + _commandLines.Clear(); + PowerShellCommandBase.Program = program.Object; + } - _commandLines.Clear(); - PowerShellCommandBase.Program = program.Object; - } + [TearDown] + public void AfterEachTest() + { + PowerShellCommandBase.Program = null; - [TearDown] - public void AfterEachTest() + foreach (var row in _powerShell.Streams.Information) { - PowerShellCommandBase.Program = null; - - foreach (var row in _powerShell.Streams.Information) - { - Console.WriteLine(row); - } - - _powerShell?.Dispose(); - _runSpace?.Dispose(); + Console.WriteLine(row); } - protected Collection InvokeCommand(string name) - { - var command = new Command(name); - _powerShell.Commands.AddCommand(command); + _powerShell?.Dispose(); + _runSpace?.Dispose(); + } - return _powerShell.Invoke(); - } + protected Collection InvokeCommand(string name) + { + var command = new Command(name); + _powerShell.Commands.AddCommand(command); - protected GenericCommandLine[] InvokeSqlDatabase(string name, Action builder) - { - return InvokeInvokeSqlDatabasePipeLine(name, builder); - } + return _powerShell.Invoke(); + } - protected GenericCommandLine[] InvokeInvokeSqlDatabasePipeLine(string name, Action builder, params object[] args) - { - _commandLines.Clear(); + protected GenericCommandLine[] InvokeSqlDatabase(string name, Action builder) + { + return InvokeInvokeSqlDatabasePipeLine(name, builder); + } - var command = new Command(name); - _powerShell.Commands.AddCommand(command); + protected GenericCommandLine[] InvokeInvokeSqlDatabasePipeLine(string name, Action builder, params object[] args) + { + _commandLines.Clear(); - builder(command); - _powerShell.Invoke(args); + var command = new Command(name); + _powerShell.Commands.AddCommand(command); - return _commandLines.ToArray(); - } + builder(command); + _powerShell.Invoke(args); - private static IEnumerable ResolveAliases() - { - var cmdlet = (CmdletAttribute)typeof(TSubject).GetCustomAttribute(typeof(CmdletAttribute)); - cmdlet.ShouldNotBeNull(); + return _commandLines.ToArray(); + } - yield return "{0}-{1}".FormatWith(cmdlet.VerbName, cmdlet.NounName); + private static IEnumerable ResolveAliases() + { + var cmdlet = (CmdletAttribute)typeof(TSubject).GetCustomAttribute(typeof(CmdletAttribute)); + cmdlet.ShouldNotBeNull(); + + yield return "{0}-{1}".FormatWith(cmdlet.VerbName, cmdlet.NounName); - var alias = (AliasAttribute)typeof(TSubject).GetCustomAttribute(typeof(AliasAttribute)); - if (alias != null) + var alias = (AliasAttribute)typeof(TSubject).GetCustomAttribute(typeof(AliasAttribute)); + if (alias != null) + { + foreach (var i in alias.AliasNames) { - foreach (var i in alias.AliasNames) - { - yield return i; - } + yield return i; } } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell.Test/UpgradeCmdLetTest.cs b/Sources/SqlDatabase.PowerShell.Test/UpgradeCmdLetTest.cs index f7085180..9ca0e54e 100644 --- a/Sources/SqlDatabase.PowerShell.Test/UpgradeCmdLetTest.cs +++ b/Sources/SqlDatabase.PowerShell.Test/UpgradeCmdLetTest.cs @@ -4,84 +4,83 @@ using SqlDatabase.Configuration; using SqlDatabase.PowerShell.TestApi; -namespace SqlDatabase.PowerShell +namespace SqlDatabase.PowerShell; + +[TestFixture] +public class UpgradeCmdLetTest : SqlDatabaseCmdLetTest { - [TestFixture] - public class UpgradeCmdLetTest : SqlDatabaseCmdLetTest + [Test] + [TestCase("Update-SqlDatabase")] + [TestCase("Upgrade-SqlDatabase")] + public void BuildCommandLine(string commandName) { - [Test] - [TestCase("Update-SqlDatabase")] - [TestCase("Upgrade-SqlDatabase")] - public void BuildCommandLine(string commandName) - { - var commandLines = InvokeSqlDatabase( - commandName, - c => - { - c.Parameters.Add(nameof(UpgradeCmdLet.Database), "connection string"); - c.Parameters.Add(nameof(UpgradeCmdLet.From), new[] { "file 1", "file 2" }); - c.Parameters.Add(nameof(UpgradeCmdLet.Transaction), TransactionMode.PerStep); - c.Parameters.Add(nameof(UpgradeCmdLet.Configuration), "app.config"); - c.Parameters.Add(nameof(UpgradeCmdLet.Var), new[] { "x=1", "y=2" }); - c.Parameters.Add(nameof(UpgradeCmdLet.WhatIf)); - c.Parameters.Add(nameof(UpgradeCmdLet.FolderAsModuleName)); - c.Parameters.Add(nameof(CreateCmdLet.Log), "log.txt"); - }); + var commandLines = InvokeSqlDatabase( + commandName, + c => + { + c.Parameters.Add(nameof(UpgradeCmdLet.Database), "connection string"); + c.Parameters.Add(nameof(UpgradeCmdLet.From), new[] { "file 1", "file 2" }); + c.Parameters.Add(nameof(UpgradeCmdLet.Transaction), TransactionMode.PerStep); + c.Parameters.Add(nameof(UpgradeCmdLet.Configuration), "app.config"); + c.Parameters.Add(nameof(UpgradeCmdLet.Var), new[] { "x=1", "y=2" }); + c.Parameters.Add(nameof(UpgradeCmdLet.WhatIf)); + c.Parameters.Add(nameof(UpgradeCmdLet.FolderAsModuleName)); + c.Parameters.Add(nameof(CreateCmdLet.Log), "log.txt"); + }); - commandLines.Length.ShouldBe(1); - var commandLine = commandLines[0]; + commandLines.Length.ShouldBe(1); + var commandLine = commandLines[0]; - commandLine.Command.ShouldBe(CommandLineFactory.CommandUpgrade); - commandLine.Connection.ShouldBe("connection string"); + commandLine.Command.ShouldBe(CommandLineFactory.CommandUpgrade); + commandLine.Connection.ShouldBe("connection string"); - commandLine.Scripts.Count.ShouldBe(2); - Path.IsPathRooted(commandLine.Scripts[0]).ShouldBeTrue(); - Path.GetFileName(commandLine.Scripts[0]).ShouldBe("file 1"); - Path.IsPathRooted(commandLine.Scripts[1]).ShouldBeTrue(); - Path.GetFileName(commandLine.Scripts[1]).ShouldBe("file 2"); + commandLine.Scripts.Count.ShouldBe(2); + Path.IsPathRooted(commandLine.Scripts[0]).ShouldBeTrue(); + Path.GetFileName(commandLine.Scripts[0]).ShouldBe("file 1"); + Path.IsPathRooted(commandLine.Scripts[1]).ShouldBeTrue(); + Path.GetFileName(commandLine.Scripts[1]).ShouldBe("file 2"); - commandLine.Transaction.ShouldBe(TransactionMode.PerStep); + commandLine.Transaction.ShouldBe(TransactionMode.PerStep); - Path.IsPathRooted(commandLine.ConfigurationFile).ShouldBeTrue(); - Path.GetFileName(commandLine.ConfigurationFile).ShouldBe("app.config"); + Path.IsPathRooted(commandLine.ConfigurationFile).ShouldBeTrue(); + Path.GetFileName(commandLine.ConfigurationFile).ShouldBe("app.config"); - Path.IsPathRooted(commandLine.LogFileName).ShouldBeTrue(); - Path.GetFileName(commandLine.LogFileName).ShouldBe("log.txt"); + Path.IsPathRooted(commandLine.LogFileName).ShouldBeTrue(); + Path.GetFileName(commandLine.LogFileName).ShouldBe("log.txt"); - commandLine.WhatIf.ShouldBeTrue(); - commandLine.FolderAsModuleName.ShouldBeTrue(); + commandLine.WhatIf.ShouldBeTrue(); + commandLine.FolderAsModuleName.ShouldBeTrue(); - commandLine.Variables.Keys.ShouldBe(new[] { "x", "y" }); - commandLine.Variables["x"].ShouldBe("1"); - commandLine.Variables["y"].ShouldBe("2"); - } + commandLine.Variables.Keys.ShouldBe(new[] { "x", "y" }); + commandLine.Variables["x"].ShouldBe("1"); + commandLine.Variables["y"].ShouldBe("2"); + } - [Test] - [TestCase("Update-SqlDatabase")] - [TestCase("Upgrade-SqlDatabase")] - public void BuildPipeCommandLine(string commandName) - { - var commandLines = InvokeInvokeSqlDatabasePipeLine( - commandName, - c => c.Parameters.Add(nameof(UpgradeCmdLet.Database), "connection string"), - "file 1", - "file 2"); + [Test] + [TestCase("Update-SqlDatabase")] + [TestCase("Upgrade-SqlDatabase")] + public void BuildPipeCommandLine(string commandName) + { + var commandLines = InvokeInvokeSqlDatabasePipeLine( + commandName, + c => c.Parameters.Add(nameof(UpgradeCmdLet.Database), "connection string"), + "file 1", + "file 2"); - commandLines.Length.ShouldBe(2); + commandLines.Length.ShouldBe(2); - commandLines[0].Command.ShouldBe(CommandLineFactory.CommandUpgrade); - commandLines[0].Connection.ShouldBe("connection string"); - commandLines[0].Scripts.Count.ShouldBe(1); - Path.IsPathRooted(commandLines[0].Scripts[0]).ShouldBeTrue(); - Path.GetFileName(commandLines[0].Scripts[0]).ShouldBe("file 1"); - commandLines[0].InLineScript.Count.ShouldBe(0); + commandLines[0].Command.ShouldBe(CommandLineFactory.CommandUpgrade); + commandLines[0].Connection.ShouldBe("connection string"); + commandLines[0].Scripts.Count.ShouldBe(1); + Path.IsPathRooted(commandLines[0].Scripts[0]).ShouldBeTrue(); + Path.GetFileName(commandLines[0].Scripts[0]).ShouldBe("file 1"); + commandLines[0].InLineScript.Count.ShouldBe(0); - commandLines[1].Command.ShouldBe(CommandLineFactory.CommandUpgrade); - commandLines[1].Connection.ShouldBe("connection string"); - commandLines[1].Scripts.Count.ShouldBe(1); - Path.IsPathRooted(commandLines[1].Scripts[0]).ShouldBeTrue(); - Path.GetFileName(commandLines[1].Scripts[0]).ShouldBe("file 2"); - commandLines[1].InLineScript.Count.ShouldBe(0); - } + commandLines[1].Command.ShouldBe(CommandLineFactory.CommandUpgrade); + commandLines[1].Connection.ShouldBe("connection string"); + commandLines[1].Scripts.Count.ShouldBe(1); + Path.IsPathRooted(commandLines[1].Scripts[0]).ShouldBeTrue(); + Path.GetFileName(commandLines[1].Scripts[0]).ShouldBe("file 2"); + commandLines[1].InLineScript.Count.ShouldBe(0); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/CreateCmdLet.cs b/Sources/SqlDatabase.PowerShell/CreateCmdLet.cs index 9a850883..f66c2d0b 100644 --- a/Sources/SqlDatabase.PowerShell/CreateCmdLet.cs +++ b/Sources/SqlDatabase.PowerShell/CreateCmdLet.cs @@ -2,37 +2,36 @@ using SqlDatabase.Configuration; using SqlDatabase.PowerShell.Internal; -namespace SqlDatabase.PowerShell +namespace SqlDatabase.PowerShell; + +[Cmdlet(VerbsCommon.New, "SqlDatabase")] +[Alias(CommandLineFactory.CommandCreate + "-SqlDatabase")] +public sealed class CreateCmdLet : PSCmdlet { - [Cmdlet(VerbsCommon.New, "SqlDatabase")] - [Alias(CommandLineFactory.CommandCreate + "-SqlDatabase")] - public sealed class CreateCmdLet : PSCmdlet - { - [Parameter(Mandatory = true, Position = 1, HelpMessage = "Connection string to target database.")] - [Alias("d")] - public string Database { get; set; } + [Parameter(Mandatory = true, Position = 1, HelpMessage = "Connection string to target database.")] + [Alias("d")] + public string Database { get; set; } - [Parameter(Mandatory = true, Position = 2, ValueFromPipeline = true, HelpMessage = "A path to a folder or zip archive with sql scripts or path to a sql script file. Repeat -from to setup several sources.")] - [Alias("f")] - public string[] From { get; set; } + [Parameter(Mandatory = true, Position = 2, ValueFromPipeline = true, HelpMessage = "A path to a folder or zip archive with sql scripts or path to a sql script file. Repeat -from to setup several sources.")] + [Alias("f")] + public string[] From { get; set; } - [Parameter(Position = 3, HelpMessage = "A path to application configuration file. Default is current SqlDatabase.exe.config.")] - [Alias("c")] - public string Configuration { get; set; } + [Parameter(Position = 3, HelpMessage = "A path to application configuration file. Default is current SqlDatabase.exe.config.")] + [Alias("c")] + public string Configuration { get; set; } - [Parameter(Position = 4, HelpMessage = "Shows what would happen if the command runs. The command is not run.")] - public SwitchParameter WhatIf { get; set; } + [Parameter(Position = 4, HelpMessage = "Shows what would happen if the command runs. The command is not run.")] + public SwitchParameter WhatIf { get; set; } - [Parameter(ValueFromRemainingArguments = true, HelpMessage = "Set a variable in format \"[name of variable]=[value of variable]\".")] - [Alias("v")] - public string[] Var { get; set; } + [Parameter(ValueFromRemainingArguments = true, HelpMessage = "Set a variable in format \"[name of variable]=[value of variable]\".")] + [Alias("v")] + public string[] Var { get; set; } - [Parameter(HelpMessage = "Optional path to log file.")] - public string Log { get; set; } + [Parameter(HelpMessage = "Optional path to log file.")] + public string Log { get; set; } - protected override void ProcessRecord() - { - new CreatePowerShellCommand(this).Execute(); - } + protected override void ProcessRecord() + { + new CreatePowerShellCommand(this).Execute(); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/ExecuteCmdLet.cs b/Sources/SqlDatabase.PowerShell/ExecuteCmdLet.cs index 39539d43..0dcba5bd 100644 --- a/Sources/SqlDatabase.PowerShell/ExecuteCmdLet.cs +++ b/Sources/SqlDatabase.PowerShell/ExecuteCmdLet.cs @@ -2,45 +2,44 @@ using SqlDatabase.Configuration; using SqlDatabase.PowerShell.Internal; -namespace SqlDatabase.PowerShell +namespace SqlDatabase.PowerShell; + +[Cmdlet(VerbsLifecycle.Invoke, "SqlDatabase")] +[Alias(CommandLineFactory.CommandExecute + "-SqlDatabase")] +public sealed class ExecuteCmdLet : PSCmdlet { - [Cmdlet(VerbsLifecycle.Invoke, "SqlDatabase")] - [Alias(CommandLineFactory.CommandExecute + "-SqlDatabase")] - public sealed class ExecuteCmdLet : PSCmdlet - { - [Parameter(Mandatory = true, Position = 1, HelpMessage = "Connection string to target database.")] - [Alias("d")] - public string Database { get; set; } + [Parameter(Mandatory = true, Position = 1, HelpMessage = "Connection string to target database.")] + [Alias("d")] + public string Database { get; set; } - [Parameter(Position = 2, ValueFromPipeline = true, HelpMessage = "A path to a folder or zip archive with sql scripts or path to a sql script file. Repeat -from to setup several sources.")] - [Alias("f")] - public string[] From { get; set; } + [Parameter(Position = 2, ValueFromPipeline = true, HelpMessage = "A path to a folder or zip archive with sql scripts or path to a sql script file. Repeat -from to setup several sources.")] + [Alias("f")] + public string[] From { get; set; } - [Parameter(HelpMessage = "An sql script text. Repeat -fromSql to setup several scripts.")] - [Alias("s")] - public string[] FromSql { get; set; } + [Parameter(HelpMessage = "An sql script text. Repeat -fromSql to setup several scripts.")] + [Alias("s")] + public string[] FromSql { get; set; } - [Parameter(Position = 3, HelpMessage = "Transaction mode. Possible values: none, perStep. Default is none.")] - [Alias("t")] - public PSTransactionMode Transaction { get; set; } + [Parameter(Position = 3, HelpMessage = "Transaction mode. Possible values: none, perStep. Default is none.")] + [Alias("t")] + public PSTransactionMode Transaction { get; set; } - [Parameter(Position = 4, HelpMessage = "A path to application configuration file. Default is current SqlDatabase.exe.config.")] - [Alias("c")] - public string Configuration { get; set; } + [Parameter(Position = 4, HelpMessage = "A path to application configuration file. Default is current SqlDatabase.exe.config.")] + [Alias("c")] + public string Configuration { get; set; } - [Parameter(Position = 5, HelpMessage = "Shows what would happen if the command runs. The command is not run.")] - public SwitchParameter WhatIf { get; set; } + [Parameter(Position = 5, HelpMessage = "Shows what would happen if the command runs. The command is not run.")] + public SwitchParameter WhatIf { get; set; } - [Parameter(ValueFromRemainingArguments = true, HelpMessage = "Set a variable in format \"[name of variable]=[value of variable]\".")] - [Alias("v")] - public string[] Var { get; set; } + [Parameter(ValueFromRemainingArguments = true, HelpMessage = "Set a variable in format \"[name of variable]=[value of variable]\".")] + [Alias("v")] + public string[] Var { get; set; } - [Parameter(HelpMessage = "Optional path to log file.")] - public string Log { get; set; } + [Parameter(HelpMessage = "Optional path to log file.")] + public string Log { get; set; } - protected override void ProcessRecord() - { - new ExecutePowerShellCommand(this).Execute(); - } + protected override void ProcessRecord() + { + new ExecutePowerShellCommand(this).Execute(); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/ExportCmdLet.cs b/Sources/SqlDatabase.PowerShell/ExportCmdLet.cs index bf4e1295..78a37db8 100644 --- a/Sources/SqlDatabase.PowerShell/ExportCmdLet.cs +++ b/Sources/SqlDatabase.PowerShell/ExportCmdLet.cs @@ -1,43 +1,42 @@ using System.Management.Automation; using SqlDatabase.PowerShell.Internal; -namespace SqlDatabase.PowerShell +namespace SqlDatabase.PowerShell; + +[Cmdlet(VerbsData.Export, "SqlDatabase")] +public sealed class ExportCmdLet : PSCmdlet { - [Cmdlet(VerbsData.Export, "SqlDatabase")] - public sealed class ExportCmdLet : PSCmdlet - { - [Parameter(Mandatory = true, Position = 1, HelpMessage = "Connection string to target database.")] - [Alias("d")] - public string Database { get; set; } + [Parameter(Mandatory = true, Position = 1, HelpMessage = "Connection string to target database.")] + [Alias("d")] + public string Database { get; set; } - [Parameter(Position = 2, HelpMessage = "An sql script to select export data. Repeat -fromSql to setup several scripts.")] - [Alias("s")] - public string[] FromSql { get; set; } + [Parameter(Position = 2, HelpMessage = "An sql script to select export data. Repeat -fromSql to setup several scripts.")] + [Alias("s")] + public string[] FromSql { get; set; } - [Parameter(HelpMessage = "A path to a folder or zip archive with sql scripts or path to a sql script file. Repeat -from to setup several sources.")] - [Alias("f")] - public string[] From { get; set; } + [Parameter(HelpMessage = "A path to a folder or zip archive with sql scripts or path to a sql script file. Repeat -from to setup several sources.")] + [Alias("f")] + public string[] From { get; set; } - [Parameter(Position = 3, HelpMessage = "Write sql scripts into a file. By default write into information stream.")] - public string ToFile { get; set; } + [Parameter(Position = 3, HelpMessage = "Write sql scripts into a file. By default write into information stream.")] + public string ToFile { get; set; } - [Parameter(Position = 4, HelpMessage = "A path to application configuration file. Default is current SqlDatabase.exe.config.")] - [Alias("c")] - public string Configuration { get; set; } + [Parameter(Position = 4, HelpMessage = "A path to application configuration file. Default is current SqlDatabase.exe.config.")] + [Alias("c")] + public string Configuration { get; set; } - [Parameter(HelpMessage = "Setup \"INSERT INTO\" table name. Default is dbo.SqlDatabaseExport.")] - public string ToTable { get; set; } + [Parameter(HelpMessage = "Setup \"INSERT INTO\" table name. Default is dbo.SqlDatabaseExport.")] + public string ToTable { get; set; } - [Parameter(ValueFromRemainingArguments = true, HelpMessage = "Set a variable in format \"[name of variable]=[value of variable]\".")] - [Alias("v")] - public string[] Var { get; set; } + [Parameter(ValueFromRemainingArguments = true, HelpMessage = "Set a variable in format \"[name of variable]=[value of variable]\".")] + [Alias("v")] + public string[] Var { get; set; } - [Parameter(HelpMessage = "Optional path to log file.")] - public string Log { get; set; } + [Parameter(HelpMessage = "Optional path to log file.")] + public string Log { get; set; } - protected override void ProcessRecord() - { - new ExportPowerShellCommand(this).Execute(); - } + protected override void ProcessRecord() + { + new ExportPowerShellCommand(this).Execute(); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/InfoCmdLet.cs b/Sources/SqlDatabase.PowerShell/InfoCmdLet.cs index 7bda9ee3..c6e0b05f 100644 --- a/Sources/SqlDatabase.PowerShell/InfoCmdLet.cs +++ b/Sources/SqlDatabase.PowerShell/InfoCmdLet.cs @@ -4,40 +4,39 @@ using SqlDatabase.Configuration; using SqlDatabase.PowerShell.Internal; -namespace SqlDatabase.PowerShell +namespace SqlDatabase.PowerShell; + +[Cmdlet(VerbsCommon.Show, "SqlDatabaseInfo")] +public sealed class InfoCmdLet : PSCmdlet { - [Cmdlet(VerbsCommon.Show, "SqlDatabaseInfo")] - public sealed class InfoCmdLet : PSCmdlet + protected override void ProcessRecord() { - protected override void ProcessRecord() + using (var resolver = DependencyResolverFactory.Create(this)) { - using (var resolver = DependencyResolverFactory.Create(this)) - { - resolver.Initialize(); - WriteInfo(); - } + resolver.Initialize(); + WriteInfo(); } + } - private void WriteInfo() - { - var assembly = GetType().Assembly; - var location = Path.GetDirectoryName(assembly.Location); + private void WriteInfo() + { + var assembly = GetType().Assembly; + var location = Path.GetDirectoryName(assembly.Location); - this.TryGetPSVersionTable(out var psVersionTable); + this.TryGetPSVersionTable(out var psVersionTable); - WriteObject(new - { - psVersionTable.PSEdition, - psVersionTable.PSVersion, - Version = assembly.GetName().Version, - RuntimeInformation.FrameworkDescription, - RuntimeInformation.OSDescription, - RuntimeInformation.OSArchitecture, - RuntimeInformation.ProcessArchitecture, - Location = location, - WorkingDirectory = this.GetWorkingDirectory(), - DefaultConfigurationFile = ConfigurationManager.ResolveDefaultConfigurationFile(location) - }); - } + WriteObject(new + { + psVersionTable.PSEdition, + psVersionTable.PSVersion, + Version = assembly.GetName().Version, + RuntimeInformation.FrameworkDescription, + RuntimeInformation.OSDescription, + RuntimeInformation.OSArchitecture, + RuntimeInformation.ProcessArchitecture, + Location = location, + WorkingDirectory = this.GetWorkingDirectory(), + DefaultConfigurationFile = ConfigurationManager.ResolveDefaultConfigurationFile(location) + }); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/Internal/AssemblyCache.cs b/Sources/SqlDatabase.PowerShell/Internal/AssemblyCache.cs index 85f72da6..53fb0f2c 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/AssemblyCache.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/AssemblyCache.cs @@ -3,55 +3,54 @@ using System.IO; using System.Reflection; -namespace SqlDatabase.PowerShell.Internal +namespace SqlDatabase.PowerShell.Internal; + +internal sealed class AssemblyCache : IDisposable { - internal sealed class AssemblyCache : IDisposable - { - private readonly string[] _probingPaths; - private readonly IDictionary _assemblyByName; + private readonly string[] _probingPaths; + private readonly IDictionary _assemblyByName; - public AssemblyCache(params string[] probingPaths) + public AssemblyCache(params string[] probingPaths) + { + _probingPaths = new string[probingPaths.Length + 1]; + _probingPaths[0] = Path.GetDirectoryName(GetType().Assembly.Location); + for (var i = 0; i < probingPaths.Length; i++) { - _probingPaths = new string[probingPaths.Length + 1]; - _probingPaths[0] = Path.GetDirectoryName(GetType().Assembly.Location); - for (var i = 0; i < probingPaths.Length; i++) - { - _probingPaths[i + 1] = probingPaths[i]; - } - - _assemblyByName = new Dictionary(StringComparer.OrdinalIgnoreCase); + _probingPaths[i + 1] = probingPaths[i]; } - public Assembly Load(AssemblyName assemblyName, Func loader) - { - var fileName = assemblyName.Name + ".dll"; - if (_assemblyByName.TryGetValue(fileName, out var assembly)) - { - return assembly; - } + _assemblyByName = new Dictionary(StringComparer.OrdinalIgnoreCase); + } - assembly = TryFindAndLoad(fileName, loader); - _assemblyByName[fileName] = assembly; + public Assembly Load(AssemblyName assemblyName, Func loader) + { + var fileName = assemblyName.Name + ".dll"; + if (_assemblyByName.TryGetValue(fileName, out var assembly)) + { return assembly; } - public void Dispose() - { - _assemblyByName.Clear(); - } + assembly = TryFindAndLoad(fileName, loader); + _assemblyByName[fileName] = assembly; + return assembly; + } + + public void Dispose() + { + _assemblyByName.Clear(); + } - private Assembly TryFindAndLoad(string fileName, Func loader) + private Assembly TryFindAndLoad(string fileName, Func loader) + { + for (var i = 0; i < _probingPaths.Length; i++) { - for (var i = 0; i < _probingPaths.Length; i++) + var path = Path.Combine(_probingPaths[i], fileName); + if (File.Exists(path)) { - var path = Path.Combine(_probingPaths[i], fileName); - if (File.Exists(path)) - { - return loader(path); - } + return loader(path); } - - return null; } + + return null; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/Internal/CmdLetLogger.cs b/Sources/SqlDatabase.PowerShell/Internal/CmdLetLogger.cs index ceb0e9e0..3977da0f 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/CmdLetLogger.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/CmdLetLogger.cs @@ -2,29 +2,28 @@ using System.Management.Automation; using SqlDatabase.Log; -namespace SqlDatabase.PowerShell.Internal +namespace SqlDatabase.PowerShell.Internal; + +internal sealed class CmdLetLogger : LoggerBase { - internal sealed class CmdLetLogger : LoggerBase - { - private readonly Cmdlet _cmdlet; + private readonly Cmdlet _cmdlet; - public CmdLetLogger(Cmdlet cmdlet) - { - _cmdlet = cmdlet; - } + public CmdLetLogger(Cmdlet cmdlet) + { + _cmdlet = cmdlet; + } - protected override void WriteError(string message) - { - _cmdlet.WriteError(new ErrorRecord( - new InvalidOperationException(message), - null, - ErrorCategory.NotSpecified, - null)); - } + protected override void WriteError(string message) + { + _cmdlet.WriteError(new ErrorRecord( + new InvalidOperationException(message), + null, + ErrorCategory.NotSpecified, + null)); + } - protected override void WriteInfo(string message) - { - _cmdlet.WriteInformation(new InformationRecord(message, null)); - } + protected override void WriteInfo(string message) + { + _cmdlet.WriteInformation(new InformationRecord(message, null)); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/Internal/CmdletExtensions.cs b/Sources/SqlDatabase.PowerShell/Internal/CmdletExtensions.cs index 15277ce2..66c48a99 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/CmdletExtensions.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/CmdletExtensions.cs @@ -2,53 +2,52 @@ using System.Management.Automation; using SqlDatabase.Configuration; -namespace SqlDatabase.PowerShell.Internal +namespace SqlDatabase.PowerShell.Internal; + +internal static class CmdletExtensions { - internal static class CmdletExtensions + public static string GetWorkingDirectory(this PSCmdlet cmdlet) { - public static string GetWorkingDirectory(this PSCmdlet cmdlet) + var root = cmdlet.MyInvocation.PSScriptRoot; + if (string.IsNullOrEmpty(root)) { - var root = cmdlet.MyInvocation.PSScriptRoot; - if (string.IsNullOrEmpty(root)) - { - root = cmdlet.CurrentProviderLocation("FileSystem").ProviderPath; - } - - return root; + root = cmdlet.CurrentProviderLocation("FileSystem").ProviderPath; } - public static string RootPath(this PSCmdlet cmdlet, string path) - { - if (string.IsNullOrEmpty(path) || Path.IsPathRooted(path)) - { - return path; - } + return root; + } - return Path.Combine(GetWorkingDirectory(cmdlet), path); + public static string RootPath(this PSCmdlet cmdlet, string path) + { + if (string.IsNullOrEmpty(path) || Path.IsPathRooted(path)) + { + return path; } - public static bool TryGetPSVersionTable(this PSCmdlet cmdlet, out PSVersionTable value) - { - var psVersionTable = cmdlet.GetVariableValue("PSVersionTable"); - if (psVersionTable == null) - { - value = default; - return false; - } + return Path.Combine(GetWorkingDirectory(cmdlet), path); + } - value = new PSVersionTable(psVersionTable); - return true; + public static bool TryGetPSVersionTable(this PSCmdlet cmdlet, out PSVersionTable value) + { + var psVersionTable = cmdlet.GetVariableValue("PSVersionTable"); + if (psVersionTable == null) + { + value = default; + return false; } - public static void AppendFrom(this PSCmdlet cmdlet, string[] from, GenericCommandLineBuilder target) + value = new PSVersionTable(psVersionTable); + return true; + } + + public static void AppendFrom(this PSCmdlet cmdlet, string[] from, GenericCommandLineBuilder target) + { + if (from != null) { - if (from != null) + for (var i = 0; i < from.Length; i++) { - for (var i = 0; i < from.Length; i++) - { - target.SetScripts(cmdlet.RootPath(from[i])); - } + target.SetScripts(cmdlet.RootPath(from[i])); } } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/Internal/CreatePowerShellCommand.cs b/Sources/SqlDatabase.PowerShell/Internal/CreatePowerShellCommand.cs index d4f43832..cd33cba2 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/CreatePowerShellCommand.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/CreatePowerShellCommand.cs @@ -1,36 +1,35 @@ using SqlDatabase.Configuration; -namespace SqlDatabase.PowerShell.Internal +namespace SqlDatabase.PowerShell.Internal; + +internal sealed class CreatePowerShellCommand : PowerShellCommandBase { - internal sealed class CreatePowerShellCommand : PowerShellCommandBase + public CreatePowerShellCommand(CreateCmdLet cmdlet) + : base(cmdlet) { - public CreatePowerShellCommand(CreateCmdLet cmdlet) - : base(cmdlet) - { - } + } - public new CreateCmdLet Cmdlet => (CreateCmdLet)base.Cmdlet; + public new CreateCmdLet Cmdlet => (CreateCmdLet)base.Cmdlet; - protected override void BuildCommandLine(GenericCommandLineBuilder builder) - { - builder - .SetCommand(CommandLineFactory.CommandCreate) - .SetConnection(Cmdlet.Database) - .SetLogFileName(Cmdlet.RootPath(Cmdlet.Log)); + protected override void BuildCommandLine(GenericCommandLineBuilder builder) + { + builder + .SetCommand(CommandLineFactory.CommandCreate) + .SetConnection(Cmdlet.Database) + .SetLogFileName(Cmdlet.RootPath(Cmdlet.Log)); - if (Cmdlet.Var != null) + if (Cmdlet.Var != null) + { + for (var i = 0; i < Cmdlet.Var.Length; i++) { - for (var i = 0; i < Cmdlet.Var.Length; i++) - { - builder.SetVariable(Cmdlet.Var[i]); - } + builder.SetVariable(Cmdlet.Var[i]); } + } - Cmdlet.AppendFrom(Cmdlet.From, builder); + Cmdlet.AppendFrom(Cmdlet.From, builder); - builder - .SetConfigurationFile(Cmdlet.RootPath(Cmdlet.Configuration)) - .SetWhatIf(Cmdlet.WhatIf); - } + builder + .SetConfigurationFile(Cmdlet.RootPath(Cmdlet.Configuration)) + .SetWhatIf(Cmdlet.WhatIf); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/Internal/DependencyResolverFactory.cs b/Sources/SqlDatabase.PowerShell/Internal/DependencyResolverFactory.cs index dee89fd1..d5b95449 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/DependencyResolverFactory.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/DependencyResolverFactory.cs @@ -1,29 +1,28 @@ using System; using System.Management.Automation; -namespace SqlDatabase.PowerShell.Internal +namespace SqlDatabase.PowerShell.Internal; + +internal static class DependencyResolverFactory { - internal static class DependencyResolverFactory + public static IDependencyResolver Create(PSCmdlet cmdlet) { - public static IDependencyResolver Create(PSCmdlet cmdlet) + if (!cmdlet.TryGetPSVersionTable(out var psVersionTable)) { - if (!cmdlet.TryGetPSVersionTable(out var psVersionTable)) - { - throw new PlatformNotSupportedException("$PSVersionTable is not defined."); - } - - return Create(psVersionTable); + throw new PlatformNotSupportedException("$PSVersionTable is not defined."); } - internal static IDependencyResolver Create(PSVersionTable psVersionTable) - { - // In PowerShell 4 and below, this variable does not exist - if (string.IsNullOrEmpty(psVersionTable.PSEdition) || "Desktop".Equals(psVersionTable.PSEdition, StringComparison.OrdinalIgnoreCase)) - { - return new PowerShellDesktopDependencyResolver(); - } + return Create(psVersionTable); + } - return new PowerShellCoreDependencyResolver(); + internal static IDependencyResolver Create(PSVersionTable psVersionTable) + { + // In PowerShell 4 and below, this variable does not exist + if (string.IsNullOrEmpty(psVersionTable.PSEdition) || "Desktop".Equals(psVersionTable.PSEdition, StringComparison.OrdinalIgnoreCase)) + { + return new PowerShellDesktopDependencyResolver(); } + + return new PowerShellCoreDependencyResolver(); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/Internal/ExecutePowerShellCommand.cs b/Sources/SqlDatabase.PowerShell/Internal/ExecutePowerShellCommand.cs index 14588671..06bdebf4 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/ExecutePowerShellCommand.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/ExecutePowerShellCommand.cs @@ -1,45 +1,44 @@ using SqlDatabase.Configuration; -namespace SqlDatabase.PowerShell.Internal +namespace SqlDatabase.PowerShell.Internal; + +internal sealed class ExecutePowerShellCommand : PowerShellCommandBase { - internal sealed class ExecutePowerShellCommand : PowerShellCommandBase + public ExecutePowerShellCommand(ExecuteCmdLet cmdLet) + : base(cmdLet) { - public ExecutePowerShellCommand(ExecuteCmdLet cmdLet) - : base(cmdLet) - { - } + } - public new ExecuteCmdLet Cmdlet => (ExecuteCmdLet)base.Cmdlet; + public new ExecuteCmdLet Cmdlet => (ExecuteCmdLet)base.Cmdlet; - protected override void BuildCommandLine(GenericCommandLineBuilder builder) - { - builder - .SetCommand(CommandLineFactory.CommandExecute) - .SetConnection(Cmdlet.Database) - .SetLogFileName(Cmdlet.RootPath(Cmdlet.Log)); + protected override void BuildCommandLine(GenericCommandLineBuilder builder) + { + builder + .SetCommand(CommandLineFactory.CommandExecute) + .SetConnection(Cmdlet.Database) + .SetLogFileName(Cmdlet.RootPath(Cmdlet.Log)); - if (Cmdlet.Var != null) + if (Cmdlet.Var != null) + { + for (var i = 0; i < Cmdlet.Var.Length; i++) { - for (var i = 0; i < Cmdlet.Var.Length; i++) - { - builder.SetVariable(Cmdlet.Var[i]); - } + builder.SetVariable(Cmdlet.Var[i]); } + } - Cmdlet.AppendFrom(Cmdlet.From, builder); + Cmdlet.AppendFrom(Cmdlet.From, builder); - if (Cmdlet.FromSql != null) + if (Cmdlet.FromSql != null) + { + for (var i = 0; i < Cmdlet.FromSql.Length; i++) { - for (var i = 0; i < Cmdlet.FromSql.Length; i++) - { - builder.SetInLineScript(Cmdlet.FromSql[i]); - } + builder.SetInLineScript(Cmdlet.FromSql[i]); } - - builder - .SetTransaction((TransactionMode)Cmdlet.Transaction) - .SetConfigurationFile(Cmdlet.RootPath(Cmdlet.Configuration)) - .SetWhatIf(Cmdlet.WhatIf); } + + builder + .SetTransaction((TransactionMode)Cmdlet.Transaction) + .SetConfigurationFile(Cmdlet.RootPath(Cmdlet.Configuration)) + .SetWhatIf(Cmdlet.WhatIf); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/Internal/ExportPowerShellCommand.cs b/Sources/SqlDatabase.PowerShell/Internal/ExportPowerShellCommand.cs index 1a8aacca..d54ccc1f 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/ExportPowerShellCommand.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/ExportPowerShellCommand.cs @@ -1,45 +1,44 @@ using SqlDatabase.Configuration; -namespace SqlDatabase.PowerShell.Internal +namespace SqlDatabase.PowerShell.Internal; + +internal sealed class ExportPowerShellCommand : PowerShellCommandBase { - internal sealed class ExportPowerShellCommand : PowerShellCommandBase + public ExportPowerShellCommand(ExportCmdLet cmdLet) + : base(cmdLet) { - public ExportPowerShellCommand(ExportCmdLet cmdLet) - : base(cmdLet) - { - } + } - public new ExportCmdLet Cmdlet => (ExportCmdLet)base.Cmdlet; + public new ExportCmdLet Cmdlet => (ExportCmdLet)base.Cmdlet; - protected override void BuildCommandLine(GenericCommandLineBuilder builder) - { - builder - .SetCommand(CommandLineFactory.CommandExport) - .SetConnection(Cmdlet.Database) - .SetLogFileName(Cmdlet.RootPath(Cmdlet.Log)); + protected override void BuildCommandLine(GenericCommandLineBuilder builder) + { + builder + .SetCommand(CommandLineFactory.CommandExport) + .SetConnection(Cmdlet.Database) + .SetLogFileName(Cmdlet.RootPath(Cmdlet.Log)); - if (Cmdlet.Var != null) + if (Cmdlet.Var != null) + { + for (var i = 0; i < Cmdlet.Var.Length; i++) { - for (var i = 0; i < Cmdlet.Var.Length; i++) - { - builder.SetVariable(Cmdlet.Var[i]); - } + builder.SetVariable(Cmdlet.Var[i]); } + } - Cmdlet.AppendFrom(Cmdlet.From, builder); + Cmdlet.AppendFrom(Cmdlet.From, builder); - if (Cmdlet.FromSql != null) + if (Cmdlet.FromSql != null) + { + for (var i = 0; i < Cmdlet.FromSql.Length; i++) { - for (var i = 0; i < Cmdlet.FromSql.Length; i++) - { - builder.SetInLineScript(Cmdlet.FromSql[i]); - } + builder.SetInLineScript(Cmdlet.FromSql[i]); } - - builder - .SetConfigurationFile(Cmdlet.RootPath(Cmdlet.Configuration)) - .SetExportToTable(Cmdlet.ToTable) - .SetExportToFile(Cmdlet.ToFile); } + + builder + .SetConfigurationFile(Cmdlet.RootPath(Cmdlet.Configuration)) + .SetExportToTable(Cmdlet.ToTable) + .SetExportToFile(Cmdlet.ToFile); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/Internal/IDependencyResolver.cs b/Sources/SqlDatabase.PowerShell/Internal/IDependencyResolver.cs index a1be125d..a84005ad 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/IDependencyResolver.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/IDependencyResolver.cs @@ -1,9 +1,8 @@ using System; -namespace SqlDatabase.PowerShell.Internal +namespace SqlDatabase.PowerShell.Internal; + +internal interface IDependencyResolver : IDisposable { - internal interface IDependencyResolver : IDisposable - { - void Initialize(); - } -} + void Initialize(); +} \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/Internal/ISqlDatabaseProgram.cs b/Sources/SqlDatabase.PowerShell/Internal/ISqlDatabaseProgram.cs index 06956368..3039537d 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/ISqlDatabaseProgram.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/ISqlDatabaseProgram.cs @@ -1,9 +1,8 @@ using SqlDatabase.Configuration; -namespace SqlDatabase.PowerShell.Internal +namespace SqlDatabase.PowerShell.Internal; + +internal interface ISqlDatabaseProgram { - internal interface ISqlDatabaseProgram - { - void ExecuteCommand(GenericCommandLine command); - } + void ExecuteCommand(GenericCommandLine command); } \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/Internal/PSVersionTable.cs b/Sources/SqlDatabase.PowerShell/Internal/PSVersionTable.cs index c4c68bd8..4c44dbb2 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/PSVersionTable.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/PSVersionTable.cs @@ -1,33 +1,32 @@ using System; using System.Collections; -namespace SqlDatabase.PowerShell.Internal +namespace SqlDatabase.PowerShell.Internal; + +internal readonly ref struct PSVersionTable { - internal readonly ref struct PSVersionTable + public PSVersionTable(object value) { - public PSVersionTable(object value) - { - PSEdition = null; - PSVersion = null; + PSEdition = null; + PSVersion = null; - // https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_editions?view=powershell-7 - var source = (IEnumerable)value; - foreach (DictionaryEntry entry in source) + // https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_editions?view=powershell-7 + var source = (IEnumerable)value; + foreach (DictionaryEntry entry in source) + { + var key = (string)entry.Key; + if ("PSEdition".Equals(key, StringComparison.OrdinalIgnoreCase)) { - var key = (string)entry.Key; - if ("PSEdition".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - PSEdition = Convert.ToString(entry.Value); - } - else if ("PSVersion".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - PSVersion = Convert.ToString(entry.Value); - } + PSEdition = Convert.ToString(entry.Value); + } + else if ("PSVersion".Equals(key, StringComparison.OrdinalIgnoreCase)) + { + PSVersion = Convert.ToString(entry.Value); } } + } - public string PSEdition { get; } + public string PSEdition { get; } - public string PSVersion { get; } - } -} + public string PSVersion { get; } +} \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/Internal/PowerShellCommandBase.cs b/Sources/SqlDatabase.PowerShell/Internal/PowerShellCommandBase.cs index 37309278..9b54c92f 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/PowerShellCommandBase.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/PowerShellCommandBase.cs @@ -2,59 +2,58 @@ using System.Management.Automation; using SqlDatabase.Configuration; -namespace SqlDatabase.PowerShell.Internal +namespace SqlDatabase.PowerShell.Internal; + +internal abstract class PowerShellCommandBase { - internal abstract class PowerShellCommandBase + protected PowerShellCommandBase(PSCmdlet cmdlet) { - protected PowerShellCommandBase(PSCmdlet cmdlet) - { - Cmdlet = cmdlet; - } + Cmdlet = cmdlet; + } - public PSCmdlet Cmdlet { get; } + public PSCmdlet Cmdlet { get; } - // only for tests - internal static ISqlDatabaseProgram Program { get; set; } + // only for tests + internal static ISqlDatabaseProgram Program { get; set; } - public void Execute() + public void Execute() + { + using (var resolver = DependencyResolverFactory.Create(Cmdlet)) { - using (var resolver = DependencyResolverFactory.Create(Cmdlet)) - { - resolver.Initialize(); - ExecuteCore(); - } + resolver.Initialize(); + ExecuteCore(); } + } - internal static void AppendDefaultConfiguration(GenericCommandLine command) + internal static void AppendDefaultConfiguration(GenericCommandLine command) + { + if (string.IsNullOrEmpty(command.ConfigurationFile)) { - if (string.IsNullOrEmpty(command.ConfigurationFile)) - { - var probingPath = Path.GetDirectoryName(typeof(PowerShellCommandBase).Assembly.Location); - command.ConfigurationFile = ConfigurationManager.ResolveDefaultConfigurationFile(probingPath); - } + var probingPath = Path.GetDirectoryName(typeof(PowerShellCommandBase).Assembly.Location); + command.ConfigurationFile = ConfigurationManager.ResolveDefaultConfigurationFile(probingPath); } + } - protected abstract void BuildCommandLine(GenericCommandLineBuilder builder); + protected abstract void BuildCommandLine(GenericCommandLineBuilder builder); - private void ExecuteCore() - { - var builder = new GenericCommandLineBuilder(); - BuildCommandLine(builder); + private void ExecuteCore() + { + var builder = new GenericCommandLineBuilder(); + BuildCommandLine(builder); - var command = builder.Build(); - AppendDefaultConfiguration(command); + var command = builder.Build(); + AppendDefaultConfiguration(command); - ResolveProgram().ExecuteCommand(command); - } + ResolveProgram().ExecuteCommand(command); + } - private ISqlDatabaseProgram ResolveProgram() + private ISqlDatabaseProgram ResolveProgram() + { + if (Program != null) { - if (Program != null) - { - return Program; - } - - return new SqlDatabaseProgram(new CmdLetLogger(Cmdlet)); + return Program; } + + return new SqlDatabaseProgram(new CmdLetLogger(Cmdlet)); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/Internal/PowerShellCoreDependencyResolver.cs b/Sources/SqlDatabase.PowerShell/Internal/PowerShellCoreDependencyResolver.cs index dbab07ba..72ef5288 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/PowerShellCoreDependencyResolver.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/PowerShellCoreDependencyResolver.cs @@ -3,36 +3,35 @@ using System.Reflection; using System.Runtime.Loader; -namespace SqlDatabase.PowerShell.Internal +namespace SqlDatabase.PowerShell.Internal; + +internal sealed class PowerShellCoreDependencyResolver : IDependencyResolver { - internal sealed class PowerShellCoreDependencyResolver : IDependencyResolver - { - private readonly AssemblyCache _cache; + private readonly AssemblyCache _cache; - public PowerShellCoreDependencyResolver() - { - var psCore = Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), "ps-core"); - _cache = new AssemblyCache( - psCore, - Path.GetDirectoryName(typeof(PSCmdlet).Assembly.Location)); - } + public PowerShellCoreDependencyResolver() + { + var psCore = Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), "ps-core"); + _cache = new AssemblyCache( + psCore, + Path.GetDirectoryName(typeof(PSCmdlet).Assembly.Location)); + } - public void Initialize() - { - // Fail to load configuration from [SqlDatabase.exe.config]. - // ---> An error occurred creating the configuration section handler for sqlDatabase: Could not load file or assembly 'SqlDatabase, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified. - AssemblyLoadContext.Default.Resolving += AssemblyResolving; - } + public void Initialize() + { + // Fail to load configuration from [SqlDatabase.exe.config]. + // ---> An error occurred creating the configuration section handler for sqlDatabase: Could not load file or assembly 'SqlDatabase, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified. + AssemblyLoadContext.Default.Resolving += AssemblyResolving; + } - public void Dispose() - { - AssemblyLoadContext.Default.Resolving -= AssemblyResolving; - _cache.Dispose(); - } + public void Dispose() + { + AssemblyLoadContext.Default.Resolving -= AssemblyResolving; + _cache.Dispose(); + } - private Assembly AssemblyResolving(AssemblyLoadContext context, AssemblyName assemblyName) - { - return _cache.Load(assemblyName, context.LoadFromAssemblyPath); - } + private Assembly AssemblyResolving(AssemblyLoadContext context, AssemblyName assemblyName) + { + return _cache.Load(assemblyName, context.LoadFromAssemblyPath); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/Internal/PowerShellDesktopDependencyResolver.cs b/Sources/SqlDatabase.PowerShell/Internal/PowerShellDesktopDependencyResolver.cs index 17053b0d..80a295b2 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/PowerShellDesktopDependencyResolver.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/PowerShellDesktopDependencyResolver.cs @@ -2,32 +2,31 @@ using System.IO; using System.Reflection; -namespace SqlDatabase.PowerShell.Internal +namespace SqlDatabase.PowerShell.Internal; + +internal sealed class PowerShellDesktopDependencyResolver : IDependencyResolver { - internal sealed class PowerShellDesktopDependencyResolver : IDependencyResolver - { - private readonly AssemblyCache _cache; + private readonly AssemblyCache _cache; - public PowerShellDesktopDependencyResolver() - { - var psDesktop = Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), "ps-desktop"); - _cache = new AssemblyCache(psDesktop); - } + public PowerShellDesktopDependencyResolver() + { + var psDesktop = Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), "ps-desktop"); + _cache = new AssemblyCache(psDesktop); + } - public void Initialize() - { - AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolve; - } + public void Initialize() + { + AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolve; + } - public void Dispose() - { - AppDomain.CurrentDomain.AssemblyResolve -= AssemblyResolve; - _cache.Dispose(); - } + public void Dispose() + { + AppDomain.CurrentDomain.AssemblyResolve -= AssemblyResolve; + _cache.Dispose(); + } - private Assembly AssemblyResolve(object sender, ResolveEventArgs args) - { - return _cache.Load(new AssemblyName(args.Name), Assembly.LoadFrom); - } + private Assembly AssemblyResolve(object sender, ResolveEventArgs args) + { + return _cache.Load(new AssemblyName(args.Name), Assembly.LoadFrom); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/Internal/SqlDatabaseProgram.cs b/Sources/SqlDatabase.PowerShell/Internal/SqlDatabaseProgram.cs index a97b7c2d..693a0c28 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/SqlDatabaseProgram.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/SqlDatabaseProgram.cs @@ -1,20 +1,19 @@ using SqlDatabase.Configuration; -namespace SqlDatabase.PowerShell.Internal +namespace SqlDatabase.PowerShell.Internal; + +internal sealed class SqlDatabaseProgram : ISqlDatabaseProgram { - internal sealed class SqlDatabaseProgram : ISqlDatabaseProgram - { - private readonly ILogger _logger; + private readonly ILogger _logger; - public SqlDatabaseProgram(ILogger logger) - { - _logger = logger; - } + public SqlDatabaseProgram(ILogger logger) + { + _logger = logger; + } - public void ExecuteCommand(GenericCommandLine command) - { - var args = new GenericCommandLineBuilder(command).BuildArray(); - Program.Run(_logger, args); - } + public void ExecuteCommand(GenericCommandLine command) + { + var args = new GenericCommandLineBuilder(command).BuildArray(); + Program.Run(_logger, args); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/Internal/UpgradePowerShellCommand.cs b/Sources/SqlDatabase.PowerShell/Internal/UpgradePowerShellCommand.cs index 2d1c403d..cac64cfc 100644 --- a/Sources/SqlDatabase.PowerShell/Internal/UpgradePowerShellCommand.cs +++ b/Sources/SqlDatabase.PowerShell/Internal/UpgradePowerShellCommand.cs @@ -1,38 +1,37 @@ using SqlDatabase.Configuration; -namespace SqlDatabase.PowerShell.Internal +namespace SqlDatabase.PowerShell.Internal; + +internal sealed class UpgradePowerShellCommand : PowerShellCommandBase { - internal sealed class UpgradePowerShellCommand : PowerShellCommandBase + public UpgradePowerShellCommand(UpgradeCmdLet cmdLet) + : base(cmdLet) { - public UpgradePowerShellCommand(UpgradeCmdLet cmdLet) - : base(cmdLet) - { - } + } - public new UpgradeCmdLet Cmdlet => (UpgradeCmdLet)base.Cmdlet; + public new UpgradeCmdLet Cmdlet => (UpgradeCmdLet)base.Cmdlet; - protected override void BuildCommandLine(GenericCommandLineBuilder builder) - { - builder - .SetCommand(CommandLineFactory.CommandUpgrade) - .SetConnection(Cmdlet.Database) - .SetLogFileName(Cmdlet.RootPath(Cmdlet.Log)); + protected override void BuildCommandLine(GenericCommandLineBuilder builder) + { + builder + .SetCommand(CommandLineFactory.CommandUpgrade) + .SetConnection(Cmdlet.Database) + .SetLogFileName(Cmdlet.RootPath(Cmdlet.Log)); - if (Cmdlet.Var != null) + if (Cmdlet.Var != null) + { + for (var i = 0; i < Cmdlet.Var.Length; i++) { - for (var i = 0; i < Cmdlet.Var.Length; i++) - { - builder.SetVariable(Cmdlet.Var[i]); - } + builder.SetVariable(Cmdlet.Var[i]); } + } - Cmdlet.AppendFrom(Cmdlet.From, builder); + Cmdlet.AppendFrom(Cmdlet.From, builder); - builder - .SetConfigurationFile(Cmdlet.RootPath(Cmdlet.Configuration)) - .SetTransaction((TransactionMode)Cmdlet.Transaction) - .SetWhatIf(Cmdlet.WhatIf) - .SetFolderAsModuleName(Cmdlet.FolderAsModuleName); - } + builder + .SetConfigurationFile(Cmdlet.RootPath(Cmdlet.Configuration)) + .SetTransaction((TransactionMode)Cmdlet.Transaction) + .SetWhatIf(Cmdlet.WhatIf) + .SetFolderAsModuleName(Cmdlet.FolderAsModuleName); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/PSTransactionMode.cs b/Sources/SqlDatabase.PowerShell/PSTransactionMode.cs index 42c4ba76..f539df1e 100644 --- a/Sources/SqlDatabase.PowerShell/PSTransactionMode.cs +++ b/Sources/SqlDatabase.PowerShell/PSTransactionMode.cs @@ -1,12 +1,11 @@ using SqlDatabase.Configuration; -namespace SqlDatabase.PowerShell +namespace SqlDatabase.PowerShell; + +// do not load SqlDatabase.dll on Import-Module +public enum PSTransactionMode { - // do not load SqlDatabase.dll on Import-Module - public enum PSTransactionMode - { - None = TransactionMode.None, + None = TransactionMode.None, - PerStep = TransactionMode.PerStep - } -} + PerStep = TransactionMode.PerStep +} \ No newline at end of file diff --git a/Sources/SqlDatabase.PowerShell/UpgradeCmdLet.cs b/Sources/SqlDatabase.PowerShell/UpgradeCmdLet.cs index e4003dce..95b921ff 100644 --- a/Sources/SqlDatabase.PowerShell/UpgradeCmdLet.cs +++ b/Sources/SqlDatabase.PowerShell/UpgradeCmdLet.cs @@ -2,44 +2,43 @@ using SqlDatabase.Configuration; using SqlDatabase.PowerShell.Internal; -namespace SqlDatabase.PowerShell +namespace SqlDatabase.PowerShell; + +[Cmdlet(VerbsData.Update, "SqlDatabase")] +[Alias(CommandLineFactory.CommandUpgrade + "-SqlDatabase")] +public sealed class UpgradeCmdLet : PSCmdlet { - [Cmdlet(VerbsData.Update, "SqlDatabase")] - [Alias(CommandLineFactory.CommandUpgrade + "-SqlDatabase")] - public sealed class UpgradeCmdLet : PSCmdlet - { - [Parameter(Mandatory = true, Position = 1, HelpMessage = "Connection string to target database.")] - [Alias("d")] - public string Database { get; set; } + [Parameter(Mandatory = true, Position = 1, HelpMessage = "Connection string to target database.")] + [Alias("d")] + public string Database { get; set; } - [Parameter(Mandatory = true, Position = 2, ValueFromPipeline = true, HelpMessage = "A path to a folder or zip archive with migration steps. Repeat -from to setup several sources.")] - [Alias("f")] - public string[] From { get; set; } + [Parameter(Mandatory = true, Position = 2, ValueFromPipeline = true, HelpMessage = "A path to a folder or zip archive with migration steps. Repeat -from to setup several sources.")] + [Alias("f")] + public string[] From { get; set; } - [Parameter(Position = 3, HelpMessage = "Transaction mode. Possible values: none, perStep. Default is none.")] - [Alias("t")] - public PSTransactionMode Transaction { get; set; } + [Parameter(Position = 3, HelpMessage = "Transaction mode. Possible values: none, perStep. Default is none.")] + [Alias("t")] + public PSTransactionMode Transaction { get; set; } - [Parameter(Position = 4, HelpMessage = "A path to application configuration file. Default is current SqlDatabase.exe.config.")] - [Alias("c")] - public string Configuration { get; set; } + [Parameter(Position = 4, HelpMessage = "A path to application configuration file. Default is current SqlDatabase.exe.config.")] + [Alias("c")] + public string Configuration { get; set; } - [Parameter(Position = 5, HelpMessage = "Shows what would happen if the command runs. The command is not run.")] - public SwitchParameter WhatIf { get; set; } + [Parameter(Position = 5, HelpMessage = "Shows what would happen if the command runs. The command is not run.")] + public SwitchParameter WhatIf { get; set; } - [Parameter(Position = 6)] - public SwitchParameter FolderAsModuleName { get; set; } + [Parameter(Position = 6)] + public SwitchParameter FolderAsModuleName { get; set; } - [Parameter(ValueFromRemainingArguments = true, HelpMessage = "Set a variable in format \"[name of variable]=[value of variable]\".")] - [Alias("v")] - public string[] Var { get; set; } + [Parameter(ValueFromRemainingArguments = true, HelpMessage = "Set a variable in format \"[name of variable]=[value of variable]\".")] + [Alias("v")] + public string[] Var { get; set; } - [Parameter(HelpMessage = "Optional path to log file.")] - public string Log { get; set; } + [Parameter(HelpMessage = "Optional path to log file.")] + public string Log { get; set; } - protected override void ProcessRecord() - { - new UpgradePowerShellCommand(this).Execute(); - } + protected override void ProcessRecord() + { + new UpgradePowerShellCommand(this).Execute(); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Commands/DatabaseCreateCommandTest.cs b/Sources/SqlDatabase.Test/Commands/DatabaseCreateCommandTest.cs index ae223bf3..de378fc0 100644 --- a/Sources/SqlDatabase.Test/Commands/DatabaseCreateCommandTest.cs +++ b/Sources/SqlDatabase.Test/Commands/DatabaseCreateCommandTest.cs @@ -4,115 +4,114 @@ using NUnit.Framework; using SqlDatabase.Scripts; -namespace SqlDatabase.Commands +namespace SqlDatabase.Commands; + +[TestFixture] +public class DatabaseCreateCommandTest { - [TestFixture] - public class DatabaseCreateCommandTest + private DatabaseCreateCommand _sut; + private Mock _database; + private Mock _scriptSequence; + private Mock _powerShellFactory; + private Mock _log; + + [SetUp] + public void BeforeEachTest() { - private DatabaseCreateCommand _sut; - private Mock _database; - private Mock _scriptSequence; - private Mock _powerShellFactory; - private Mock _log; - - [SetUp] - public void BeforeEachTest() - { - var adapter = new Mock(MockBehavior.Strict); - adapter - .Setup(a => a.GetUserFriendlyConnectionString()) - .Returns("greet"); - - _database = new Mock(MockBehavior.Strict); - _database.SetupGet(d => d.Adapter).Returns(adapter.Object); - _database.Setup(d => d.GetServerVersion()).Returns("sql server 1.0"); - - _scriptSequence = new Mock(MockBehavior.Strict); - - _powerShellFactory = new Mock(MockBehavior.Strict); - - _log = new Mock(MockBehavior.Strict); - _log.Setup(l => l.Indent()).Returns((IDisposable)null); - _log - .Setup(l => l.Error(It.IsAny())) - .Callback(m => - { - Console.WriteLine("Error: {0}", m); - }); - _log - .Setup(l => l.Info(It.IsAny())) - .Callback(m => - { - Console.WriteLine("Info: {0}", m); - }); - - _sut = new DatabaseCreateCommand + var adapter = new Mock(MockBehavior.Strict); + adapter + .Setup(a => a.GetUserFriendlyConnectionString()) + .Returns("greet"); + + _database = new Mock(MockBehavior.Strict); + _database.SetupGet(d => d.Adapter).Returns(adapter.Object); + _database.Setup(d => d.GetServerVersion()).Returns("sql server 1.0"); + + _scriptSequence = new Mock(MockBehavior.Strict); + + _powerShellFactory = new Mock(MockBehavior.Strict); + + _log = new Mock(MockBehavior.Strict); + _log.Setup(l => l.Indent()).Returns((IDisposable)null); + _log + .Setup(l => l.Error(It.IsAny())) + .Callback(m => + { + Console.WriteLine("Error: {0}", m); + }); + _log + .Setup(l => l.Info(It.IsAny())) + .Callback(m => { - Database = _database.Object, - Log = _log.Object, - ScriptSequence = _scriptSequence.Object, - PowerShellFactory = _powerShellFactory.Object - }; - } - - [Test] - public void ScriptsNotFound() + Console.WriteLine("Info: {0}", m); + }); + + _sut = new DatabaseCreateCommand { - _scriptSequence.Setup(s => s.BuildSequence()).Returns(new IScript[0]); + Database = _database.Object, + Log = _log.Object, + ScriptSequence = _scriptSequence.Object, + PowerShellFactory = _powerShellFactory.Object + }; + } - Assert.Throws(_sut.Execute); + [Test] + public void ScriptsNotFound() + { + _scriptSequence.Setup(s => s.BuildSequence()).Returns(new IScript[0]); - _scriptSequence.VerifyAll(); - } + Assert.Throws(_sut.Execute); - [Test] - public void ExecuteSequence() - { - var step1 = new Mock(MockBehavior.Strict); - step1.SetupGet(s => s.DisplayName).Returns("step 1"); + _scriptSequence.VerifyAll(); + } + + [Test] + public void ExecuteSequence() + { + var step1 = new Mock(MockBehavior.Strict); + step1.SetupGet(s => s.DisplayName).Returns("step 1"); - var step2 = new Mock(MockBehavior.Strict); - step2.SetupGet(s => s.DisplayName).Returns("step 2"); + var step2 = new Mock(MockBehavior.Strict); + step2.SetupGet(s => s.DisplayName).Returns("step 2"); - _powerShellFactory - .Setup(f => f.InitializeIfRequested(_log.Object)); + _powerShellFactory + .Setup(f => f.InitializeIfRequested(_log.Object)); - _database - .Setup(d => d.Execute(step1.Object)) - .Callback(() => _database.Setup(d => d.Execute(step2.Object))); + _database + .Setup(d => d.Execute(step1.Object)) + .Callback(() => _database.Setup(d => d.Execute(step2.Object))); - _scriptSequence.Setup(s => s.BuildSequence()).Returns(new[] { step1.Object, step2.Object }); + _scriptSequence.Setup(s => s.BuildSequence()).Returns(new[] { step1.Object, step2.Object }); - _sut.Execute(); + _sut.Execute(); - _database.VerifyAll(); - _scriptSequence.VerifyAll(); - _powerShellFactory.VerifyAll(); - } + _database.VerifyAll(); + _scriptSequence.VerifyAll(); + _powerShellFactory.VerifyAll(); + } - [Test] - public void StopExecutionOnError() - { - var step1 = new Mock(MockBehavior.Strict); - step1.SetupGet(s => s.DisplayName).Returns("step 1"); + [Test] + public void StopExecutionOnError() + { + var step1 = new Mock(MockBehavior.Strict); + step1.SetupGet(s => s.DisplayName).Returns("step 1"); - var step2 = new Mock(MockBehavior.Strict); - step2.SetupGet(s => s.DisplayName).Returns("step 2"); + var step2 = new Mock(MockBehavior.Strict); + step2.SetupGet(s => s.DisplayName).Returns("step 2"); - _powerShellFactory - .Setup(f => f.InitializeIfRequested(_log.Object)); + _powerShellFactory + .Setup(f => f.InitializeIfRequested(_log.Object)); - _database - .Setup(d => d.Execute(step1.Object)) - .Throws(); + _database + .Setup(d => d.Execute(step1.Object)) + .Throws(); - _scriptSequence.Setup(s => s.BuildSequence()).Returns(new[] { step1.Object, step2.Object }); + _scriptSequence.Setup(s => s.BuildSequence()).Returns(new[] { step1.Object, step2.Object }); - Assert.Throws(_sut.Execute); + Assert.Throws(_sut.Execute); - _database.VerifyAll(); - _scriptSequence.VerifyAll(); - _powerShellFactory.VerifyAll(); - } + _database.VerifyAll(); + _scriptSequence.VerifyAll(); + _powerShellFactory.VerifyAll(); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Commands/DatabaseExecuteCommandTest.cs b/Sources/SqlDatabase.Test/Commands/DatabaseExecuteCommandTest.cs index e361cb1c..ba302585 100644 --- a/Sources/SqlDatabase.Test/Commands/DatabaseExecuteCommandTest.cs +++ b/Sources/SqlDatabase.Test/Commands/DatabaseExecuteCommandTest.cs @@ -3,75 +3,74 @@ using NUnit.Framework; using SqlDatabase.Scripts; -namespace SqlDatabase.Commands -{ - [TestFixture] - public class DatabaseExecuteCommandTest - { - private DatabaseExecuteCommand _sut; - private Mock _database; - private Mock _scriptSequence; - private Mock _powerShellFactory; - private Mock _log; +namespace SqlDatabase.Commands; - [SetUp] - public void BeforeEachTest() - { - var adapter = new Mock(MockBehavior.Strict); - adapter - .Setup(a => a.GetUserFriendlyConnectionString()) - .Returns("greet"); +[TestFixture] +public class DatabaseExecuteCommandTest +{ + private DatabaseExecuteCommand _sut; + private Mock _database; + private Mock _scriptSequence; + private Mock _powerShellFactory; + private Mock _log; - _database = new Mock(MockBehavior.Strict); - _database.SetupGet(d => d.Adapter).Returns(adapter.Object); - _database.Setup(d => d.GetServerVersion()).Returns("sql server 1.0"); + [SetUp] + public void BeforeEachTest() + { + var adapter = new Mock(MockBehavior.Strict); + adapter + .Setup(a => a.GetUserFriendlyConnectionString()) + .Returns("greet"); - _scriptSequence = new Mock(MockBehavior.Strict); + _database = new Mock(MockBehavior.Strict); + _database.SetupGet(d => d.Adapter).Returns(adapter.Object); + _database.Setup(d => d.GetServerVersion()).Returns("sql server 1.0"); - _powerShellFactory = new Mock(MockBehavior.Strict); + _scriptSequence = new Mock(MockBehavior.Strict); - _log = new Mock(MockBehavior.Strict); - _log.Setup(l => l.Indent()).Returns((IDisposable)null); - _log - .Setup(l => l.Info(It.IsAny())) - .Callback(m => - { - Console.WriteLine("Info: {0}", m); - }); + _powerShellFactory = new Mock(MockBehavior.Strict); - _sut = new DatabaseExecuteCommand + _log = new Mock(MockBehavior.Strict); + _log.Setup(l => l.Indent()).Returns((IDisposable)null); + _log + .Setup(l => l.Info(It.IsAny())) + .Callback(m => { - Database = _database.Object, - Log = _log.Object, - ScriptSequence = _scriptSequence.Object, - PowerShellFactory = _powerShellFactory.Object - }; - } + Console.WriteLine("Info: {0}", m); + }); - [Test] - public void ExecuteOneScript() + _sut = new DatabaseExecuteCommand { - var script1 = new Mock(MockBehavior.Strict); - script1.SetupGet(s => s.DisplayName).Returns("step 1"); + Database = _database.Object, + Log = _log.Object, + ScriptSequence = _scriptSequence.Object, + PowerShellFactory = _powerShellFactory.Object + }; + } + + [Test] + public void ExecuteOneScript() + { + var script1 = new Mock(MockBehavior.Strict); + script1.SetupGet(s => s.DisplayName).Returns("step 1"); - var script2 = new Mock(MockBehavior.Strict); - script2.SetupGet(s => s.DisplayName).Returns("step 2"); + var script2 = new Mock(MockBehavior.Strict); + script2.SetupGet(s => s.DisplayName).Returns("step 2"); - _powerShellFactory - .Setup(f => f.InitializeIfRequested(_log.Object)); + _powerShellFactory + .Setup(f => f.InitializeIfRequested(_log.Object)); - _database - .Setup(d => d.Execute(script1.Object)) - .Callback(() => _database.Setup(d => d.Execute(script2.Object))); + _database + .Setup(d => d.Execute(script1.Object)) + .Callback(() => _database.Setup(d => d.Execute(script2.Object))); - _scriptSequence.Setup(s => s.BuildSequence()).Returns(new[] { script1.Object, script2.Object }); + _scriptSequence.Setup(s => s.BuildSequence()).Returns(new[] { script1.Object, script2.Object }); - _sut.Execute(); + _sut.Execute(); - _database.VerifyAll(); - script1.VerifyAll(); - script2.VerifyAll(); - _powerShellFactory.VerifyAll(); - } + _database.VerifyAll(); + script1.VerifyAll(); + script2.VerifyAll(); + _powerShellFactory.VerifyAll(); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Commands/DatabaseExportCommandTest.cs b/Sources/SqlDatabase.Test/Commands/DatabaseExportCommandTest.cs index 3c2bfa1d..150e3039 100644 --- a/Sources/SqlDatabase.Test/Commands/DatabaseExportCommandTest.cs +++ b/Sources/SqlDatabase.Test/Commands/DatabaseExportCommandTest.cs @@ -7,114 +7,113 @@ using SqlDatabase.Scripts; using SqlDatabase.Scripts.MsSql; -namespace SqlDatabase.Commands +namespace SqlDatabase.Commands; + +[TestFixture] +public class DatabaseExportCommandTest { - [TestFixture] - public class DatabaseExportCommandTest - { - private DatabaseExportCommand _sut; - private Mock _database; - private Mock _scriptSequence; - private Mock _exporter; + private DatabaseExportCommand _sut; + private Mock _database; + private Mock _scriptSequence; + private Mock _exporter; - [SetUp] - public void BeforeEachTest() - { - var adapter = new Mock(MockBehavior.Strict); - adapter - .Setup(a => a.GetUserFriendlyConnectionString()) - .Returns("host; database"); - adapter - .Setup(a => a.CreateSqlWriter(It.IsAny())) - .Returns(output => new MsSqlWriter(output)); - - _database = new Mock(MockBehavior.Strict); - _database.SetupGet(d => d.Adapter).Returns(adapter.Object); - _database.Setup(d => d.GetServerVersion()).Returns("sql server 1.0"); - - _scriptSequence = new Mock(MockBehavior.Strict); - - var log = new Mock(MockBehavior.Strict); - log.Setup(l => l.Indent()).Returns((IDisposable)null); - log - .Setup(l => l.Info(It.IsAny())) - .Callback(m => - { - Console.WriteLine("Info: {0}", m); - }); - - _exporter = new Mock(MockBehavior.Strict); - _exporter - .SetupProperty(e => e.Output); - _exporter - .SetupSet(e => e.Log = log.Object); - - _sut = new DatabaseExportCommand + [SetUp] + public void BeforeEachTest() + { + var adapter = new Mock(MockBehavior.Strict); + adapter + .Setup(a => a.GetUserFriendlyConnectionString()) + .Returns("host; database"); + adapter + .Setup(a => a.CreateSqlWriter(It.IsAny())) + .Returns(output => new MsSqlWriter(output)); + + _database = new Mock(MockBehavior.Strict); + _database.SetupGet(d => d.Adapter).Returns(adapter.Object); + _database.Setup(d => d.GetServerVersion()).Returns("sql server 1.0"); + + _scriptSequence = new Mock(MockBehavior.Strict); + + var log = new Mock(MockBehavior.Strict); + log.Setup(l => l.Indent()).Returns((IDisposable)null); + log + .Setup(l => l.Info(It.IsAny())) + .Callback(m => { - Database = _database.Object, - Log = log.Object, - ScriptSequence = _scriptSequence.Object, - ExporterFactory = () => _exporter.Object, - OpenOutput = () => Console.Out - }; - } - - [Test] - public void ExportOneScript() + Console.WriteLine("Info: {0}", m); + }); + + _exporter = new Mock(MockBehavior.Strict); + _exporter + .SetupProperty(e => e.Output); + _exporter + .SetupSet(e => e.Log = log.Object); + + _sut = new DatabaseExportCommand { - var script = new Mock(MockBehavior.Strict); - script.SetupGet(s => s.DisplayName).Returns("display name"); + Database = _database.Object, + Log = log.Object, + ScriptSequence = _scriptSequence.Object, + ExporterFactory = () => _exporter.Object, + OpenOutput = () => Console.Out + }; + } - var reader = new Mock(MockBehavior.Strict); - reader - .Setup(r => r.NextResult()) - .Returns(false); + [Test] + public void ExportOneScript() + { + var script = new Mock(MockBehavior.Strict); + script.SetupGet(s => s.DisplayName).Returns("display name"); - _database - .Setup(d => d.ExecuteReader(script.Object)) - .Returns(new[] { reader.Object }); + var reader = new Mock(MockBehavior.Strict); + reader + .Setup(r => r.NextResult()) + .Returns(false); - _exporter - .Setup(e => e.Export(reader.Object, "dbo.SqlDatabaseExport")); + _database + .Setup(d => d.ExecuteReader(script.Object)) + .Returns(new[] { reader.Object }); - _scriptSequence.Setup(s => s.BuildSequence()).Returns(new[] { script.Object }); + _exporter + .Setup(e => e.Export(reader.Object, "dbo.SqlDatabaseExport")); - _sut.Execute(); + _scriptSequence.Setup(s => s.BuildSequence()).Returns(new[] { script.Object }); - _database.VerifyAll(); - script.VerifyAll(); - _exporter.VerifyAll(); - } + _sut.Execute(); - [Test] - public void ReaderNextResult() - { - var script = new Mock(MockBehavior.Strict); - script.SetupGet(s => s.DisplayName).Returns("display name"); + _database.VerifyAll(); + script.VerifyAll(); + _exporter.VerifyAll(); + } + + [Test] + public void ReaderNextResult() + { + var script = new Mock(MockBehavior.Strict); + script.SetupGet(s => s.DisplayName).Returns("display name"); - var reader = new Mock(MockBehavior.Strict); - reader - .Setup(r => r.NextResult()) - .Callback(() => reader.Setup(r => r.NextResult()).Returns(false)) - .Returns(true); + var reader = new Mock(MockBehavior.Strict); + reader + .Setup(r => r.NextResult()) + .Callback(() => reader.Setup(r => r.NextResult()).Returns(false)) + .Returns(true); - _database - .Setup(d => d.ExecuteReader(script.Object)) - .Returns(new[] { reader.Object }); + _database + .Setup(d => d.ExecuteReader(script.Object)) + .Returns(new[] { reader.Object }); - _exporter - .Setup(e => e.Export(reader.Object, "dbo.SqlDatabaseExport")); + _exporter + .Setup(e => e.Export(reader.Object, "dbo.SqlDatabaseExport")); - _exporter - .Setup(e => e.Export(reader.Object, "dbo.SqlDatabaseExport_2")); + _exporter + .Setup(e => e.Export(reader.Object, "dbo.SqlDatabaseExport_2")); - _scriptSequence.Setup(s => s.BuildSequence()).Returns(new[] { script.Object }); + _scriptSequence.Setup(s => s.BuildSequence()).Returns(new[] { script.Object }); - _sut.Execute(); + _sut.Execute(); - _database.VerifyAll(); - script.VerifyAll(); - _exporter.VerifyAll(); - } + _database.VerifyAll(); + script.VerifyAll(); + _exporter.VerifyAll(); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Commands/DatabaseUpgradeCommandTest.cs b/Sources/SqlDatabase.Test/Commands/DatabaseUpgradeCommandTest.cs index a5b8b7bd..b391967b 100644 --- a/Sources/SqlDatabase.Test/Commands/DatabaseUpgradeCommandTest.cs +++ b/Sources/SqlDatabase.Test/Commands/DatabaseUpgradeCommandTest.cs @@ -3,124 +3,123 @@ using NUnit.Framework; using SqlDatabase.Scripts; -namespace SqlDatabase.Commands +namespace SqlDatabase.Commands; + +[TestFixture] +public class DatabaseUpgradeCommandTest { - [TestFixture] - public class DatabaseUpgradeCommandTest + private DatabaseUpgradeCommand _sut; + private Mock _database; + private Mock _scriptSequence; + private Mock _powerShellFactory; + private Mock _log; + + [SetUp] + public void BeforeEachTest() { - private DatabaseUpgradeCommand _sut; - private Mock _database; - private Mock _scriptSequence; - private Mock _powerShellFactory; - private Mock _log; - - [SetUp] - public void BeforeEachTest() - { - var adapter = new Mock(MockBehavior.Strict); - adapter - .Setup(a => a.GetUserFriendlyConnectionString()) - .Returns("greet"); - - _database = new Mock(MockBehavior.Strict); - _database.SetupGet(d => d.Adapter).Returns(adapter.Object); - _database.Setup(d => d.GetServerVersion()).Returns("sql server 1.0"); - - _scriptSequence = new Mock(MockBehavior.Strict); - - _powerShellFactory = new Mock(MockBehavior.Strict); - - _log = new Mock(MockBehavior.Strict); - _log.Setup(l => l.Indent()).Returns((IDisposable)null); - _log - .Setup(l => l.Error(It.IsAny())) - .Callback(m => - { - Console.WriteLine("Error: {0}", m); - }); - _log - .Setup(l => l.Info(It.IsAny())) - .Callback(m => - { - Console.WriteLine("Info: {0}", m); - }); - - _sut = new DatabaseUpgradeCommand + var adapter = new Mock(MockBehavior.Strict); + adapter + .Setup(a => a.GetUserFriendlyConnectionString()) + .Returns("greet"); + + _database = new Mock(MockBehavior.Strict); + _database.SetupGet(d => d.Adapter).Returns(adapter.Object); + _database.Setup(d => d.GetServerVersion()).Returns("sql server 1.0"); + + _scriptSequence = new Mock(MockBehavior.Strict); + + _powerShellFactory = new Mock(MockBehavior.Strict); + + _log = new Mock(MockBehavior.Strict); + _log.Setup(l => l.Indent()).Returns((IDisposable)null); + _log + .Setup(l => l.Error(It.IsAny())) + .Callback(m => + { + Console.WriteLine("Error: {0}", m); + }); + _log + .Setup(l => l.Info(It.IsAny())) + .Callback(m => { - Database = _database.Object, - Log = _log.Object, - ScriptSequence = _scriptSequence.Object, - PowerShellFactory = _powerShellFactory.Object - }; - } - - [Test] - public void DatabaseIsUpToDate() + Console.WriteLine("Info: {0}", m); + }); + + _sut = new DatabaseUpgradeCommand { - _scriptSequence.Setup(s => s.BuildSequence()).Returns(new ScriptStep[0]); + Database = _database.Object, + Log = _log.Object, + ScriptSequence = _scriptSequence.Object, + PowerShellFactory = _powerShellFactory.Object + }; + } - _sut.Execute(); + [Test] + public void DatabaseIsUpToDate() + { + _scriptSequence.Setup(s => s.BuildSequence()).Returns(new ScriptStep[0]); - _database.VerifyAll(); - _scriptSequence.VerifyAll(); - } + _sut.Execute(); - [Test] - public void ExecuteSequence() - { - var currentVersion = new Version("1.0"); + _database.VerifyAll(); + _scriptSequence.VerifyAll(); + } + + [Test] + public void ExecuteSequence() + { + var currentVersion = new Version("1.0"); - var updateTo2 = new Mock(MockBehavior.Strict); - updateTo2.SetupGet(s => s.DisplayName).Returns("2.0"); + var updateTo2 = new Mock(MockBehavior.Strict); + updateTo2.SetupGet(s => s.DisplayName).Returns("2.0"); - var updateTo3 = new Mock(MockBehavior.Strict); - updateTo3.SetupGet(s => s.DisplayName).Returns("3.0"); + var updateTo3 = new Mock(MockBehavior.Strict); + updateTo3.SetupGet(s => s.DisplayName).Returns("3.0"); - var stepTo2 = new ScriptStep("module1", currentVersion, new Version("2.0"), updateTo2.Object); - var stepTo3 = new ScriptStep("module2", new Version("2.0"), new Version("3.0"), updateTo3.Object); + var stepTo2 = new ScriptStep("module1", currentVersion, new Version("2.0"), updateTo2.Object); + var stepTo3 = new ScriptStep("module2", new Version("2.0"), new Version("3.0"), updateTo3.Object); - _powerShellFactory - .Setup(f => f.InitializeIfRequested(_log.Object)); + _powerShellFactory + .Setup(f => f.InitializeIfRequested(_log.Object)); - _database - .Setup(d => d.Execute(updateTo2.Object, "module1", stepTo2.From, stepTo2.To)) - .Callback(() => _database.Setup(d => d.Execute(updateTo3.Object, "module2", stepTo3.From, stepTo3.To))); + _database + .Setup(d => d.Execute(updateTo2.Object, "module1", stepTo2.From, stepTo2.To)) + .Callback(() => _database.Setup(d => d.Execute(updateTo3.Object, "module2", stepTo3.From, stepTo3.To))); - _scriptSequence.Setup(s => s.BuildSequence()).Returns(new[] { stepTo2, stepTo3 }); + _scriptSequence.Setup(s => s.BuildSequence()).Returns(new[] { stepTo2, stepTo3 }); - _sut.Execute(); + _sut.Execute(); - _database.VerifyAll(); - _scriptSequence.VerifyAll(); - _powerShellFactory.VerifyAll(); - } + _database.VerifyAll(); + _scriptSequence.VerifyAll(); + _powerShellFactory.VerifyAll(); + } - [Test] - public void StopExecutionOnError() - { - var currentVersion = new Version("1.0"); + [Test] + public void StopExecutionOnError() + { + var currentVersion = new Version("1.0"); - var updateTo2 = new Mock(MockBehavior.Strict); - updateTo2.SetupGet(s => s.DisplayName).Returns("2.0"); + var updateTo2 = new Mock(MockBehavior.Strict); + updateTo2.SetupGet(s => s.DisplayName).Returns("2.0"); - var updateTo3 = new Mock(MockBehavior.Strict); - updateTo3.SetupGet(s => s.DisplayName).Returns("3.0"); + var updateTo3 = new Mock(MockBehavior.Strict); + updateTo3.SetupGet(s => s.DisplayName).Returns("3.0"); - var stepTo2 = new ScriptStep(string.Empty, currentVersion, new Version("2.0"), updateTo2.Object); - var stepTo3 = new ScriptStep(string.Empty, new Version("2.0"), new Version("3.0"), updateTo3.Object); + var stepTo2 = new ScriptStep(string.Empty, currentVersion, new Version("2.0"), updateTo2.Object); + var stepTo3 = new ScriptStep(string.Empty, new Version("2.0"), new Version("3.0"), updateTo3.Object); - _powerShellFactory - .Setup(f => f.InitializeIfRequested(_log.Object)); + _powerShellFactory + .Setup(f => f.InitializeIfRequested(_log.Object)); - _database.Setup(d => d.Execute(updateTo2.Object, string.Empty, stepTo2.From, stepTo2.To)).Throws(); + _database.Setup(d => d.Execute(updateTo2.Object, string.Empty, stepTo2.From, stepTo2.To)).Throws(); - _scriptSequence.Setup(s => s.BuildSequence()).Returns(new[] { stepTo2, stepTo3 }); + _scriptSequence.Setup(s => s.BuildSequence()).Returns(new[] { stepTo2, stepTo3 }); - Assert.Throws(_sut.Execute); + Assert.Throws(_sut.Execute); - _database.VerifyAll(); - _scriptSequence.VerifyAll(); - _powerShellFactory.VerifyAll(); - } + _database.VerifyAll(); + _scriptSequence.VerifyAll(); + _powerShellFactory.VerifyAll(); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Configuration/AppConfigurationTest.cs b/Sources/SqlDatabase.Test/Configuration/AppConfigurationTest.cs index 4780ca83..ccaa2681 100644 --- a/Sources/SqlDatabase.Test/Configuration/AppConfigurationTest.cs +++ b/Sources/SqlDatabase.Test/Configuration/AppConfigurationTest.cs @@ -3,83 +3,82 @@ using Shouldly; using SqlDatabase.TestApi; -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +[TestFixture] +public class AppConfigurationTest { - [TestFixture] - public class AppConfigurationTest + [Test] + public void LoadEmpty() { - [Test] - public void LoadEmpty() - { - var configuration = LoadFromResource("AppConfiguration.empty.xml"); + var configuration = LoadFromResource("AppConfiguration.empty.xml"); - configuration.ShouldBeNull(); - } + configuration.ShouldBeNull(); + } - [Test] - public void LoadDefault() - { - var configuration = LoadFromResource("AppConfiguration.default.xml"); + [Test] + public void LoadDefault() + { + var configuration = LoadFromResource("AppConfiguration.default.xml"); - configuration.ShouldNotBeNull(); + configuration.ShouldNotBeNull(); - configuration.GetCurrentVersionScript.ShouldBeNullOrEmpty(); - configuration.SetCurrentVersionScript.ShouldBeNullOrEmpty(); + configuration.GetCurrentVersionScript.ShouldBeNullOrEmpty(); + configuration.SetCurrentVersionScript.ShouldBeNullOrEmpty(); - configuration.AssemblyScript.ClassName.ShouldBe("SqlDatabaseScript"); - configuration.AssemblyScript.MethodName.ShouldBe("Execute"); + configuration.AssemblyScript.ClassName.ShouldBe("SqlDatabaseScript"); + configuration.AssemblyScript.MethodName.ShouldBe("Execute"); - configuration.Variables.Count.ShouldBe(0); + configuration.Variables.Count.ShouldBe(0); - configuration.MsSql.GetCurrentVersionScript.ShouldBeNullOrEmpty(); - configuration.MsSql.GetCurrentVersionScript.ShouldBeNullOrEmpty(); - configuration.MsSql.Variables.Count.ShouldBe(0); + configuration.MsSql.GetCurrentVersionScript.ShouldBeNullOrEmpty(); + configuration.MsSql.GetCurrentVersionScript.ShouldBeNullOrEmpty(); + configuration.MsSql.Variables.Count.ShouldBe(0); - configuration.PgSql.GetCurrentVersionScript.ShouldBeNullOrEmpty(); - configuration.PgSql.GetCurrentVersionScript.ShouldBeNullOrEmpty(); - configuration.PgSql.Variables.Count.ShouldBe(0); + configuration.PgSql.GetCurrentVersionScript.ShouldBeNullOrEmpty(); + configuration.PgSql.GetCurrentVersionScript.ShouldBeNullOrEmpty(); + configuration.PgSql.Variables.Count.ShouldBe(0); - configuration.MySql.GetCurrentVersionScript.ShouldBeNullOrEmpty(); - configuration.MySql.GetCurrentVersionScript.ShouldBeNullOrEmpty(); - configuration.MySql.Variables.Count.ShouldBe(0); - } + configuration.MySql.GetCurrentVersionScript.ShouldBeNullOrEmpty(); + configuration.MySql.GetCurrentVersionScript.ShouldBeNullOrEmpty(); + configuration.MySql.Variables.Count.ShouldBe(0); + } - [Test] - public void LoadFull() - { - var configuration = LoadFromResource("AppConfiguration.full.xml"); + [Test] + public void LoadFull() + { + var configuration = LoadFromResource("AppConfiguration.full.xml"); - configuration.ShouldNotBeNull(); + configuration.ShouldNotBeNull(); - configuration.GetCurrentVersionScript.ShouldBe("get-version"); - configuration.SetCurrentVersionScript.ShouldBe("set-version"); + configuration.GetCurrentVersionScript.ShouldBe("get-version"); + configuration.SetCurrentVersionScript.ShouldBe("set-version"); - configuration.AssemblyScript.ClassName.ShouldBe("class-name"); - configuration.AssemblyScript.MethodName.ShouldBe("method-name"); + configuration.AssemblyScript.ClassName.ShouldBe("class-name"); + configuration.AssemblyScript.MethodName.ShouldBe("method-name"); - configuration.Variables.AllKeys.ShouldBe(new[] { "x", "y" }); - configuration.Variables["x"].Value.ShouldBe("1"); - configuration.Variables["y"].Value.ShouldBe("2"); + configuration.Variables.AllKeys.ShouldBe(new[] { "x", "y" }); + configuration.Variables["x"].Value.ShouldBe("1"); + configuration.Variables["y"].Value.ShouldBe("2"); - configuration.MsSql.GetCurrentVersionScript.ShouldBe("get-mssql-version"); - configuration.MsSql.SetCurrentVersionScript.ShouldBe("set-mssql-version"); - configuration.MsSql.Variables.AllKeys.ShouldBe(new[] { "mssql1" }); - configuration.MsSql.Variables["mssql1"].Value.ShouldBe("10"); + configuration.MsSql.GetCurrentVersionScript.ShouldBe("get-mssql-version"); + configuration.MsSql.SetCurrentVersionScript.ShouldBe("set-mssql-version"); + configuration.MsSql.Variables.AllKeys.ShouldBe(new[] { "mssql1" }); + configuration.MsSql.Variables["mssql1"].Value.ShouldBe("10"); - configuration.PgSql.GetCurrentVersionScript.ShouldBe("get-pgsql-version"); - configuration.PgSql.SetCurrentVersionScript.ShouldBe("set-pgsql-version"); - configuration.PgSql.Variables.AllKeys.ShouldBe(new[] { "pgsql1" }); - configuration.PgSql.Variables["pgsql1"].Value.ShouldBe("20"); - } + configuration.PgSql.GetCurrentVersionScript.ShouldBe("get-pgsql-version"); + configuration.PgSql.SetCurrentVersionScript.ShouldBe("set-pgsql-version"); + configuration.PgSql.Variables.AllKeys.ShouldBe(new[] { "pgsql1" }); + configuration.PgSql.Variables["pgsql1"].Value.ShouldBe("20"); + } - private static AppConfiguration LoadFromResource(string resourceName) + private static AppConfiguration LoadFromResource(string resourceName) + { + using (var temp = new TempDirectory()) { - using (var temp = new TempDirectory()) - { - var fileName = temp.CopyFileFromResources(resourceName); - var configuration = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = fileName }, ConfigurationUserLevel.None); - return (AppConfiguration)configuration.GetSection(AppConfiguration.SectionName); - } + var fileName = temp.CopyFileFromResources(resourceName); + var configuration = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = fileName }, ConfigurationUserLevel.None); + return (AppConfiguration)configuration.GetSection(AppConfiguration.SectionName); } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Configuration/CommandLineBaseTest.cs b/Sources/SqlDatabase.Test/Configuration/CommandLineBaseTest.cs index e1c3add1..d2690f9b 100644 --- a/Sources/SqlDatabase.Test/Configuration/CommandLineBaseTest.cs +++ b/Sources/SqlDatabase.Test/Configuration/CommandLineBaseTest.cs @@ -6,87 +6,86 @@ using SqlDatabase.IO; using SqlDatabase.TestApi; -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +[TestFixture] +public class CommandLineBaseTest { - [TestFixture] - public class CommandLineBaseTest + private Mock _log; + private Mock _configurationManager; + private AppConfiguration _configuration; + private Mock _fs; + private CommandLineBase _sut; + + [SetUp] + public void BeforeEachTest() + { + _log = new Mock(MockBehavior.Strict); + + _configuration = new AppConfiguration(); + + _configurationManager = new Mock(MockBehavior.Strict); + _configurationManager + .SetupGet(c => c.SqlDatabase) + .Returns(_configuration); + + _fs = new Mock(MockBehavior.Strict); + + _sut = new Mock { CallBase = true }.Object; + _sut.ConnectionString = MsSqlQuery.ConnectionString; + _sut.FileSystemFactory = _fs.Object; + } + + [Test] + public void CreateDatabase() + { + var actual = _sut.CreateDatabase(_log.Object, _configurationManager.Object, TransactionMode.PerStep, true); + + actual.Log.ShouldBe(_log.Object); + actual.Adapter.ShouldNotBeNull(); + actual.Transaction.ShouldBe(TransactionMode.PerStep); + actual.WhatIf.ShouldBeTrue(); + } + + [Test] + public void CreateDatabaseApplyVariables() + { + _sut.Variables.Add("a", "1"); + _sut.Variables.Add("b", "2"); + + _configuration.Variables.Add(new NameValueConfigurationElement("b", "2.2")); + _configuration.Variables.Add(new NameValueConfigurationElement("c", "3")); + + var actual = _sut.CreateDatabase(_log.Object, _configurationManager.Object, TransactionMode.None, false); + + Assert.AreEqual("1", actual.Variables.GetValue("a")); + Assert.AreEqual("2", actual.Variables.GetValue("b")); + Assert.AreEqual("3", actual.Variables.GetValue("c")); + } + + [Test] + public void CreateDatabaseValidateVariables() { - private Mock _log; - private Mock _configurationManager; - private AppConfiguration _configuration; - private Mock _fs; - private CommandLineBase _sut; - - [SetUp] - public void BeforeEachTest() - { - _log = new Mock(MockBehavior.Strict); - - _configuration = new AppConfiguration(); - - _configurationManager = new Mock(MockBehavior.Strict); - _configurationManager - .SetupGet(c => c.SqlDatabase) - .Returns(_configuration); - - _fs = new Mock(MockBehavior.Strict); - - _sut = new Mock { CallBase = true }.Object; - _sut.ConnectionString = MsSqlQuery.ConnectionString; - _sut.FileSystemFactory = _fs.Object; - } - - [Test] - public void CreateDatabase() - { - var actual = _sut.CreateDatabase(_log.Object, _configurationManager.Object, TransactionMode.PerStep, true); - - actual.Log.ShouldBe(_log.Object); - actual.Adapter.ShouldNotBeNull(); - actual.Transaction.ShouldBe(TransactionMode.PerStep); - actual.WhatIf.ShouldBeTrue(); - } - - [Test] - public void CreateDatabaseApplyVariables() - { - _sut.Variables.Add("a", "1"); - _sut.Variables.Add("b", "2"); - - _configuration.Variables.Add(new NameValueConfigurationElement("b", "2.2")); - _configuration.Variables.Add(new NameValueConfigurationElement("c", "3")); - - var actual = _sut.CreateDatabase(_log.Object, _configurationManager.Object, TransactionMode.None, false); - - Assert.AreEqual("1", actual.Variables.GetValue("a")); - Assert.AreEqual("2", actual.Variables.GetValue("b")); - Assert.AreEqual("3", actual.Variables.GetValue("c")); - } - - [Test] - public void CreateDatabaseValidateVariables() - { - _sut.Variables.Add("a b", "1"); - - _configuration.Variables.Add(new NameValueConfigurationElement("c d", "1")); - - var ex = Assert.Throws(() => _sut.CreateDatabase(_log.Object, _configurationManager.Object, TransactionMode.None, false)); - - ex.Message.ShouldContain("a b"); - ex.Message.ShouldContain("c d"); - } - - [Test] - public void ParseFrom() - { - var file = new Mock(MockBehavior.Strict); - _fs - .Setup(f => f.FileSystemInfoFromPath(@"c:\11.sql")) - .Returns(file.Object); - - _sut.Parse(new CommandLine(new Arg("from", @"c:\11.sql"))); - - _sut.Scripts.ShouldBe(new[] { file.Object }); - } + _sut.Variables.Add("a b", "1"); + + _configuration.Variables.Add(new NameValueConfigurationElement("c d", "1")); + + var ex = Assert.Throws(() => _sut.CreateDatabase(_log.Object, _configurationManager.Object, TransactionMode.None, false)); + + ex.Message.ShouldContain("a b"); + ex.Message.ShouldContain("c d"); + } + + [Test] + public void ParseFrom() + { + var file = new Mock(MockBehavior.Strict); + _fs + .Setup(f => f.FileSystemInfoFromPath(@"c:\11.sql")) + .Returns(file.Object); + + _sut.Parse(new CommandLine(new Arg("from", @"c:\11.sql"))); + + _sut.Scripts.ShouldBe(new[] { file.Object }); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Configuration/CommandLineFactoryTest.cs b/Sources/SqlDatabase.Test/Configuration/CommandLineFactoryTest.cs index d69e3dc9..d153ca9e 100644 --- a/Sources/SqlDatabase.Test/Configuration/CommandLineFactoryTest.cs +++ b/Sources/SqlDatabase.Test/Configuration/CommandLineFactoryTest.cs @@ -2,61 +2,60 @@ using NUnit.Framework; using Shouldly; -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +[TestFixture] +public class CommandLineFactoryTest { - [TestFixture] - public class CommandLineFactoryTest - { - private CommandLineFactory _sut; + private CommandLineFactory _sut; - [SetUp] - public void BeforeEachTest() - { - _sut = new CommandLineFactory(); - } + [SetUp] + public void BeforeEachTest() + { + _sut = new CommandLineFactory(); + } - [Test] - [TestCase(CommandLineFactory.CommandCreate, typeof(CreateCommandLine))] - [TestCase(CommandLineFactory.CommandUpgrade, typeof(UpgradeCommandLine))] - [TestCase(CommandLineFactory.CommandExecute, typeof(ExecuteCommandLine))] - [TestCase(CommandLineFactory.CommandExport, typeof(ExportCommandLine))] - [TestCase(CommandLineFactory.CommandEcho, typeof(EchoCommandLine))] - public void Bind(string command, Type commandLine) - { - _sut.Args = new CommandLine(new Arg(command)); + [Test] + [TestCase(CommandLineFactory.CommandCreate, typeof(CreateCommandLine))] + [TestCase(CommandLineFactory.CommandUpgrade, typeof(UpgradeCommandLine))] + [TestCase(CommandLineFactory.CommandExecute, typeof(ExecuteCommandLine))] + [TestCase(CommandLineFactory.CommandExport, typeof(ExportCommandLine))] + [TestCase(CommandLineFactory.CommandEcho, typeof(EchoCommandLine))] + public void Bind(string command, Type commandLine) + { + _sut.Args = new CommandLine(new Arg(command)); - _sut.Bind().ShouldBeTrue(); + _sut.Bind().ShouldBeTrue(); - _sut.ActiveCommandName.ShouldBe(command); - _sut.ShowCommandHelp.ShouldBeFalse(); + _sut.ActiveCommandName.ShouldBe(command); + _sut.ShowCommandHelp.ShouldBeFalse(); - CommandLineFactory.CreateCommand(_sut.ActiveCommandName).ShouldBeOfType(commandLine); - } + CommandLineFactory.CreateCommand(_sut.ActiveCommandName).ShouldBeOfType(commandLine); + } - [Test] - public void BindEmptyCommandLine() - { - _sut.Args = new CommandLine(new Arg[0], new string[0]); + [Test] + public void BindEmptyCommandLine() + { + _sut.Args = new CommandLine(new Arg[0], new string[0]); - _sut.Bind().ShouldBeFalse(); - } + _sut.Bind().ShouldBeFalse(); + } - [Test] - public void BindUnknownCommand() - { - _sut.Args = new CommandLine(new Arg("Unknown")); + [Test] + public void BindUnknownCommand() + { + _sut.Args = new CommandLine(new Arg("Unknown")); - var ex = Assert.Throws(() => _sut.Bind()); + var ex = Assert.Throws(() => _sut.Bind()); - ex.Message.ShouldContain("[Unknown]"); - } + ex.Message.ShouldContain("[Unknown]"); + } - [Test] - public void BindNoCommand() - { - _sut.Args = new CommandLine(new Arg("key", "value")); + [Test] + public void BindNoCommand() + { + _sut.Args = new CommandLine(new Arg("key", "value")); - Assert.Throws(() => _sut.Bind()); - } + Assert.Throws(() => _sut.Bind()); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Configuration/CommandLineParserTest.cs b/Sources/SqlDatabase.Test/Configuration/CommandLineParserTest.cs index dd34c5aa..a31c9db8 100644 --- a/Sources/SqlDatabase.Test/Configuration/CommandLineParserTest.cs +++ b/Sources/SqlDatabase.Test/Configuration/CommandLineParserTest.cs @@ -1,85 +1,84 @@ using NUnit.Framework; using Shouldly; -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +[TestFixture] +public class CommandLineParserTest { - [TestFixture] - public class CommandLineParserTest - { - private CommandLineParser _sut; + private CommandLineParser _sut; - [SetUp] - public void BeforeEachTest() - { - _sut = new CommandLineParser(); - } + [SetUp] + public void BeforeEachTest() + { + _sut = new CommandLineParser(); + } - [Test] - [TestCase("-x=y", "x", "y", true)] - [TestCase("x=y", null, "x=y", true)] - [TestCase("-x", "x", null, true)] - [TestCase("-x=", "x", null, true)] - [TestCase("-=x", null, null, false)] - [TestCase("-=", null, null, false)] - [TestCase("-", null, null, false)] - public void SplitArg(string keyValue, string expectedKey, string expectedValue, bool isValid) + [Test] + [TestCase("-x=y", "x", "y", true)] + [TestCase("x=y", null, "x=y", true)] + [TestCase("-x", "x", null, true)] + [TestCase("-x=", "x", null, true)] + [TestCase("-=x", null, null, false)] + [TestCase("-=", null, null, false)] + [TestCase("-", null, null, false)] + public void SplitArg(string keyValue, string expectedKey, string expectedValue, bool isValid) + { + CommandLineParser.ParseArg(keyValue, out var actual).ShouldBe(isValid); + if (isValid) { - CommandLineParser.ParseArg(keyValue, out var actual).ShouldBe(isValid); - if (isValid) + if (expectedKey == null) { - if (expectedKey == null) - { - actual.IsPair.ShouldBeFalse(); + actual.IsPair.ShouldBeFalse(); - actual.Value.ShouldBe(expectedValue); - } - else - { - actual.IsPair.ShouldBeTrue(); + actual.Value.ShouldBe(expectedValue); + } + else + { + actual.IsPair.ShouldBeTrue(); - actual.Key.ShouldBe(expectedKey); - actual.Value.ShouldBe(expectedValue); - } + actual.Key.ShouldBe(expectedKey); + actual.Value.ShouldBe(expectedValue); } } + } - [Test] - public void Parse() - { - var actual = _sut - .Parse( - "execute", - "create", - "-database=connection string", - "-from=folder 1", - "-from=folder 2") - .Args; + [Test] + public void Parse() + { + var actual = _sut + .Parse( + "execute", + "create", + "-database=connection string", + "-from=folder 1", + "-from=folder 2") + .Args; - actual.Count.ShouldBe(5); + actual.Count.ShouldBe(5); - actual[0].IsPair.ShouldBeFalse(); - actual[0].Value.ShouldBe("execute"); + actual[0].IsPair.ShouldBeFalse(); + actual[0].Value.ShouldBe("execute"); - actual[1].IsPair.ShouldBeFalse(); - actual[1].Value.ShouldBe("create"); + actual[1].IsPair.ShouldBeFalse(); + actual[1].Value.ShouldBe("create"); - actual[2].IsPair.ShouldBeTrue(); - actual[2].Key.ShouldBe("database"); - actual[2].Value.ShouldBe("connection string"); + actual[2].IsPair.ShouldBeTrue(); + actual[2].Key.ShouldBe("database"); + actual[2].Value.ShouldBe("connection string"); - actual[3].IsPair.ShouldBeTrue(); - actual[3].Key.ShouldBe("from"); - actual[3].Value.ShouldBe("folder 1"); + actual[3].IsPair.ShouldBeTrue(); + actual[3].Key.ShouldBe("from"); + actual[3].Value.ShouldBe("folder 1"); - actual[4].IsPair.ShouldBeTrue(); - actual[4].Key.ShouldBe("from"); - actual[4].Value.ShouldBe("folder 2"); - } + actual[4].IsPair.ShouldBeTrue(); + actual[4].Key.ShouldBe("from"); + actual[4].Value.ShouldBe("folder 2"); + } - [Test] - public void ParseFail() - { - Assert.Throws(() => _sut.Parse("-")); - } + [Test] + public void ParseFail() + { + Assert.Throws(() => _sut.Parse("-")); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Configuration/ConfigurationManagerTest.cs b/Sources/SqlDatabase.Test/Configuration/ConfigurationManagerTest.cs index 9ab85abd..0380c5d2 100644 --- a/Sources/SqlDatabase.Test/Configuration/ConfigurationManagerTest.cs +++ b/Sources/SqlDatabase.Test/Configuration/ConfigurationManagerTest.cs @@ -5,12 +5,12 @@ using Shouldly; using SqlDatabase.TestApi; -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +[TestFixture] +public class ConfigurationManagerTest { - [TestFixture] - public class ConfigurationManagerTest - { - public const string SomeConfiguration = @" + public const string SomeConfiguration = @"
"; - private ConfigurationManager _sut; + private ConfigurationManager _sut; - [SetUp] - public void BeforeEachTest() - { - _sut = new ConfigurationManager(); - } + [SetUp] + public void BeforeEachTest() + { + _sut = new ConfigurationManager(); + } - [Test] - public void LoadFromCurrentConfiguration() - { - _sut.LoadFrom((string)null); + [Test] + public void LoadFromCurrentConfiguration() + { + _sut.LoadFrom((string)null); - _sut.SqlDatabase.ShouldNotBeNull(); - _sut.SqlDatabase.Variables.AllKeys.ShouldBe(new[] { nameof(ConfigurationManagerTest) }); - _sut.SqlDatabase.Variables[nameof(ConfigurationManagerTest)].Value.ShouldBe(nameof(LoadFromCurrentConfiguration)); - } + _sut.SqlDatabase.ShouldNotBeNull(); + _sut.SqlDatabase.Variables.AllKeys.ShouldBe(new[] { nameof(ConfigurationManagerTest) }); + _sut.SqlDatabase.Variables[nameof(ConfigurationManagerTest)].Value.ShouldBe(nameof(LoadFromCurrentConfiguration)); + } - [Test] - public void LoadFromEmptyFile() - { - var file = FileFactory.File("app.config", ""); + [Test] + public void LoadFromEmptyFile() + { + var file = FileFactory.File("app.config", ""); - _sut.LoadFrom(file); + _sut.LoadFrom(file); - Assert.IsNotNull(_sut.SqlDatabase); - Assert.AreEqual(new AppConfiguration().GetCurrentVersionScript, _sut.SqlDatabase.GetCurrentVersionScript); - } + Assert.IsNotNull(_sut.SqlDatabase); + Assert.AreEqual(new AppConfiguration().GetCurrentVersionScript, _sut.SqlDatabase.GetCurrentVersionScript); + } - [Test] - public void LoadFromFile() - { - var file = FileFactory.File("app.config", SomeConfiguration); + [Test] + public void LoadFromFile() + { + var file = FileFactory.File("app.config", SomeConfiguration); - _sut.LoadFrom(file); + _sut.LoadFrom(file); - Assert.IsNotNull(_sut.SqlDatabase); - Assert.AreEqual("expected", _sut.SqlDatabase.GetCurrentVersionScript); - } + Assert.IsNotNull(_sut.SqlDatabase); + Assert.AreEqual("expected", _sut.SqlDatabase.GetCurrentVersionScript); + } - [Test] - public void LoadFromDirectory() - { - // SqlDatabase.exe.config or SqlDatabase.dll.config - var fileName = Path.GetFileName(_sut.GetType().Assembly.Location) + ".config"; - var file = FileFactory.File(fileName, SomeConfiguration); - var folder = FileFactory.Folder("some folder", file); + [Test] + public void LoadFromDirectory() + { + // SqlDatabase.exe.config or SqlDatabase.dll.config + var fileName = Path.GetFileName(_sut.GetType().Assembly.Location) + ".config"; + var file = FileFactory.File(fileName, SomeConfiguration); + var folder = FileFactory.Folder("some folder", file); - _sut.LoadFrom(folder); + _sut.LoadFrom(folder); - Assert.IsNotNull(_sut.SqlDatabase); - Assert.AreEqual("expected", _sut.SqlDatabase.GetCurrentVersionScript); - } + Assert.IsNotNull(_sut.SqlDatabase); + Assert.AreEqual("expected", _sut.SqlDatabase.GetCurrentVersionScript); + } - [Test] - public void NotFoundInDirectory() - { - var folder = FileFactory.Folder("some folder"); + [Test] + public void NotFoundInDirectory() + { + var folder = FileFactory.Folder("some folder"); - Assert.Throws(() => _sut.LoadFrom(folder)); - } + Assert.Throws(() => _sut.LoadFrom(folder)); + } - [Test] - public void FileNotFound() - { - var file = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); + [Test] + public void FileNotFound() + { + var file = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); - Assert.Throws(() => _sut.LoadFrom(file)); - } + Assert.Throws(() => _sut.LoadFrom(file)); + } - [Test] - public void LoadInvalidConfiguration() - { - var file = FileFactory.File("app.config", ""); + [Test] + public void LoadInvalidConfiguration() + { + var file = FileFactory.File("app.config", ""); - Assert.Throws(() => _sut.LoadFrom(file)); - } + Assert.Throws(() => _sut.LoadFrom(file)); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Configuration/CreateCommandLineTest.cs b/Sources/SqlDatabase.Test/Configuration/CreateCommandLineTest.cs index 1e0f0dad..c8d770c3 100644 --- a/Sources/SqlDatabase.Test/Configuration/CreateCommandLineTest.cs +++ b/Sources/SqlDatabase.Test/Configuration/CreateCommandLineTest.cs @@ -6,79 +6,78 @@ using SqlDatabase.Scripts; using SqlDatabase.TestApi; -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +[TestFixture] +public class CreateCommandLineTest { - [TestFixture] - public class CreateCommandLineTest + private Mock _log; + private Mock _fs; + private CreateCommandLine _sut; + + [SetUp] + public void BeforeEachTest() + { + _log = new Mock(MockBehavior.Strict); + _fs = new Mock(MockBehavior.Strict); + + _sut = new CreateCommandLine { FileSystemFactory = _fs.Object }; + } + + [Test] + public void Parse() { - private Mock _log; - private Mock _fs; - private CreateCommandLine _sut; - - [SetUp] - public void BeforeEachTest() - { - _log = new Mock(MockBehavior.Strict); - _fs = new Mock(MockBehavior.Strict); - - _sut = new CreateCommandLine { FileSystemFactory = _fs.Object }; - } - - [Test] - public void Parse() - { - var folder = new Mock(MockBehavior.Strict); - _fs - .Setup(f => f.FileSystemInfoFromPath(@"c:\folder")) - .Returns(folder.Object); - - _sut.Parse(new CommandLine( - new Arg("database", "Data Source=.;Initial Catalog=test"), - new Arg("from", @"c:\folder"), - new Arg("varX", "1 2 3"), - new Arg("varY", "value"), - new Arg("configuration", "app.config"), + var folder = new Mock(MockBehavior.Strict); + _fs + .Setup(f => f.FileSystemInfoFromPath(@"c:\folder")) + .Returns(folder.Object); + + _sut.Parse(new CommandLine( + new Arg("database", "Data Source=.;Initial Catalog=test"), + new Arg("from", @"c:\folder"), + new Arg("varX", "1 2 3"), + new Arg("varY", "value"), + new Arg("configuration", "app.config"), #if !NET472 - new Arg("usePowerShell", @"c:\PowerShell"), + new Arg("usePowerShell", @"c:\PowerShell"), #endif - new Arg("whatIf"))); + new Arg("whatIf"))); - _sut.Scripts.ShouldBe(new[] { folder.Object }); + _sut.Scripts.ShouldBe(new[] { folder.Object }); - _sut.ConnectionString.ShouldBe("Data Source=.;Initial Catalog=test"); + _sut.ConnectionString.ShouldBe("Data Source=.;Initial Catalog=test"); - _sut.Variables.Keys.ShouldBe(new[] { "X", "Y" }); - _sut.Variables["x"].ShouldBe("1 2 3"); - _sut.Variables["y"].ShouldBe("value"); + _sut.Variables.Keys.ShouldBe(new[] { "X", "Y" }); + _sut.Variables["x"].ShouldBe("1 2 3"); + _sut.Variables["y"].ShouldBe("value"); - _sut.ConfigurationFile.ShouldBe("app.config"); + _sut.ConfigurationFile.ShouldBe("app.config"); #if !NET472 - _sut.UsePowerShell.ShouldBe(@"c:\PowerShell"); + _sut.UsePowerShell.ShouldBe(@"c:\PowerShell"); #endif - _sut.WhatIf.ShouldBeTrue(); - } + _sut.WhatIf.ShouldBeTrue(); + } - [Test] - public void CreateCommand() - { - _sut.WhatIf = true; - _sut.ConnectionString = MsSqlQuery.ConnectionString; - _sut.UsePowerShell = @"c:\PowerShell"; + [Test] + public void CreateCommand() + { + _sut.WhatIf = true; + _sut.ConnectionString = MsSqlQuery.ConnectionString; + _sut.UsePowerShell = @"c:\PowerShell"; - var actual = _sut - .CreateCommand(_log.Object) - .ShouldBeOfType(); + var actual = _sut + .CreateCommand(_log.Object) + .ShouldBeOfType(); - actual.Log.ShouldBe(_log.Object); - var database = actual.Database.ShouldBeOfType(); - database.WhatIf.ShouldBeTrue(); + actual.Log.ShouldBe(_log.Object); + var database = actual.Database.ShouldBeOfType(); + database.WhatIf.ShouldBeTrue(); - var scriptFactory = actual.ScriptSequence.ShouldBeOfType().ScriptFactory.ShouldBeOfType(); - scriptFactory.PowerShellFactory.InstallationPath.ShouldBe(@"c:\PowerShell"); + var scriptFactory = actual.ScriptSequence.ShouldBeOfType().ScriptFactory.ShouldBeOfType(); + scriptFactory.PowerShellFactory.InstallationPath.ShouldBe(@"c:\PowerShell"); - actual.PowerShellFactory.ShouldBe(scriptFactory.PowerShellFactory); - } + actual.PowerShellFactory.ShouldBe(scriptFactory.PowerShellFactory); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Configuration/ExecuteCommandLineTest.cs b/Sources/SqlDatabase.Test/Configuration/ExecuteCommandLineTest.cs index c370b8b5..e8ad6fea 100644 --- a/Sources/SqlDatabase.Test/Configuration/ExecuteCommandLineTest.cs +++ b/Sources/SqlDatabase.Test/Configuration/ExecuteCommandLineTest.cs @@ -6,89 +6,88 @@ using SqlDatabase.Scripts; using SqlDatabase.TestApi; -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +[TestFixture] +public class ExecuteCommandLineTest { - [TestFixture] - public class ExecuteCommandLineTest + private Mock _log; + private Mock _fs; + private ExecuteCommandLine _sut; + + [SetUp] + public void BeforeEachTest() + { + _log = new Mock(MockBehavior.Strict); + _fs = new Mock(MockBehavior.Strict); + + _sut = new ExecuteCommandLine { FileSystemFactory = _fs.Object }; + } + + [Test] + public void Parse() { - private Mock _log; - private Mock _fs; - private ExecuteCommandLine _sut; - - [SetUp] - public void BeforeEachTest() - { - _log = new Mock(MockBehavior.Strict); - _fs = new Mock(MockBehavior.Strict); - - _sut = new ExecuteCommandLine { FileSystemFactory = _fs.Object }; - } - - [Test] - public void Parse() - { - var folder = new Mock(MockBehavior.Strict); - var sql = new Mock(MockBehavior.Strict); - _fs - .Setup(f => f.FileSystemInfoFromPath(@"c:\folder")) - .Returns(folder.Object); - _fs - .Setup(f => f.FromContent("from2.sql", "drop 1")) - .Returns(sql.Object); - - _sut.Parse(new CommandLine( - new Arg("database", "Data Source=.;Initial Catalog=test"), - new Arg("from", @"c:\folder"), - new Arg("fromSql", "drop 1"), - new Arg("varX", "1 2 3"), - new Arg("varY", "value"), - new Arg("configuration", "app.config"), - new Arg("transaction", "perStep"), + var folder = new Mock(MockBehavior.Strict); + var sql = new Mock(MockBehavior.Strict); + _fs + .Setup(f => f.FileSystemInfoFromPath(@"c:\folder")) + .Returns(folder.Object); + _fs + .Setup(f => f.FromContent("from2.sql", "drop 1")) + .Returns(sql.Object); + + _sut.Parse(new CommandLine( + new Arg("database", "Data Source=.;Initial Catalog=test"), + new Arg("from", @"c:\folder"), + new Arg("fromSql", "drop 1"), + new Arg("varX", "1 2 3"), + new Arg("varY", "value"), + new Arg("configuration", "app.config"), + new Arg("transaction", "perStep"), #if !NET472 - new Arg("usePowerShell", @"c:\PowerShell"), + new Arg("usePowerShell", @"c:\PowerShell"), #endif - new Arg("whatIf"))); + new Arg("whatIf"))); - _sut.Scripts.Count.ShouldBe(2); - _sut.Scripts[0].ShouldBe(folder.Object); - _sut.Scripts[1].ShouldBe(sql.Object); + _sut.Scripts.Count.ShouldBe(2); + _sut.Scripts[0].ShouldBe(folder.Object); + _sut.Scripts[1].ShouldBe(sql.Object); - _sut.ConnectionString.ShouldBe("Data Source=.;Initial Catalog=test"); + _sut.ConnectionString.ShouldBe("Data Source=.;Initial Catalog=test"); - _sut.Variables.Keys.ShouldBe(new[] { "X", "Y" }); - _sut.Variables["x"].ShouldBe("1 2 3"); - _sut.Variables["y"].ShouldBe("value"); + _sut.Variables.Keys.ShouldBe(new[] { "X", "Y" }); + _sut.Variables["x"].ShouldBe("1 2 3"); + _sut.Variables["y"].ShouldBe("value"); - _sut.ConfigurationFile.ShouldBe("app.config"); + _sut.ConfigurationFile.ShouldBe("app.config"); - _sut.Transaction.ShouldBe(TransactionMode.PerStep); + _sut.Transaction.ShouldBe(TransactionMode.PerStep); #if !NET472 - _sut.UsePowerShell.ShouldBe(@"c:\PowerShell"); + _sut.UsePowerShell.ShouldBe(@"c:\PowerShell"); #endif - _sut.WhatIf.ShouldBeTrue(); - } + _sut.WhatIf.ShouldBeTrue(); + } - [Test] - public void CreateCommand() - { - _sut.WhatIf = true; - _sut.ConnectionString = MsSqlQuery.ConnectionString; - _sut.UsePowerShell = @"c:\PowerShell"; + [Test] + public void CreateCommand() + { + _sut.WhatIf = true; + _sut.ConnectionString = MsSqlQuery.ConnectionString; + _sut.UsePowerShell = @"c:\PowerShell"; - var actual = _sut - .CreateCommand(_log.Object) - .ShouldBeOfType(); + var actual = _sut + .CreateCommand(_log.Object) + .ShouldBeOfType(); - actual.Log.ShouldBe(_log.Object); - var database = actual.Database.ShouldBeOfType(); - database.WhatIf.ShouldBeTrue(); + actual.Log.ShouldBe(_log.Object); + var database = actual.Database.ShouldBeOfType(); + database.WhatIf.ShouldBeTrue(); - var scriptFactory = actual.ScriptSequence.ShouldBeOfType().ScriptFactory.ShouldBeOfType(); - scriptFactory.PowerShellFactory.InstallationPath.ShouldBe(@"c:\PowerShell"); + var scriptFactory = actual.ScriptSequence.ShouldBeOfType().ScriptFactory.ShouldBeOfType(); + scriptFactory.PowerShellFactory.InstallationPath.ShouldBe(@"c:\PowerShell"); - actual.PowerShellFactory.ShouldBe(scriptFactory.PowerShellFactory); - } + actual.PowerShellFactory.ShouldBe(scriptFactory.PowerShellFactory); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Configuration/ExportCommandLineTest.cs b/Sources/SqlDatabase.Test/Configuration/ExportCommandLineTest.cs index 2e3ee741..5e0538c5 100644 --- a/Sources/SqlDatabase.Test/Configuration/ExportCommandLineTest.cs +++ b/Sources/SqlDatabase.Test/Configuration/ExportCommandLineTest.cs @@ -8,126 +8,125 @@ using SqlDatabase.Scripts; using SqlDatabase.TestApi; -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +[TestFixture] +public class ExportCommandLineTest { - [TestFixture] - public class ExportCommandLineTest + private Mock _log; + private Mock _fs; + private ExportCommandLine _sut; + + [SetUp] + public void BeforeEachTest() { - private Mock _log; - private Mock _fs; - private ExportCommandLine _sut; + _log = new Mock(MockBehavior.Strict); + _fs = new Mock(MockBehavior.Strict); - [SetUp] - public void BeforeEachTest() - { - _log = new Mock(MockBehavior.Strict); - _fs = new Mock(MockBehavior.Strict); + _sut = new ExportCommandLine { FileSystemFactory = _fs.Object }; + } - _sut = new ExportCommandLine { FileSystemFactory = _fs.Object }; - } + [Test] + public void Parse() + { + var folder = new Mock(MockBehavior.Strict); + var sql = new Mock(MockBehavior.Strict); + _fs + .Setup(f => f.FileSystemInfoFromPath(@"c:\folder")) + .Returns(folder.Object); + _fs + .Setup(f => f.FromContent("from1.sql", "select 1")) + .Returns(sql.Object); + + _sut.Parse(new CommandLine( + new Arg("database", "Data Source=.;Initial Catalog=test"), + new Arg("fromSql", "select 1"), + new Arg("from", @"c:\folder"), + new Arg("toTable", "dbo.ExportedData"), + new Arg("toFile", "file path"))); + + _sut.Scripts.Count.ShouldBe(2); + _sut.Scripts[0].ShouldBe(sql.Object); + _sut.Scripts[1].ShouldBe(folder.Object); + + _sut.ConnectionString.ShouldBe("Data Source=.;Initial Catalog=test"); + _sut.DestinationTableName.ShouldBe("dbo.ExportedData"); + _sut.DestinationFileName.ShouldBe("file path"); + } - [Test] - public void Parse() - { - var folder = new Mock(MockBehavior.Strict); - var sql = new Mock(MockBehavior.Strict); - _fs - .Setup(f => f.FileSystemInfoFromPath(@"c:\folder")) - .Returns(folder.Object); - _fs - .Setup(f => f.FromContent("from1.sql", "select 1")) - .Returns(sql.Object); - - _sut.Parse(new CommandLine( - new Arg("database", "Data Source=.;Initial Catalog=test"), - new Arg("fromSql", "select 1"), - new Arg("from", @"c:\folder"), - new Arg("toTable", "dbo.ExportedData"), - new Arg("toFile", "file path"))); - - _sut.Scripts.Count.ShouldBe(2); - _sut.Scripts[0].ShouldBe(sql.Object); - _sut.Scripts[1].ShouldBe(folder.Object); - - _sut.ConnectionString.ShouldBe("Data Source=.;Initial Catalog=test"); - _sut.DestinationTableName.ShouldBe("dbo.ExportedData"); - _sut.DestinationFileName.ShouldBe("file path"); - } + [Test] + public void CreateCommand() + { + _sut.ConnectionString = MsSqlQuery.ConnectionString; + _sut.DestinationTableName = "table 1"; + + var actual = _sut + .CreateCommand(_log.Object) + .ShouldBeOfType(); + + actual.Log.ShouldNotBe(_log.Object); + actual.Database.ShouldBeOfType(); + actual.ScriptSequence.ShouldBeOfType(); + actual.OpenOutput.ShouldNotBeNull(); + actual.DestinationTableName.ShouldBe("table 1"); + } - [Test] - public void CreateCommand() - { - _sut.ConnectionString = MsSqlQuery.ConnectionString; - _sut.DestinationTableName = "table 1"; - - var actual = _sut - .CreateCommand(_log.Object) - .ShouldBeOfType(); - - actual.Log.ShouldNotBe(_log.Object); - actual.Database.ShouldBeOfType(); - actual.ScriptSequence.ShouldBeOfType(); - actual.OpenOutput.ShouldNotBeNull(); - actual.DestinationTableName.ShouldBe("table 1"); - } + [Test] + public void CreateOutputConsole() + { + var actual = _sut.CreateOutput(); - [Test] - public void CreateOutputConsole() + string output; + using (var console = new TempConsoleOut()) { - var actual = _sut.CreateOutput(); - - string output; - using (var console = new TempConsoleOut()) + using (var writer = actual()) { - using (var writer = actual()) - { - writer.Write("hello"); - } - - output = console.GetOutput(); + writer.Write("hello"); } - output.ShouldBe("hello"); + output = console.GetOutput(); } - [Test] - public void WrapLoggerConsole() - { - _sut.WrapLogger(_log.Object).ShouldBeOfType(); - } + output.ShouldBe("hello"); + } - [Test] - public void CreateOutputFile() - { - using (var file = new TempFile(".sql")) - { - _sut.DestinationFileName = file.Location; + [Test] + public void WrapLoggerConsole() + { + _sut.WrapLogger(_log.Object).ShouldBeOfType(); + } - var actual = _sut.CreateOutput(); + [Test] + public void CreateOutputFile() + { + using (var file = new TempFile(".sql")) + { + _sut.DestinationFileName = file.Location; - using (var writer = actual()) - { - writer.Write("hello 1"); - } + var actual = _sut.CreateOutput(); - FileAssert.Exists(file.Location); - File.ReadAllText(file.Location).ShouldBe("hello 1"); + using (var writer = actual()) + { + writer.Write("hello 1"); + } - using (var writer = actual()) - { - writer.Write("hello 2"); - } + FileAssert.Exists(file.Location); + File.ReadAllText(file.Location).ShouldBe("hello 1"); - File.ReadAllText(file.Location).ShouldBe("hello 2"); + using (var writer = actual()) + { + writer.Write("hello 2"); } + + File.ReadAllText(file.Location).ShouldBe("hello 2"); } + } - [Test] - public void WrapLoggerFile() - { - _sut.DestinationFileName = "file"; + [Test] + public void WrapLoggerFile() + { + _sut.DestinationFileName = "file"; - _sut.WrapLogger(_log.Object).ShouldBe(_log.Object); - } + _sut.WrapLogger(_log.Object).ShouldBe(_log.Object); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Configuration/GenericCommandLineBuilderTest.cs b/Sources/SqlDatabase.Test/Configuration/GenericCommandLineBuilderTest.cs index 66f7cbed..9f176ed8 100644 --- a/Sources/SqlDatabase.Test/Configuration/GenericCommandLineBuilderTest.cs +++ b/Sources/SqlDatabase.Test/Configuration/GenericCommandLineBuilderTest.cs @@ -2,119 +2,118 @@ using NUnit.Framework; using Shouldly; -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +[TestFixture] +public class GenericCommandLineBuilderTest { - [TestFixture] - public class GenericCommandLineBuilderTest + private GenericCommandLineBuilder _sut; + + [SetUp] + public void BeforeEachTest() { - private GenericCommandLineBuilder _sut; + _sut = new GenericCommandLineBuilder(); + } - [SetUp] - public void BeforeEachTest() + [Test] + public void BuildArray() + { + var args = _sut + .SetCommand("some command") + .SetConnection("Data Source=.;Initial Catalog=SqlDatabaseTest") + .SetScripts("file1") + .SetScripts("file2") + .SetConfigurationFile("configuration file") + .SetTransaction(TransactionMode.PerStep) + .SetVariable("var1", "value 1") + .SetWhatIf(true) + .SetFolderAsModuleName(true) + .SetLogFileName("log file") + .BuildArray(); + + foreach (var arg in args) { - _sut = new GenericCommandLineBuilder(); + Console.WriteLine(arg); } - [Test] - public void BuildArray() - { - var args = _sut - .SetCommand("some command") - .SetConnection("Data Source=.;Initial Catalog=SqlDatabaseTest") - .SetScripts("file1") - .SetScripts("file2") - .SetConfigurationFile("configuration file") - .SetTransaction(TransactionMode.PerStep) - .SetVariable("var1", "value 1") - .SetWhatIf(true) - .SetFolderAsModuleName(true) - .SetLogFileName("log file") - .BuildArray(); - - foreach (var arg in args) - { - Console.WriteLine(arg); - } + CommandLineParser.GetLogFileName(args).ShouldBe("log file"); + var actual = new CommandLineParser().Parse(args); - CommandLineParser.GetLogFileName(args).ShouldBe("log file"); - var actual = new CommandLineParser().Parse(args); + actual.Args.Count.ShouldBe(9); - actual.Args.Count.ShouldBe(9); + actual.Args[0].IsPair.ShouldBe(false); + actual.Args[0].Value.ShouldBe("some command"); - actual.Args[0].IsPair.ShouldBe(false); - actual.Args[0].Value.ShouldBe("some command"); + actual.Args[1].Key.ShouldBe("database"); + actual.Args[1].Value.ShouldBe("Data Source=.;Initial Catalog=SqlDatabaseTest"); - actual.Args[1].Key.ShouldBe("database"); - actual.Args[1].Value.ShouldBe("Data Source=.;Initial Catalog=SqlDatabaseTest"); + actual.Args[2].Key.ShouldBe("from"); + actual.Args[2].Value.ShouldBe("file1"); - actual.Args[2].Key.ShouldBe("from"); - actual.Args[2].Value.ShouldBe("file1"); + actual.Args[3].Key.ShouldBe("from"); + actual.Args[3].Value.ShouldBe("file2"); - actual.Args[3].Key.ShouldBe("from"); - actual.Args[3].Value.ShouldBe("file2"); + actual.Args[4].Key.ShouldBe("transaction"); + actual.Args[4].Value.ShouldBe("PerStep"); - actual.Args[4].Key.ShouldBe("transaction"); - actual.Args[4].Value.ShouldBe("PerStep"); + actual.Args[5].Key.ShouldBe("configuration"); + actual.Args[5].Value.ShouldBe("configuration file"); - actual.Args[5].Key.ShouldBe("configuration"); - actual.Args[5].Value.ShouldBe("configuration file"); + actual.Args[6].Key.ShouldBe("varvar1"); + actual.Args[6].Value.ShouldBe("value 1"); - actual.Args[6].Key.ShouldBe("varvar1"); - actual.Args[6].Value.ShouldBe("value 1"); + actual.Args[7].Key.ShouldBe("whatIf"); + actual.Args[7].Value.ShouldBe("True"); - actual.Args[7].Key.ShouldBe("whatIf"); - actual.Args[7].Value.ShouldBe("True"); - - actual.Args[8].Key.ShouldBe("folderAsModuleName"); - actual.Args[8].Value.ShouldBe("True"); - } + actual.Args[8].Key.ShouldBe("folderAsModuleName"); + actual.Args[8].Value.ShouldBe("True"); + } - [Test] - public void BuildArrayScripts() - { - var actual = _sut - .SetScripts("file1") - .SetScripts("file2") - .BuildArray(); - - actual.Length.ShouldBe(4); - actual[2].ShouldBe("-from=file1"); - actual[3].ShouldBe("-from=file2"); - } + [Test] + public void BuildArrayScripts() + { + var actual = _sut + .SetScripts("file1") + .SetScripts("file2") + .BuildArray(); + + actual.Length.ShouldBe(4); + actual[2].ShouldBe("-from=file1"); + actual[3].ShouldBe("-from=file2"); + } - [Test] - public void BuildArrayInLineScripts() - { - var actual = _sut - .SetInLineScript("file1") - .SetInLineScript("file2") - .BuildArray(); - - actual.Length.ShouldBe(4); - actual[2].ShouldBe("-fromSql=file1"); - actual[3].ShouldBe("-fromSql=file2"); - } + [Test] + public void BuildArrayInLineScripts() + { + var actual = _sut + .SetInLineScript("file1") + .SetInLineScript("file2") + .BuildArray(); + + actual.Length.ShouldBe(4); + actual[2].ShouldBe("-fromSql=file1"); + actual[3].ShouldBe("-fromSql=file2"); + } - [Test] - public void BuildArrayExportToTable() - { - var actual = _sut - .SetExportToTable("name") - .BuildArray(); + [Test] + public void BuildArrayExportToTable() + { + var actual = _sut + .SetExportToTable("name") + .BuildArray(); - actual.Length.ShouldBe(3); - actual[2].ShouldBe("-toTable=name"); - } + actual.Length.ShouldBe(3); + actual[2].ShouldBe("-toTable=name"); + } - [Test] - public void BuildArrayExportToFile() - { - var actual = _sut - .SetExportToFile("file name") - .BuildArray(); + [Test] + public void BuildArrayExportToFile() + { + var actual = _sut + .SetExportToFile("file name") + .BuildArray(); - actual.Length.ShouldBe(3); - actual[2].ShouldBe("-toFile=file name"); - } + actual.Length.ShouldBe(3); + actual[2].ShouldBe("-toFile=file name"); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Configuration/UpgradeCommandLineTest.cs b/Sources/SqlDatabase.Test/Configuration/UpgradeCommandLineTest.cs index eaa6a050..58abace4 100644 --- a/Sources/SqlDatabase.Test/Configuration/UpgradeCommandLineTest.cs +++ b/Sources/SqlDatabase.Test/Configuration/UpgradeCommandLineTest.cs @@ -6,89 +6,88 @@ using SqlDatabase.Scripts; using SqlDatabase.TestApi; -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +[TestFixture] +public class UpgradeCommandLineTest { - [TestFixture] - public class UpgradeCommandLineTest + private Mock _log; + private Mock _fs; + private UpgradeCommandLine _sut; + + [SetUp] + public void BeforeEachTest() + { + _log = new Mock(MockBehavior.Strict); + _fs = new Mock(MockBehavior.Strict); + + _sut = new UpgradeCommandLine { FileSystemFactory = _fs.Object }; + } + + [Test] + public void Parse() { - private Mock _log; - private Mock _fs; - private UpgradeCommandLine _sut; - - [SetUp] - public void BeforeEachTest() - { - _log = new Mock(MockBehavior.Strict); - _fs = new Mock(MockBehavior.Strict); - - _sut = new UpgradeCommandLine { FileSystemFactory = _fs.Object }; - } - - [Test] - public void Parse() - { - var folder = new Mock(MockBehavior.Strict); - _fs - .Setup(f => f.FileSystemInfoFromPath(@"c:\folder")) - .Returns(folder.Object); - - _sut.Parse(new CommandLine( - new Arg("database", "Data Source=.;Initial Catalog=test"), - new Arg("from", @"c:\folder"), - new Arg("varX", "1 2 3"), - new Arg("varY", "value"), - new Arg("configuration", "app.config"), - new Arg("transaction", "perStep"), - new Arg("folderAsModuleName"), + var folder = new Mock(MockBehavior.Strict); + _fs + .Setup(f => f.FileSystemInfoFromPath(@"c:\folder")) + .Returns(folder.Object); + + _sut.Parse(new CommandLine( + new Arg("database", "Data Source=.;Initial Catalog=test"), + new Arg("from", @"c:\folder"), + new Arg("varX", "1 2 3"), + new Arg("varY", "value"), + new Arg("configuration", "app.config"), + new Arg("transaction", "perStep"), + new Arg("folderAsModuleName"), #if !NET472 - new Arg("usePowerShell", @"c:\PowerShell"), + new Arg("usePowerShell", @"c:\PowerShell"), #endif - new Arg("whatIf"))); + new Arg("whatIf"))); - _sut.Scripts.ShouldBe(new[] { folder.Object }); + _sut.Scripts.ShouldBe(new[] { folder.Object }); - _sut.ConnectionString.ShouldBe("Data Source=.;Initial Catalog=test"); + _sut.ConnectionString.ShouldBe("Data Source=.;Initial Catalog=test"); - _sut.Variables.Keys.ShouldBe(new[] { "X", "Y" }); - _sut.Variables["x"].ShouldBe("1 2 3"); - _sut.Variables["y"].ShouldBe("value"); + _sut.Variables.Keys.ShouldBe(new[] { "X", "Y" }); + _sut.Variables["x"].ShouldBe("1 2 3"); + _sut.Variables["y"].ShouldBe("value"); - _sut.ConfigurationFile.ShouldBe("app.config"); + _sut.ConfigurationFile.ShouldBe("app.config"); - _sut.Transaction.ShouldBe(TransactionMode.PerStep); + _sut.Transaction.ShouldBe(TransactionMode.PerStep); #if !NET472 - _sut.UsePowerShell.ShouldBe(@"c:\PowerShell"); + _sut.UsePowerShell.ShouldBe(@"c:\PowerShell"); #endif - _sut.WhatIf.ShouldBeTrue(); - _sut.FolderAsModuleName.ShouldBeTrue(); - } + _sut.WhatIf.ShouldBeTrue(); + _sut.FolderAsModuleName.ShouldBeTrue(); + } - [Test] - public void CreateCommand() - { - _sut.WhatIf = true; - _sut.FolderAsModuleName = true; - _sut.ConnectionString = MsSqlQuery.ConnectionString; - _sut.UsePowerShell = @"c:\PowerShell"; + [Test] + public void CreateCommand() + { + _sut.WhatIf = true; + _sut.FolderAsModuleName = true; + _sut.ConnectionString = MsSqlQuery.ConnectionString; + _sut.UsePowerShell = @"c:\PowerShell"; - var actual = _sut - .CreateCommand(_log.Object) - .ShouldBeOfType(); + var actual = _sut + .CreateCommand(_log.Object) + .ShouldBeOfType(); - actual.Log.ShouldBe(_log.Object); - var database = actual.Database.ShouldBeOfType(); - database.WhatIf.ShouldBeTrue(); + actual.Log.ShouldBe(_log.Object); + var database = actual.Database.ShouldBeOfType(); + database.WhatIf.ShouldBeTrue(); - var sequence = actual.ScriptSequence.ShouldBeOfType(); - sequence.WhatIf.ShouldBeTrue(); - sequence.FolderAsModuleName.ShouldBeTrue(); + var sequence = actual.ScriptSequence.ShouldBeOfType(); + sequence.WhatIf.ShouldBeTrue(); + sequence.FolderAsModuleName.ShouldBeTrue(); - var scriptFactory = sequence.ScriptFactory.ShouldBeOfType(); - scriptFactory.PowerShellFactory.InstallationPath.ShouldBe(@"c:\PowerShell"); + var scriptFactory = sequence.ScriptFactory.ShouldBeOfType(); + scriptFactory.PowerShellFactory.InstallationPath.ShouldBe(@"c:\PowerShell"); - actual.PowerShellFactory.ShouldBe(scriptFactory.PowerShellFactory); - } + actual.PowerShellFactory.ShouldBe(scriptFactory.PowerShellFactory); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Export/DataExportLoggerTest.cs b/Sources/SqlDatabase.Test/Export/DataExportLoggerTest.cs index f886dec8..ccaa66fe 100644 --- a/Sources/SqlDatabase.Test/Export/DataExportLoggerTest.cs +++ b/Sources/SqlDatabase.Test/Export/DataExportLoggerTest.cs @@ -3,45 +3,44 @@ using NUnit.Framework; using Shouldly; -namespace SqlDatabase.Export +namespace SqlDatabase.Export; + +[TestFixture] +public class DataExportLoggerTest { - [TestFixture] - public class DataExportLoggerTest + private DataExportLogger _sut; + private IList _output; + + [SetUp] + public void BeforeEachTest() + { + _output = new List(); + + var logger = new Mock(MockBehavior.Strict); + logger + .Setup(l => l.Info(It.IsAny())) + .Callback(m => _output.Add(m)); + logger + .Setup(l => l.Error(It.IsAny())) + .Callback(m => _output.Add(m)); + + _sut = new DataExportLogger(logger.Object); + } + + [Test] + public void IgnoreInfo() + { + _sut.Info("some text"); + + _output.ShouldBeEmpty(); + } + + [Test] + public void SqlEscapeError() { - private DataExportLogger _sut; - private IList _output; - - [SetUp] - public void BeforeEachTest() - { - _output = new List(); - - var logger = new Mock(MockBehavior.Strict); - logger - .Setup(l => l.Info(It.IsAny())) - .Callback(m => _output.Add(m)); - logger - .Setup(l => l.Error(It.IsAny())) - .Callback(m => _output.Add(m)); - - _sut = new DataExportLogger(logger.Object); - } - - [Test] - public void IgnoreInfo() - { - _sut.Info("some text"); - - _output.ShouldBeEmpty(); - } - - [Test] - public void SqlEscapeError() - { - _sut.Error("some text"); - - _output.Count.ShouldBe(1); - _output[0].ShouldBe("-- some text"); - } + _sut.Error("some text"); + + _output.Count.ShouldBe(1); + _output[0].ShouldBe("-- some text"); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Export/MsSqlDataExporterTest.cs b/Sources/SqlDatabase.Test/Export/MsSqlDataExporterTest.cs index 471b5444..99e67446 100644 --- a/Sources/SqlDatabase.Test/Export/MsSqlDataExporterTest.cs +++ b/Sources/SqlDatabase.Test/Export/MsSqlDataExporterTest.cs @@ -9,258 +9,257 @@ using SqlDatabase.Scripts.MsSql; using SqlDatabase.TestApi; -namespace SqlDatabase.Export +namespace SqlDatabase.Export; + +[TestFixture] +public class MsSqlDataExporterTest { - [TestFixture] - public class MsSqlDataExporterTest + private StringBuilder _output; + private DataExporter _sut; + + [SetUp] + public void BeforeEachTest() { - private StringBuilder _output; - private DataExporter _sut; + _output = new StringBuilder(); - [SetUp] - public void BeforeEachTest() - { - _output = new StringBuilder(); + var log = new Mock(MockBehavior.Strict); + log + .Setup(l => l.Info(It.IsAny())) + .Callback(m => Console.WriteLine("Info: {0}", m)); - var log = new Mock(MockBehavior.Strict); - log - .Setup(l => l.Info(It.IsAny())) - .Callback(m => Console.WriteLine("Info: {0}", m)); + _sut = new DataExporter + { + Log = log.Object, + Output = new MsSqlWriter(new StringWriter(_output)) + }; + } - _sut = new DataExporter - { - Log = log.Object, - Output = new MsSqlWriter(new StringWriter(_output)) - }; - } + [Test] + [TestCaseSource(nameof(GetExportCases))] + public void Export(string dataType, object minValue, object maxValue) + { + var sql = new StringBuilder(); + var script = new MsSqlWriter(new StringWriter(sql)) + .TextFormat("DECLARE @input TABLE(Value {0} NULL)", dataType) + .Line() + .Line("INSERT INTO @input VALUES"); - [Test] - [TestCaseSource(nameof(GetExportCases))] - public void Export(string dataType, object minValue, object maxValue) - { - var sql = new StringBuilder(); - var script = new MsSqlWriter(new StringWriter(sql)) - .TextFormat("DECLARE @input TABLE(Value {0} NULL)", dataType) - .Line() - .Line("INSERT INTO @input VALUES"); + script.Text("(").Value(minValue).Line(")"); + script.Text(",(").Value(maxValue).Line(")"); + script.Text(",(").Value(null).Line(")"); - script.Text("(").Value(minValue).Line(")"); - script.Text(",(").Value(maxValue).Line(")"); - script.Text(",(").Value(null).Line(")"); + script.Text("SELECT * FROM @input"); - script.Text("SELECT * FROM @input"); + using (var connection = new SqlConnection(MsSqlQuery.ConnectionString)) + using (var cmd = connection.CreateCommand()) + { + cmd.CommandText = sql.ToString(); + connection.Open(); - using (var connection = new SqlConnection(MsSqlQuery.ConnectionString)) - using (var cmd = connection.CreateCommand()) + using (var reader = cmd.ExecuteReader()) { - cmd.CommandText = sql.ToString(); - connection.Open(); - - using (var reader = cmd.ExecuteReader()) - { - _sut.Export(reader, "#tmp"); - } + _sut.Export(reader, "#tmp"); } + } - var exportSql = _output.ToString(); - Console.WriteLine(exportSql); + var exportSql = _output.ToString(); + Console.WriteLine(exportSql); - exportSql.ShouldContain(" " + dataType + " "); + exportSql.ShouldContain(" " + dataType + " "); - using (var connection = new SqlConnection(MsSqlQuery.ConnectionString)) - using (var cmd = connection.CreateCommand()) - { - cmd.CommandText = exportSql.Replace("GO", string.Empty) + "\r\n\r\nSELECT * FROM #tmp"; - connection.Open(); + using (var connection = new SqlConnection(MsSqlQuery.ConnectionString)) + using (var cmd = connection.CreateCommand()) + { + cmd.CommandText = exportSql.Replace("GO", string.Empty) + "\r\n\r\nSELECT * FROM #tmp"; + connection.Open(); - using (var reader = cmd.ExecuteReader()) - { - reader.Read().ShouldBeTrue(); - reader[0].ShouldBe(minValue); + using (var reader = cmd.ExecuteReader()) + { + reader.Read().ShouldBeTrue(); + reader[0].ShouldBe(minValue); - reader.Read().ShouldBeTrue(); - reader[0].ShouldBe(maxValue); + reader.Read().ShouldBeTrue(); + reader[0].ShouldBe(maxValue); - reader.Read().ShouldBeTrue(); - reader[0].ShouldBe(DBNull.Value); - } + reader.Read().ShouldBeTrue(); + reader[0].ShouldBe(DBNull.Value); } } + } - [Test] - public void ExportReplaceRowVersionWithVarbinary() + [Test] + public void ExportReplaceRowVersionWithVarbinary() + { + using (var connection = new SqlConnection(MsSqlQuery.ConnectionString)) + using (var cmd = connection.CreateCommand()) { - using (var connection = new SqlConnection(MsSqlQuery.ConnectionString)) - using (var cmd = connection.CreateCommand()) - { - cmd.CommandText = @" + cmd.CommandText = @" declare @x table (Id int, Ver rowversion) insert into @x(Id) values(1) select * from @x"; - connection.Open(); + connection.Open(); - using (var reader = cmd.ExecuteReader()) - { - var table = _sut.Output.ReadSchemaTable(reader.GetSchemaTable(), "#tmp"); - table.Columns[1].SqlDataTypeName.ShouldBe("VARBINARY"); - table.Columns[1].Size.ShouldBe(8); + using (var reader = cmd.ExecuteReader()) + { + var table = _sut.Output.ReadSchemaTable(reader.GetSchemaTable(), "#tmp"); + table.Columns[1].SqlDataTypeName.ShouldBe("VARBINARY"); + table.Columns[1].Size.ShouldBe(8); - _sut.Export(reader, "#tmp"); - } + _sut.Export(reader, "#tmp"); } + } - var exportSql = _output.ToString(); - Console.WriteLine(exportSql); + var exportSql = _output.ToString(); + Console.WriteLine(exportSql); + + using (var connection = new SqlConnection(MsSqlQuery.ConnectionString)) + using (var cmd = connection.CreateCommand()) + { + cmd.CommandText = exportSql.Replace("GO", string.Empty) + "\r\n\r\nSELECT * FROM #tmp"; + connection.Open(); - using (var connection = new SqlConnection(MsSqlQuery.ConnectionString)) - using (var cmd = connection.CreateCommand()) + using (var reader = cmd.ExecuteReader()) { - cmd.CommandText = exportSql.Replace("GO", string.Empty) + "\r\n\r\nSELECT * FROM #tmp"; - connection.Open(); - - using (var reader = cmd.ExecuteReader()) - { - reader.Read().ShouldBeTrue(); - reader.Read().ShouldBeFalse(); - } + reader.Read().ShouldBeTrue(); + reader.Read().ShouldBeFalse(); } } + } - [Test] - public void ExportHierarchyId() + [Test] + public void ExportHierarchyId() + { + using (var connection = new SqlConnection(MsSqlQuery.ConnectionString)) + using (var cmd = connection.CreateCommand()) { - using (var connection = new SqlConnection(MsSqlQuery.ConnectionString)) - using (var cmd = connection.CreateCommand()) - { - cmd.CommandText = @" + cmd.CommandText = @" declare @x table (Id HIERARCHYID) insert into @x values('/1/') select * from @x"; - connection.Open(); + connection.Open(); - using (var reader = cmd.ExecuteReader()) - { - Assert.Throws(() => _sut.Output.ReadSchemaTable(reader.GetSchemaTable(), "#tmp")); - } + using (var reader = cmd.ExecuteReader()) + { + Assert.Throws(() => _sut.Output.ReadSchemaTable(reader.GetSchemaTable(), "#tmp")); } } + } - [Test] - public void EmptySchemaTable() + [Test] + public void EmptySchemaTable() + { + ExportTable actual; + + using (var connection = new SqlConnection(MsSqlQuery.ConnectionString)) + using (var cmd = connection.CreateCommand()) { - ExportTable actual; + cmd.CommandText = "select 1, N'2' x, NULL"; + connection.Open(); - using (var connection = new SqlConnection(MsSqlQuery.ConnectionString)) - using (var cmd = connection.CreateCommand()) + using (var reader = cmd.ExecuteReader()) { - cmd.CommandText = "select 1, N'2' x, NULL"; - connection.Open(); - - using (var reader = cmd.ExecuteReader()) - { - actual = _sut.Output.ReadSchemaTable(reader.GetSchemaTable(), "#tmp"); - } + actual = _sut.Output.ReadSchemaTable(reader.GetSchemaTable(), "#tmp"); } + } - actual.Columns.Count.ShouldBe(3); + actual.Columns.Count.ShouldBe(3); - actual.Columns[0].Name.ShouldBe("GeneratedName1"); - actual.Columns[0].AllowNull.ShouldBeFalse(); - actual.Columns[0].SqlDataTypeName.ShouldBe("int"); + actual.Columns[0].Name.ShouldBe("GeneratedName1"); + actual.Columns[0].AllowNull.ShouldBeFalse(); + actual.Columns[0].SqlDataTypeName.ShouldBe("int"); - actual.Columns[1].Name.ShouldBe("x"); - actual.Columns[1].AllowNull.ShouldBeFalse(); - actual.Columns[1].SqlDataTypeName.ShouldBe("nvarchar"); + actual.Columns[1].Name.ShouldBe("x"); + actual.Columns[1].AllowNull.ShouldBeFalse(); + actual.Columns[1].SqlDataTypeName.ShouldBe("nvarchar"); - actual.Columns[2].Name.ShouldBe("GeneratedName2"); - actual.Columns[2].AllowNull.ShouldBeTrue(); - actual.Columns[2].SqlDataTypeName.ShouldBe("int"); - } + actual.Columns[2].Name.ShouldBe("GeneratedName2"); + actual.Columns[2].AllowNull.ShouldBeTrue(); + actual.Columns[2].SqlDataTypeName.ShouldBe("int"); + } - [Test] - public void InsertBatchSize() + [Test] + public void InsertBatchSize() + { + string slq500; + string slq2; + + using (var connection = new SqlConnection(MsSqlQuery.ConnectionString)) + using (var cmd = connection.CreateCommand()) { - string slq500; - string slq2; + cmd.CommandText = "select * from sys.databases"; + connection.Open(); - using (var connection = new SqlConnection(MsSqlQuery.ConnectionString)) - using (var cmd = connection.CreateCommand()) + using (var reader = cmd.ExecuteReader()) { - cmd.CommandText = "select * from sys.databases"; - connection.Open(); - - using (var reader = cmd.ExecuteReader()) - { - _sut.Export(reader, "#tmp"); - slq500 = _output.ToString(); - } - - _output.Clear(); - _sut.MaxInsertBatchSize = 2; - using (var reader = cmd.ExecuteReader()) - { - _sut.Export(reader, "#tmp"); - slq2 = _output.ToString(); - } + _sut.Export(reader, "#tmp"); + slq500 = _output.ToString(); } - Console.WriteLine(slq2); - - slq2.Length.ShouldBeGreaterThan(slq500.Length); + _output.Clear(); + _sut.MaxInsertBatchSize = 2; + using (var reader = cmd.ExecuteReader()) + { + _sut.Export(reader, "#tmp"); + slq2 = _output.ToString(); + } } - private static IEnumerable GetExportCases() - { - yield return new TestCaseData("BIGINT", long.MinValue, long.MaxValue) { TestName = "BIGINT" }; - yield return new TestCaseData("BIT", false, true) { TestName = "BIT" }; - yield return new TestCaseData("INT", int.MinValue, int.MaxValue) { TestName = "INT" }; - yield return new TestCaseData("SMALLINT", short.MinValue, short.MaxValue) { TestName = "SMALLINT" }; - yield return new TestCaseData("TINYINT", byte.MinValue, byte.MaxValue) { TestName = "TINYINT" }; - - // NUMERIC is synonym - yield return new TestCaseData("DECIMAL", -1.0, 1.0) { TestName = "DECIMAL" }; - yield return new TestCaseData("DECIMAL(38)", -1.0, 1.0) { TestName = "DECIMAL(38)" }; - yield return new TestCaseData("DECIMAL(38,3)", -1.123, 1.123) { TestName = "DECIMAL(38,3)" }; - yield return new TestCaseData("DECIMAL(18,1)", -1.1, 1.1) { TestName = "DECIMAL(18,1)" }; - yield return new TestCaseData("MONEY", -922_337_203_685_477.0, 922_337_203_685_477.0) { TestName = "MONEY" }; - yield return new TestCaseData("FLOAT", -1.0, 1.0) { TestName = "FLOAT" }; - - yield return new TestCaseData("CHAR", "1", "2") { TestName = "CHAR" }; - yield return new TestCaseData("CHAR(3)", "123", "321") { TestName = "CHAR(3)" }; - yield return new TestCaseData("NCHAR", "1", "2") { TestName = "NCHAR" }; - yield return new TestCaseData("NCHAR(3)", "123", "321") { TestName = "NCHAR(3)" }; - yield return new TestCaseData("VARCHAR", "1", "2") { TestName = "VARCHAR" }; - yield return new TestCaseData("VARCHAR(5)", "123", "321") { TestName = "VARCHAR(5)" }; - yield return new TestCaseData("VARCHAR(MAX)", "123", "321") { TestName = "VARCHAR(MAX)" }; - yield return new TestCaseData("NVARCHAR", "1", "1") { TestName = "NVARCHAR" }; - yield return new TestCaseData("NVARCHAR(5)", "123", "321") { TestName = "NVARCHAR(5)" }; - yield return new TestCaseData("NVARCHAR(MAX)", "123", "321") { TestName = "NVARCHAR(MAX)" }; - yield return new TestCaseData("TEXT", "123", "321") { TestName = "TEXT" }; - yield return new TestCaseData("NTEXT", "123", "321") { TestName = "NTEXT" }; - yield return new TestCaseData("XML", "", "") { TestName = "XML" }; - - yield return new TestCaseData("UNIQUEIDENTIFIER", Guid.Empty, Guid.Empty) { TestName = "UNIQUEIDENTIFIER" }; - - yield return new TestCaseData("BINARY", new[] { byte.MinValue }, new[] { byte.MaxValue }) { TestName = "BINARY" }; - yield return new TestCaseData("BINARY(2)", new[] { byte.MinValue, byte.MinValue }, new[] { byte.MaxValue, byte.MaxValue }) { TestName = "BINARY(2)" }; - - yield return new TestCaseData("VARBINARY", new byte[0], new[] { byte.MinValue }) { TestName = "VARBINARY" }; - yield return new TestCaseData("VARBINARY(3)", new byte[0], new byte[] { byte.MinValue, 2, byte.MaxValue }) { TestName = "VARBINARY(3)" }; - yield return new TestCaseData("VARBINARY(MAX)", new byte[0], new byte[] { byte.MinValue, 2, byte.MaxValue }) { TestName = "VARBINARY(MAX)" }; - - yield return new TestCaseData("IMAGE", new byte[0], new byte[] { byte.MinValue, 2, byte.MaxValue }) { TestName = "IMAGE" }; - - var date = new DateTime(2019, 04, 22, 15, 42, 30); - yield return new TestCaseData("DATE", date.Date, date.Date) { TestName = "DATE" }; - yield return new TestCaseData("DATETIME", date, date) { TestName = "DATETIME" }; - yield return new TestCaseData("DATETIME2", date, date) { TestName = "DATETIME2" }; - yield return new TestCaseData("SMALLDATETIME", date.AddSeconds(-30), date.AddSeconds(30)) { TestName = "SMALLDATETIME" }; - yield return new TestCaseData("TIME", date.TimeOfDay, date.TimeOfDay) { TestName = "TIME" }; - - var dateTimeOffset = new DateTimeOffset(2020, 11, 23, 00, 02, 50, 999, TimeSpan.FromHours(2)); - yield return new TestCaseData("DATETIMEOFFSET", dateTimeOffset, dateTimeOffset) { TestName = "DATETIMEOFFSET" }; - - ////yield return new TestCaseData() { TestName = "" }; - } + Console.WriteLine(slq2); + + slq2.Length.ShouldBeGreaterThan(slq500.Length); + } + + private static IEnumerable GetExportCases() + { + yield return new TestCaseData("BIGINT", long.MinValue, long.MaxValue) { TestName = "BIGINT" }; + yield return new TestCaseData("BIT", false, true) { TestName = "BIT" }; + yield return new TestCaseData("INT", int.MinValue, int.MaxValue) { TestName = "INT" }; + yield return new TestCaseData("SMALLINT", short.MinValue, short.MaxValue) { TestName = "SMALLINT" }; + yield return new TestCaseData("TINYINT", byte.MinValue, byte.MaxValue) { TestName = "TINYINT" }; + + // NUMERIC is synonym + yield return new TestCaseData("DECIMAL", -1.0, 1.0) { TestName = "DECIMAL" }; + yield return new TestCaseData("DECIMAL(38)", -1.0, 1.0) { TestName = "DECIMAL(38)" }; + yield return new TestCaseData("DECIMAL(38,3)", -1.123, 1.123) { TestName = "DECIMAL(38,3)" }; + yield return new TestCaseData("DECIMAL(18,1)", -1.1, 1.1) { TestName = "DECIMAL(18,1)" }; + yield return new TestCaseData("MONEY", -922_337_203_685_477.0, 922_337_203_685_477.0) { TestName = "MONEY" }; + yield return new TestCaseData("FLOAT", -1.0, 1.0) { TestName = "FLOAT" }; + + yield return new TestCaseData("CHAR", "1", "2") { TestName = "CHAR" }; + yield return new TestCaseData("CHAR(3)", "123", "321") { TestName = "CHAR(3)" }; + yield return new TestCaseData("NCHAR", "1", "2") { TestName = "NCHAR" }; + yield return new TestCaseData("NCHAR(3)", "123", "321") { TestName = "NCHAR(3)" }; + yield return new TestCaseData("VARCHAR", "1", "2") { TestName = "VARCHAR" }; + yield return new TestCaseData("VARCHAR(5)", "123", "321") { TestName = "VARCHAR(5)" }; + yield return new TestCaseData("VARCHAR(MAX)", "123", "321") { TestName = "VARCHAR(MAX)" }; + yield return new TestCaseData("NVARCHAR", "1", "1") { TestName = "NVARCHAR" }; + yield return new TestCaseData("NVARCHAR(5)", "123", "321") { TestName = "NVARCHAR(5)" }; + yield return new TestCaseData("NVARCHAR(MAX)", "123", "321") { TestName = "NVARCHAR(MAX)" }; + yield return new TestCaseData("TEXT", "123", "321") { TestName = "TEXT" }; + yield return new TestCaseData("NTEXT", "123", "321") { TestName = "NTEXT" }; + yield return new TestCaseData("XML", "", "") { TestName = "XML" }; + + yield return new TestCaseData("UNIQUEIDENTIFIER", Guid.Empty, Guid.Empty) { TestName = "UNIQUEIDENTIFIER" }; + + yield return new TestCaseData("BINARY", new[] { byte.MinValue }, new[] { byte.MaxValue }) { TestName = "BINARY" }; + yield return new TestCaseData("BINARY(2)", new[] { byte.MinValue, byte.MinValue }, new[] { byte.MaxValue, byte.MaxValue }) { TestName = "BINARY(2)" }; + + yield return new TestCaseData("VARBINARY", new byte[0], new[] { byte.MinValue }) { TestName = "VARBINARY" }; + yield return new TestCaseData("VARBINARY(3)", new byte[0], new byte[] { byte.MinValue, 2, byte.MaxValue }) { TestName = "VARBINARY(3)" }; + yield return new TestCaseData("VARBINARY(MAX)", new byte[0], new byte[] { byte.MinValue, 2, byte.MaxValue }) { TestName = "VARBINARY(MAX)" }; + + yield return new TestCaseData("IMAGE", new byte[0], new byte[] { byte.MinValue, 2, byte.MaxValue }) { TestName = "IMAGE" }; + + var date = new DateTime(2019, 04, 22, 15, 42, 30); + yield return new TestCaseData("DATE", date.Date, date.Date) { TestName = "DATE" }; + yield return new TestCaseData("DATETIME", date, date) { TestName = "DATETIME" }; + yield return new TestCaseData("DATETIME2", date, date) { TestName = "DATETIME2" }; + yield return new TestCaseData("SMALLDATETIME", date.AddSeconds(-30), date.AddSeconds(30)) { TestName = "SMALLDATETIME" }; + yield return new TestCaseData("TIME", date.TimeOfDay, date.TimeOfDay) { TestName = "TIME" }; + + var dateTimeOffset = new DateTimeOffset(2020, 11, 23, 00, 02, 50, 999, TimeSpan.FromHours(2)); + yield return new TestCaseData("DATETIMEOFFSET", dateTimeOffset, dateTimeOffset) { TestName = "DATETIMEOFFSET" }; + + ////yield return new TestCaseData() { TestName = "" }; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Export/MySqlDataExporterTest.cs b/Sources/SqlDatabase.Test/Export/MySqlDataExporterTest.cs index f907ccbe..f6e0bbe7 100644 --- a/Sources/SqlDatabase.Test/Export/MySqlDataExporterTest.cs +++ b/Sources/SqlDatabase.Test/Export/MySqlDataExporterTest.cs @@ -8,185 +8,184 @@ using SqlDatabase.Scripts.MySql; using SqlDatabase.TestApi; -namespace SqlDatabase.Export +namespace SqlDatabase.Export; + +[TestFixture] +public class MySqlDataExporterTest { - [TestFixture] - public class MySqlDataExporterTest + private StringBuilder _output; + private DataExporter _sut; + + [SetUp] + public void BeforeEachTest() { - private StringBuilder _output; - private DataExporter _sut; + _output = new StringBuilder(); - [SetUp] - public void BeforeEachTest() - { - _output = new StringBuilder(); + var log = new Mock(MockBehavior.Strict); + log + .Setup(l => l.Info(It.IsAny())) + .Callback(m => Console.WriteLine("Info: {0}", m)); - var log = new Mock(MockBehavior.Strict); - log - .Setup(l => l.Info(It.IsAny())) - .Callback(m => Console.WriteLine("Info: {0}", m)); + _sut = new DataExporter + { + Log = log.Object, + Output = new MySqlWriter(new StringWriter(_output)) + }; + } - _sut = new DataExporter - { - Log = log.Object, - Output = new MySqlWriter(new StringWriter(_output)) - }; + [Test] + [TestCaseSource(nameof(GetExportCases))] + public void Export(string dataType, object minValue, object maxValue, bool allowNull, string expectedDataType) + { + var sql = new StringBuilder(); + var script = new MySqlWriter(new StringWriter(sql)) + .TextFormat("CREATE TEMPORARY TABLE input_data(value {0} {1});", dataType, allowNull ? "NULL" : null) + .Line() + .Line("INSERT INTO input_data VALUES"); + + script.Text("(").Value(minValue, expectedDataType ?? dataType).Line(")"); + if (allowNull) + { + script.Text(",(").Value(maxValue, expectedDataType ?? dataType).Line(")"); + script.Text(",(").Value(null).Line(");"); } - - [Test] - [TestCaseSource(nameof(GetExportCases))] - public void Export(string dataType, object minValue, object maxValue, bool allowNull, string expectedDataType) + else { - var sql = new StringBuilder(); - var script = new MySqlWriter(new StringWriter(sql)) - .TextFormat("CREATE TEMPORARY TABLE input_data(value {0} {1});", dataType, allowNull ? "NULL" : null) - .Line() - .Line("INSERT INTO input_data VALUES"); - - script.Text("(").Value(minValue, expectedDataType ?? dataType).Line(")"); - if (allowNull) - { - script.Text(",(").Value(maxValue, expectedDataType ?? dataType).Line(")"); - script.Text(",(").Value(null).Line(");"); - } - else - { - script.Text(",(").Value(maxValue, expectedDataType ?? dataType).Line(");"); - } + script.Text(",(").Value(maxValue, expectedDataType ?? dataType).Line(");"); + } - script.Text("SELECT * FROM input_data;"); + script.Text("SELECT * FROM input_data;"); - using (var connection = MySqlQuery.Open()) - using (var cmd = connection.CreateCommand()) + using (var connection = MySqlQuery.Open()) + using (var cmd = connection.CreateCommand()) + { + cmd.CommandText = sql.ToString(); + using (var reader = cmd.ExecuteReader()) { - cmd.CommandText = sql.ToString(); - using (var reader = cmd.ExecuteReader()) - { - _sut.Export(reader, "test_data"); - } + _sut.Export(reader, "test_data"); } + } - var exportSql = _output.ToString(); - Console.WriteLine(exportSql); + var exportSql = _output.ToString(); + Console.WriteLine(exportSql); - exportSql.ShouldContain(" " + (expectedDataType ?? dataType) + " "); + exportSql.ShouldContain(" " + (expectedDataType ?? dataType) + " "); - using (var connection = MySqlQuery.Open()) - using (var cmd = connection.CreateCommand()) + using (var connection = MySqlQuery.Open()) + using (var cmd = connection.CreateCommand()) + { + cmd.CommandText = exportSql.Replace("CREATE TABLE", "CREATE TEMPORARY TABLE") + "\r\n\r\nSELECT * FROM test_data;"; + + using (var reader = cmd.ExecuteReader()) { - cmd.CommandText = exportSql.Replace("CREATE TABLE", "CREATE TEMPORARY TABLE") + "\r\n\r\nSELECT * FROM test_data;"; + reader.Read().ShouldBeTrue(); + CompareValues(expectedDataType ?? dataType, minValue, reader[0]); - using (var reader = cmd.ExecuteReader()) - { - reader.Read().ShouldBeTrue(); - CompareValues(expectedDataType ?? dataType, minValue, reader[0]); + reader.Read().ShouldBeTrue(); + CompareValues(expectedDataType ?? dataType, maxValue, reader[0]); + if (allowNull) + { reader.Read().ShouldBeTrue(); - CompareValues(expectedDataType ?? dataType, maxValue, reader[0]); - - if (allowNull) - { - reader.Read().ShouldBeTrue(); - reader[0].ShouldBe(DBNull.Value); - reader.Read().ShouldBeFalse(); - } - else - { - reader.Read().ShouldBeFalse(); - } + reader[0].ShouldBe(DBNull.Value); + reader.Read().ShouldBeFalse(); + } + else + { + reader.Read().ShouldBeFalse(); } } } + } - private static void CompareValues(string dataType, object expected, object actual) + private static void CompareValues(string dataType, object expected, object actual) + { + if (dataType == "TIMESTAMP") { - if (dataType == "TIMESTAMP") - { - actual = ((DateTime)actual) - new DateTime(1970, 01, 01); - } - - if (dataType == "TIME") - { - var date = (DateTime)expected; - expected = new TimeSpan(date.Hour, date.Minute, date.Second); - } - - if (dataType == "GEOMETRY") - { - return; - } + actual = ((DateTime)actual) - new DateTime(1970, 01, 01); + } - actual.ShouldBe(expected); + if (dataType == "TIME") + { + var date = (DateTime)expected; + expected = new TimeSpan(date.Hour, date.Minute, date.Second); } - private static IEnumerable GetExportCases() + if (dataType == "GEOMETRY") { - // Integer Types - yield return new TestCaseData("TINYINT", sbyte.MinValue, sbyte.MaxValue, true, "TINYINT(4)") { TestName = "TINYINT" }; - yield return new TestCaseData("TINYINT UNSIGNED", (sbyte)0, sbyte.MaxValue, true, "TINYINT(3) UNSIGNED") { TestName = "TINYINT UNSIGNED" }; - yield return new TestCaseData("SMALLINT", short.MinValue, short.MaxValue, true, "SMALLINT(6)") { TestName = "SMALLINT" }; - yield return new TestCaseData("SMALLINT UNSIGNED", ushort.MinValue, ushort.MaxValue, true, "SMALLINT(5) UNSIGNED") { TestName = "SMALLINT UNSIGNED" }; - yield return new TestCaseData("MEDIUMINT", -8388608, 8388607, true, "MEDIUMINT(9)") { TestName = "MEDIUMINT" }; - yield return new TestCaseData("MEDIUMINT UNSIGNED", 0, 16777215, true, "MEDIUMINT(8) UNSIGNED") { TestName = "MEDIUMINT UNSIGNED" }; - yield return new TestCaseData("INT", int.MinValue, int.MaxValue, true, "INT(11)") { TestName = "INT" }; - yield return new TestCaseData("INT UNSIGNED", uint.MinValue, uint.MaxValue, true, "INT(10) UNSIGNED") { TestName = "INT UNSIGNED" }; - yield return new TestCaseData("INTEGER", int.MinValue, int.MaxValue, true, "INT(11)") { TestName = "INTEGER" }; - yield return new TestCaseData("INTEGER UNSIGNED", uint.MinValue, uint.MaxValue, true, "INT(10) UNSIGNED") { TestName = "INTEGER UNSIGNED" }; - yield return new TestCaseData("BIGINT", long.MinValue, long.MaxValue, true, "BIGINT(20)") { TestName = "BIGINT" }; - yield return new TestCaseData("BIGINT UNSIGNED", ulong.MinValue, ulong.MaxValue, true, "BIGINT(20) UNSIGNED") { TestName = "BIGINT UNSIGNED" }; - - // Fixed-Point Types - yield return new TestCaseData("NUMERIC", -123M, 123M, true, "NUMERIC(10)") { TestName = "NUMERIC" }; - yield return new TestCaseData("DECIMAL", -123M, 123M, true, "NUMERIC(10)") { TestName = "DECIMAL" }; - yield return new TestCaseData("NUMERIC(6,3)", -123.123M, 123.123M, true, null) { TestName = "NUMERIC(6,3)" }; - - // Floating-Point Types - yield return new TestCaseData("FLOAT", -123f, 123f, true, null) { TestName = "FLOAT" }; - yield return new TestCaseData("FLOAT(7,4)", -123.21f, 123.21f, true, "FLOAT") { TestName = "FLOAT(7,4)" }; - yield return new TestCaseData("DOUBLE", -123f, 123f, true, null) { TestName = "DOUBLE" }; - yield return new TestCaseData("REAL", -123f, 123f, true, "DOUBLE") { TestName = "REAL" }; - yield return new TestCaseData("DOUBLE(7,4)", -123f, 123f, true, "DOUBLE") { TestName = "DOUBLE(7,4)" }; - - // Bit-Value - yield return new TestCaseData("BIT", 0, 1, true, "BIT(1)") { TestName = "BIT" }; - yield return new TestCaseData("BIT(10)", 7, 128, true, null) { TestName = "BIT(10)" }; - - // bool - yield return new TestCaseData("BOOL", true, false, true, null) { TestName = "BOOL" }; - yield return new TestCaseData("BOOLEAN", true, false, true, "BOOL") { TestName = "BOOLEAN" }; - - // Date and Time Data Type - yield return new TestCaseData("DATE", new DateTime(2021, 06, 20), new DateTime(2021, 06, 20), true, null) { TestName = "DATE" }; - yield return new TestCaseData("TIME", new DateTime(2021, 06, 20, 15, 10, 10), new DateTime(2021, 06, 20, 15, 10, 10), true, null) { TestName = "TIME" }; - yield return new TestCaseData("DATETIME", new DateTime(2021, 06, 20, 15, 10, 10), new DateTime(2021, 06, 20, 15, 10, 10), true, null) { TestName = "DATETIME" }; - yield return new TestCaseData("TIMESTAMP", TimeSpan.FromSeconds(1), TimeSpan.FromDays(2), true, null) { TestName = "TIMESTAMP" }; - yield return new TestCaseData("YEAR", 1901, 2155, true, null) { TestName = "YEAR" }; - - // String Data Type - yield return new TestCaseData("CHAR", "a", "b", true, "NCHAR(1)") { TestName = "CHAR" }; - yield return new TestCaseData("CHAR(10)", "ab", "bc", true, "NCHAR(10)") { TestName = "CHAR(10)" }; - yield return new TestCaseData("NCHAR(10)", "ab", "bc", true, null) { TestName = "NCHAR(10)" }; - yield return new TestCaseData("VARCHAR(10)", "ab", "bc", true, "NVARCHAR(10)") { TestName = "VARCHAR(10)" }; - yield return new TestCaseData("NVARCHAR(10)", "ab", "bc", true, null) { TestName = "NVARCHAR(10)" }; - yield return new TestCaseData("BINARY", new byte[] { 2 }, new byte[] { 1 }, true, "BINARY(1)") { TestName = "BINARY" }; - yield return new TestCaseData("VARBINARY(10)", new byte[] { 1, 2, 3 }, new byte[] { 1 }, true, null) { TestName = "VARBINARY(10)" }; - yield return new TestCaseData("TINYBLOB", new byte[] { 2 }, new byte[] { 1 }, true, "BLOB") { TestName = "TINYBLOB" }; - yield return new TestCaseData("TINYTEXT", "ab", "bc", true, "TEXT") { TestName = "TINYTEXT" }; - yield return new TestCaseData("BLOB", new byte[] { 2 }, new byte[] { 1 }, true, null) { TestName = "BLOB" }; - yield return new TestCaseData("TEXT", "ab", "bc", true, null) { TestName = "TEXT" }; - yield return new TestCaseData("MEDIUMBLOB", new byte[] { 2 }, new byte[] { 1 }, true, "BLOB") { TestName = "MEDIUMBLOB" }; - yield return new TestCaseData("MEDIUMTEXT", "ab", "bc", true, "TEXT") { TestName = "MEDIUMTEXT" }; - yield return new TestCaseData("LONGBLOB", new byte[] { 2 }, new byte[] { 1 }, true, "BLOB") { TestName = "LONGBLOB" }; - yield return new TestCaseData("LONGTEXT", "ab", "bc", true, "TEXT") { TestName = "LONGTEXT" }; - - // enum - yield return new TestCaseData("ENUM('small', 'medium', 'large')", "small", "large", true, "NVARCHAR(6)") { TestName = "ENUM" }; - yield return new TestCaseData("SET('a', 'b', 'c')", "a,b", "b,c", true, "NVARCHAR(5)") { TestName = "SET" }; - - yield return new TestCaseData("JSON", "{}", "{\"a\": 1}", true, null) { TestName = "JSON" }; - - yield return new TestCaseData("GEOMETRY", "ST_GeomFromText('POINT(1 1)')", "ST_GeomFromText('LINESTRING(0 0,1 1,2 2)')", true, null) { TestName = "GEOMETRY" }; - yield return new TestCaseData("POINT", "ST_GeomFromText('POINT(1 1)')", "ST_GeomFromText('POINT(1 1)')", true, "GEOMETRY") { TestName = "POINT" }; + return; } + + actual.ShouldBe(expected); + } + + private static IEnumerable GetExportCases() + { + // Integer Types + yield return new TestCaseData("TINYINT", sbyte.MinValue, sbyte.MaxValue, true, "TINYINT(4)") { TestName = "TINYINT" }; + yield return new TestCaseData("TINYINT UNSIGNED", (sbyte)0, sbyte.MaxValue, true, "TINYINT(3) UNSIGNED") { TestName = "TINYINT UNSIGNED" }; + yield return new TestCaseData("SMALLINT", short.MinValue, short.MaxValue, true, "SMALLINT(6)") { TestName = "SMALLINT" }; + yield return new TestCaseData("SMALLINT UNSIGNED", ushort.MinValue, ushort.MaxValue, true, "SMALLINT(5) UNSIGNED") { TestName = "SMALLINT UNSIGNED" }; + yield return new TestCaseData("MEDIUMINT", -8388608, 8388607, true, "MEDIUMINT(9)") { TestName = "MEDIUMINT" }; + yield return new TestCaseData("MEDIUMINT UNSIGNED", 0, 16777215, true, "MEDIUMINT(8) UNSIGNED") { TestName = "MEDIUMINT UNSIGNED" }; + yield return new TestCaseData("INT", int.MinValue, int.MaxValue, true, "INT(11)") { TestName = "INT" }; + yield return new TestCaseData("INT UNSIGNED", uint.MinValue, uint.MaxValue, true, "INT(10) UNSIGNED") { TestName = "INT UNSIGNED" }; + yield return new TestCaseData("INTEGER", int.MinValue, int.MaxValue, true, "INT(11)") { TestName = "INTEGER" }; + yield return new TestCaseData("INTEGER UNSIGNED", uint.MinValue, uint.MaxValue, true, "INT(10) UNSIGNED") { TestName = "INTEGER UNSIGNED" }; + yield return new TestCaseData("BIGINT", long.MinValue, long.MaxValue, true, "BIGINT(20)") { TestName = "BIGINT" }; + yield return new TestCaseData("BIGINT UNSIGNED", ulong.MinValue, ulong.MaxValue, true, "BIGINT(20) UNSIGNED") { TestName = "BIGINT UNSIGNED" }; + + // Fixed-Point Types + yield return new TestCaseData("NUMERIC", -123M, 123M, true, "NUMERIC(10)") { TestName = "NUMERIC" }; + yield return new TestCaseData("DECIMAL", -123M, 123M, true, "NUMERIC(10)") { TestName = "DECIMAL" }; + yield return new TestCaseData("NUMERIC(6,3)", -123.123M, 123.123M, true, null) { TestName = "NUMERIC(6,3)" }; + + // Floating-Point Types + yield return new TestCaseData("FLOAT", -123f, 123f, true, null) { TestName = "FLOAT" }; + yield return new TestCaseData("FLOAT(7,4)", -123.21f, 123.21f, true, "FLOAT") { TestName = "FLOAT(7,4)" }; + yield return new TestCaseData("DOUBLE", -123f, 123f, true, null) { TestName = "DOUBLE" }; + yield return new TestCaseData("REAL", -123f, 123f, true, "DOUBLE") { TestName = "REAL" }; + yield return new TestCaseData("DOUBLE(7,4)", -123f, 123f, true, "DOUBLE") { TestName = "DOUBLE(7,4)" }; + + // Bit-Value + yield return new TestCaseData("BIT", 0, 1, true, "BIT(1)") { TestName = "BIT" }; + yield return new TestCaseData("BIT(10)", 7, 128, true, null) { TestName = "BIT(10)" }; + + // bool + yield return new TestCaseData("BOOL", true, false, true, null) { TestName = "BOOL" }; + yield return new TestCaseData("BOOLEAN", true, false, true, "BOOL") { TestName = "BOOLEAN" }; + + // Date and Time Data Type + yield return new TestCaseData("DATE", new DateTime(2021, 06, 20), new DateTime(2021, 06, 20), true, null) { TestName = "DATE" }; + yield return new TestCaseData("TIME", new DateTime(2021, 06, 20, 15, 10, 10), new DateTime(2021, 06, 20, 15, 10, 10), true, null) { TestName = "TIME" }; + yield return new TestCaseData("DATETIME", new DateTime(2021, 06, 20, 15, 10, 10), new DateTime(2021, 06, 20, 15, 10, 10), true, null) { TestName = "DATETIME" }; + yield return new TestCaseData("TIMESTAMP", TimeSpan.FromSeconds(1), TimeSpan.FromDays(2), true, null) { TestName = "TIMESTAMP" }; + yield return new TestCaseData("YEAR", 1901, 2155, true, null) { TestName = "YEAR" }; + + // String Data Type + yield return new TestCaseData("CHAR", "a", "b", true, "NCHAR(1)") { TestName = "CHAR" }; + yield return new TestCaseData("CHAR(10)", "ab", "bc", true, "NCHAR(10)") { TestName = "CHAR(10)" }; + yield return new TestCaseData("NCHAR(10)", "ab", "bc", true, null) { TestName = "NCHAR(10)" }; + yield return new TestCaseData("VARCHAR(10)", "ab", "bc", true, "NVARCHAR(10)") { TestName = "VARCHAR(10)" }; + yield return new TestCaseData("NVARCHAR(10)", "ab", "bc", true, null) { TestName = "NVARCHAR(10)" }; + yield return new TestCaseData("BINARY", new byte[] { 2 }, new byte[] { 1 }, true, "BINARY(1)") { TestName = "BINARY" }; + yield return new TestCaseData("VARBINARY(10)", new byte[] { 1, 2, 3 }, new byte[] { 1 }, true, null) { TestName = "VARBINARY(10)" }; + yield return new TestCaseData("TINYBLOB", new byte[] { 2 }, new byte[] { 1 }, true, "BLOB") { TestName = "TINYBLOB" }; + yield return new TestCaseData("TINYTEXT", "ab", "bc", true, "TEXT") { TestName = "TINYTEXT" }; + yield return new TestCaseData("BLOB", new byte[] { 2 }, new byte[] { 1 }, true, null) { TestName = "BLOB" }; + yield return new TestCaseData("TEXT", "ab", "bc", true, null) { TestName = "TEXT" }; + yield return new TestCaseData("MEDIUMBLOB", new byte[] { 2 }, new byte[] { 1 }, true, "BLOB") { TestName = "MEDIUMBLOB" }; + yield return new TestCaseData("MEDIUMTEXT", "ab", "bc", true, "TEXT") { TestName = "MEDIUMTEXT" }; + yield return new TestCaseData("LONGBLOB", new byte[] { 2 }, new byte[] { 1 }, true, "BLOB") { TestName = "LONGBLOB" }; + yield return new TestCaseData("LONGTEXT", "ab", "bc", true, "TEXT") { TestName = "LONGTEXT" }; + + // enum + yield return new TestCaseData("ENUM('small', 'medium', 'large')", "small", "large", true, "NVARCHAR(6)") { TestName = "ENUM" }; + yield return new TestCaseData("SET('a', 'b', 'c')", "a,b", "b,c", true, "NVARCHAR(5)") { TestName = "SET" }; + + yield return new TestCaseData("JSON", "{}", "{\"a\": 1}", true, null) { TestName = "JSON" }; + + yield return new TestCaseData("GEOMETRY", "ST_GeomFromText('POINT(1 1)')", "ST_GeomFromText('LINESTRING(0 0,1 1,2 2)')", true, null) { TestName = "GEOMETRY" }; + yield return new TestCaseData("POINT", "ST_GeomFromText('POINT(1 1)')", "ST_GeomFromText('POINT(1 1)')", true, "GEOMETRY") { TestName = "POINT" }; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Export/PgSqlDataExporterTest.cs b/Sources/SqlDatabase.Test/Export/PgSqlDataExporterTest.cs index ce5b89ec..752b47dc 100644 --- a/Sources/SqlDatabase.Test/Export/PgSqlDataExporterTest.cs +++ b/Sources/SqlDatabase.Test/Export/PgSqlDataExporterTest.cs @@ -12,224 +12,223 @@ using SqlDatabase.Scripts.PgSql; using SqlDatabase.TestApi; -namespace SqlDatabase.Export +namespace SqlDatabase.Export; + +[TestFixture] +public class PgSqlDataExporterTest { - [TestFixture] - public class PgSqlDataExporterTest + private StringBuilder _output; + private DataExporter _sut; + + [SetUp] + public void BeforeEachTest() { - private StringBuilder _output; - private DataExporter _sut; + _output = new StringBuilder(); - [SetUp] - public void BeforeEachTest() - { - _output = new StringBuilder(); + var log = new Mock(MockBehavior.Strict); + log + .Setup(l => l.Info(It.IsAny())) + .Callback(m => Console.WriteLine("Info: {0}", m)); - var log = new Mock(MockBehavior.Strict); - log - .Setup(l => l.Info(It.IsAny())) - .Callback(m => Console.WriteLine("Info: {0}", m)); + _sut = new DataExporter + { + Log = log.Object, + Output = new PgSqlWriter(new StringWriter(_output)) + }; + } - _sut = new DataExporter - { - Log = log.Object, - Output = new PgSqlWriter(new StringWriter(_output)) - }; + [Test] + [TestCaseSource(nameof(GetExportCases))] + public void Export(string dataType, object minValue, object maxValue, bool allowNull, string expectedDataType) + { + var sql = new StringBuilder(); + var script = new PgSqlWriter(new StringWriter(sql)) + .TextFormat("CREATE TEMP TABLE input_data(value {0} {1});", dataType, allowNull ? "NULL" : null) + .Line() + .Line("INSERT INTO input_data VALUES"); + + script.Text("(").Value(minValue).Line(")"); + if (allowNull) + { + script.Text(",(").Value(maxValue).Line(")"); + script.Text(",(").Value(null).Line(");"); } - - [Test] - [TestCaseSource(nameof(GetExportCases))] - public void Export(string dataType, object minValue, object maxValue, bool allowNull, string expectedDataType) + else { - var sql = new StringBuilder(); - var script = new PgSqlWriter(new StringWriter(sql)) - .TextFormat("CREATE TEMP TABLE input_data(value {0} {1});", dataType, allowNull ? "NULL" : null) - .Line() - .Line("INSERT INTO input_data VALUES"); - - script.Text("(").Value(minValue).Line(")"); - if (allowNull) - { - script.Text(",(").Value(maxValue).Line(")"); - script.Text(",(").Value(null).Line(");"); - } - else - { - script.Text(",(").Value(maxValue).Line(");"); - } + script.Text(",(").Value(maxValue).Line(");"); + } - script.Text("SELECT * FROM input_data;"); + script.Text("SELECT * FROM input_data;"); - using (var connection = new NpgsqlConnection(PgSqlQuery.ConnectionString)) - using (var cmd = connection.CreateCommand()) - { - cmd.CommandText = sql.ToString(); - connection.Open(); + using (var connection = new NpgsqlConnection(PgSqlQuery.ConnectionString)) + using (var cmd = connection.CreateCommand()) + { + cmd.CommandText = sql.ToString(); + connection.Open(); - using (var reader = cmd.ExecuteReader()) - { - _sut.Export(reader, "test_data"); - } + using (var reader = cmd.ExecuteReader()) + { + _sut.Export(reader, "test_data"); } + } + + var exportSql = _output.ToString(); + Console.WriteLine(exportSql); - var exportSql = _output.ToString(); - Console.WriteLine(exportSql); + exportSql.ShouldContain(" " + (expectedDataType ?? dataType) + " "); - exportSql.ShouldContain(" " + (expectedDataType ?? dataType) + " "); + using (var connection = new NpgsqlConnection(PgSqlQuery.ConnectionString)) + using (var cmd = connection.CreateCommand()) + { + cmd.CommandText = exportSql.Replace("CREATE TABLE", "CREATE TEMP TABLE") + "\r\n\r\nSELECT * FROM test_data;"; + connection.Open(); - using (var connection = new NpgsqlConnection(PgSqlQuery.ConnectionString)) - using (var cmd = connection.CreateCommand()) + using (var reader = cmd.ExecuteReader()) { - cmd.CommandText = exportSql.Replace("CREATE TABLE", "CREATE TEMP TABLE") + "\r\n\r\nSELECT * FROM test_data;"; - connection.Open(); + reader.Read().ShouldBeTrue(); + CompareValues(dataType, minValue, reader[0]); - using (var reader = cmd.ExecuteReader()) - { - reader.Read().ShouldBeTrue(); - CompareValues(dataType, minValue, reader[0]); + reader.Read().ShouldBeTrue(); + CompareValues(dataType, maxValue, reader[0]); + if (allowNull) + { reader.Read().ShouldBeTrue(); - CompareValues(dataType, maxValue, reader[0]); - - if (allowNull) - { - reader.Read().ShouldBeTrue(); - reader[0].ShouldBe(DBNull.Value); - reader.Read().ShouldBeFalse(); - } - else - { - reader.Read().ShouldBeFalse(); - } + reader[0].ShouldBe(DBNull.Value); + reader.Read().ShouldBeFalse(); + } + else + { + reader.Read().ShouldBeFalse(); } } } + } - private static void CompareValues(string dataType, object expected, object actual) + private static void CompareValues(string dataType, object expected, object actual) + { + if (dataType.StartsWith("bit", StringComparison.OrdinalIgnoreCase) && actual is bool) { - if (dataType.StartsWith("bit", StringComparison.OrdinalIgnoreCase) && actual is bool) - { - actual.ShouldBe(((BitArray)expected)[0]); - return; - } + actual.ShouldBe(((BitArray)expected)[0]); + return; + } - if (dataType.Equals("tsvector", StringComparison.OrdinalIgnoreCase)) - { - actual.ShouldBeOfType().ShouldBe(NpgsqlTsVector.Parse((string)expected)); - return; - } + if (dataType.Equals("tsvector", StringComparison.OrdinalIgnoreCase)) + { + actual.ShouldBeOfType().ShouldBe(NpgsqlTsVector.Parse((string)expected)); + return; + } - if (dataType.Equals("tsquery", StringComparison.OrdinalIgnoreCase)) - { - actual.ShouldBeAssignableTo().ToString().ShouldBe(NpgsqlTsQuery.Parse((string)expected).ToString()); - return; - } + if (dataType.Equals("tsquery", StringComparison.OrdinalIgnoreCase)) + { + actual.ShouldBeAssignableTo().ToString().ShouldBe(NpgsqlTsQuery.Parse((string)expected).ToString()); + return; + } - if (expected is IDictionary compositeExpected) + if (expected is IDictionary compositeExpected) + { + var compositeActual = actual.ShouldBeAssignableTo>(); + compositeActual.Keys.ShouldBe(compositeExpected.Keys); + foreach (var key in compositeExpected.Keys) { - var compositeActual = actual.ShouldBeAssignableTo>(); - compositeActual.Keys.ShouldBe(compositeExpected.Keys); - foreach (var key in compositeExpected.Keys) - { - compositeActual[key].ShouldBe(compositeExpected[key]); - } - - return; + compositeActual[key].ShouldBe(compositeExpected[key]); } - actual.ShouldBe(expected); + return; } - private static IEnumerable GetExportCases() - { - // Numeric Types - yield return new TestCaseData("smallint", short.MinValue, short.MaxValue, true, null) { TestName = "smallint" }; - yield return new TestCaseData("integer", int.MinValue, int.MaxValue, true, null) { TestName = "integer" }; - yield return new TestCaseData("bigint", long.MinValue, long.MaxValue, true, null) { TestName = "bigint" }; - yield return new TestCaseData("decimal", decimal.MinValue, decimal.MaxValue, true, "numeric") { TestName = "decimal" }; - yield return new TestCaseData("numeric", decimal.MinValue, decimal.MaxValue, true, null) { TestName = "numeric" }; - yield return new TestCaseData("real", -10.1F, 20.1F, true, null) { TestName = "real" }; - yield return new TestCaseData("double precision", double.MinValue, double.MaxValue, true, null) { TestName = "double precision" }; - - yield return new TestCaseData("smallserial", (short)0, short.MaxValue, false, "smallint") { TestName = "smallserial" }; - yield return new TestCaseData("serial", 0, int.MaxValue, false, "integer") { TestName = "serial" }; - yield return new TestCaseData("bigserial", 0L, long.MaxValue, false, "bigint") { TestName = "bigserial" }; - - yield return new TestCaseData("numeric(2)", -1m, 1m, true, null) { TestName = "numeric(2)" }; - yield return new TestCaseData("numeric(2,1)", -1.1m, 1.1m, true, null) { TestName = "numeric(2,1)" }; - - // Monetary Types - yield return new TestCaseData("money", -100.12m, 100.12m, true, null) { TestName = "money" }; - - // Character Types - yield return new TestCaseData("character varying", "abc", "d", true, null) { TestName = "character varying" }; - yield return new TestCaseData("varchar", "abc", "d", true, "character varying") { TestName = "varchar" }; - yield return new TestCaseData("character varying(3)", "abc", "d", true, null) { TestName = "character varying(3)" }; - yield return new TestCaseData("varchar(3)", "abc", "d", true, "character varying(3)") { TestName = "varchar(3)" }; - - yield return new TestCaseData("character", "a", "d", true, "character(1)") { TestName = "character" }; - yield return new TestCaseData("char", "a", "d", true, "character(1)") { TestName = "char" }; - yield return new TestCaseData("character(2)", "ab", "db", true, null) { TestName = "character(2)" }; - yield return new TestCaseData("char(2)", "ab", "db", true, "character(2)") { TestName = "char(2)" }; - - yield return new TestCaseData("text", "abc", "d", true, null) { TestName = "text" }; - - yield return new TestCaseData("name", "abc", "d", true, null) { TestName = "name" }; - - yield return new TestCaseData("citext", "abc", "d", true, "public.citext") { TestName = "citext" }; - yield return new TestCaseData("public.citext", "abc", "d", true, null) { TestName = "public.citext" }; - - // Binary Data Types - yield return new TestCaseData("bytea", new byte[0], new[] { byte.MinValue, byte.MaxValue, (byte)10 }, true, null) { TestName = "bytea" }; - - // Date/Time Types - var date = new DateTime(2021, 05, 13, 18, 31, 30, 10); - yield return new TestCaseData("timestamp", date, date, true, null) { TestName = "timestamp" }; - yield return new TestCaseData("timestamp(6)", date, date, true, null) { TestName = "timestamp(6)" }; - yield return new TestCaseData("date", date.Date, date.Date, true, null) { TestName = "date" }; - yield return new TestCaseData("time", date.TimeOfDay, date.TimeOfDay, true, null) { TestName = "time" }; - yield return new TestCaseData("time(6)", date.TimeOfDay, date.TimeOfDay, true, null) { TestName = "time(6)" }; - yield return new TestCaseData("interval", TimeSpan.Parse("3.04:05:06"), TimeSpan.Parse("04:05:06"), true, null) { TestName = "interval" }; - yield return new TestCaseData("interval(6)", TimeSpan.Parse("3.04:05:06"), TimeSpan.Parse("04:05:06"), true, null) { TestName = "interval(6)" }; - - // Boolean Type - yield return new TestCaseData("boolean", true, false, true, null) { TestName = "boolean" }; - - // UUID Type - yield return new TestCaseData("uuid", Guid.Empty, Guid.NewGuid(), true, null) { TestName = "uuid" }; - - // Bit String Types - yield return new TestCaseData("bit", new BitArray(new[] { true }), new BitArray(new[] { false }), true, "bit(1)") { TestName = "bit" }; - yield return new TestCaseData("bit(2)", new BitArray(new[] { false, true }), new BitArray(new[] { true, false }), true, null) { TestName = "bit(2)" }; - - // XML Type - yield return new TestCaseData("xml", "bar", "bar", true, null) { TestName = "xml" }; - - // JSON Types - yield return new TestCaseData("json", "{\"foo\": \"bar\"}", "{\"foo\": \"bar\"}", true, null) { TestName = "json" }; - yield return new TestCaseData("jsonb", "{\"foo\": \"bar\"}", "{\"foo\": \"bar\"}", true, null) { TestName = "jsonb" }; - - // Text Search Types - yield return new TestCaseData("tsvector", "a fat cat", "a fat cat", true, null) { TestName = "tsvector" }; - yield return new TestCaseData("tsquery", "fat & rat", "fat & rat", true, null) { TestName = "tsquery" }; - - // Enumerated Types - yield return new TestCaseData("public.mood", "ok", "happy", true, null) { TestName = "enum1" }; - yield return new TestCaseData("mood", "ok", "happy", true, "public.mood") { TestName = "enum2" }; - - // Arrays - yield return new TestCaseData("integer[]", new[] { 1, 2, 3 }, new[] { -1, -2, 3 }, true, null) { TestName = "integer[]" }; - yield return new TestCaseData("integer[3]", new[] { 1, 2, 3 }, new[] { -1, -2, 3 }, true, "integer[]") { TestName = "integer[3]" }; - - // Composite Types - IDictionary composite = new ExpandoObject(); - composite.Add("name", "fuzzy dice"); - composite.Add("supplier_id", 42); - composite.Add("price", 1.99); - yield return new TestCaseData("public.inventory_item", composite, composite, true, null) { TestName = "composite" }; - - // Range Types - yield return new TestCaseData("int4range", NpgsqlRange.Parse("[21,30)"), NpgsqlRange.Parse("[21,31)"), true, null) { TestName = "int4range" }; - } + actual.ShouldBe(expected); + } + + private static IEnumerable GetExportCases() + { + // Numeric Types + yield return new TestCaseData("smallint", short.MinValue, short.MaxValue, true, null) { TestName = "smallint" }; + yield return new TestCaseData("integer", int.MinValue, int.MaxValue, true, null) { TestName = "integer" }; + yield return new TestCaseData("bigint", long.MinValue, long.MaxValue, true, null) { TestName = "bigint" }; + yield return new TestCaseData("decimal", decimal.MinValue, decimal.MaxValue, true, "numeric") { TestName = "decimal" }; + yield return new TestCaseData("numeric", decimal.MinValue, decimal.MaxValue, true, null) { TestName = "numeric" }; + yield return new TestCaseData("real", -10.1F, 20.1F, true, null) { TestName = "real" }; + yield return new TestCaseData("double precision", double.MinValue, double.MaxValue, true, null) { TestName = "double precision" }; + + yield return new TestCaseData("smallserial", (short)0, short.MaxValue, false, "smallint") { TestName = "smallserial" }; + yield return new TestCaseData("serial", 0, int.MaxValue, false, "integer") { TestName = "serial" }; + yield return new TestCaseData("bigserial", 0L, long.MaxValue, false, "bigint") { TestName = "bigserial" }; + + yield return new TestCaseData("numeric(2)", -1m, 1m, true, null) { TestName = "numeric(2)" }; + yield return new TestCaseData("numeric(2,1)", -1.1m, 1.1m, true, null) { TestName = "numeric(2,1)" }; + + // Monetary Types + yield return new TestCaseData("money", -100.12m, 100.12m, true, null) { TestName = "money" }; + + // Character Types + yield return new TestCaseData("character varying", "abc", "d", true, null) { TestName = "character varying" }; + yield return new TestCaseData("varchar", "abc", "d", true, "character varying") { TestName = "varchar" }; + yield return new TestCaseData("character varying(3)", "abc", "d", true, null) { TestName = "character varying(3)" }; + yield return new TestCaseData("varchar(3)", "abc", "d", true, "character varying(3)") { TestName = "varchar(3)" }; + + yield return new TestCaseData("character", "a", "d", true, "character(1)") { TestName = "character" }; + yield return new TestCaseData("char", "a", "d", true, "character(1)") { TestName = "char" }; + yield return new TestCaseData("character(2)", "ab", "db", true, null) { TestName = "character(2)" }; + yield return new TestCaseData("char(2)", "ab", "db", true, "character(2)") { TestName = "char(2)" }; + + yield return new TestCaseData("text", "abc", "d", true, null) { TestName = "text" }; + + yield return new TestCaseData("name", "abc", "d", true, null) { TestName = "name" }; + + yield return new TestCaseData("citext", "abc", "d", true, "public.citext") { TestName = "citext" }; + yield return new TestCaseData("public.citext", "abc", "d", true, null) { TestName = "public.citext" }; + + // Binary Data Types + yield return new TestCaseData("bytea", new byte[0], new[] { byte.MinValue, byte.MaxValue, (byte)10 }, true, null) { TestName = "bytea" }; + + // Date/Time Types + var date = new DateTime(2021, 05, 13, 18, 31, 30, 10); + yield return new TestCaseData("timestamp", date, date, true, null) { TestName = "timestamp" }; + yield return new TestCaseData("timestamp(6)", date, date, true, null) { TestName = "timestamp(6)" }; + yield return new TestCaseData("date", date.Date, date.Date, true, null) { TestName = "date" }; + yield return new TestCaseData("time", date.TimeOfDay, date.TimeOfDay, true, null) { TestName = "time" }; + yield return new TestCaseData("time(6)", date.TimeOfDay, date.TimeOfDay, true, null) { TestName = "time(6)" }; + yield return new TestCaseData("interval", TimeSpan.Parse("3.04:05:06"), TimeSpan.Parse("04:05:06"), true, null) { TestName = "interval" }; + yield return new TestCaseData("interval(6)", TimeSpan.Parse("3.04:05:06"), TimeSpan.Parse("04:05:06"), true, null) { TestName = "interval(6)" }; + + // Boolean Type + yield return new TestCaseData("boolean", true, false, true, null) { TestName = "boolean" }; + + // UUID Type + yield return new TestCaseData("uuid", Guid.Empty, Guid.NewGuid(), true, null) { TestName = "uuid" }; + + // Bit String Types + yield return new TestCaseData("bit", new BitArray(new[] { true }), new BitArray(new[] { false }), true, "bit(1)") { TestName = "bit" }; + yield return new TestCaseData("bit(2)", new BitArray(new[] { false, true }), new BitArray(new[] { true, false }), true, null) { TestName = "bit(2)" }; + + // XML Type + yield return new TestCaseData("xml", "bar", "bar", true, null) { TestName = "xml" }; + + // JSON Types + yield return new TestCaseData("json", "{\"foo\": \"bar\"}", "{\"foo\": \"bar\"}", true, null) { TestName = "json" }; + yield return new TestCaseData("jsonb", "{\"foo\": \"bar\"}", "{\"foo\": \"bar\"}", true, null) { TestName = "jsonb" }; + + // Text Search Types + yield return new TestCaseData("tsvector", "a fat cat", "a fat cat", true, null) { TestName = "tsvector" }; + yield return new TestCaseData("tsquery", "fat & rat", "fat & rat", true, null) { TestName = "tsquery" }; + + // Enumerated Types + yield return new TestCaseData("public.mood", "ok", "happy", true, null) { TestName = "enum1" }; + yield return new TestCaseData("mood", "ok", "happy", true, "public.mood") { TestName = "enum2" }; + + // Arrays + yield return new TestCaseData("integer[]", new[] { 1, 2, 3 }, new[] { -1, -2, 3 }, true, null) { TestName = "integer[]" }; + yield return new TestCaseData("integer[3]", new[] { 1, 2, 3 }, new[] { -1, -2, 3 }, true, "integer[]") { TestName = "integer[3]" }; + + // Composite Types + IDictionary composite = new ExpandoObject(); + composite.Add("name", "fuzzy dice"); + composite.Add("supplier_id", 42); + composite.Add("price", 1.99); + yield return new TestCaseData("public.inventory_item", composite, composite, true, null) { TestName = "composite" }; + + // Range Types + yield return new TestCaseData("int4range", NpgsqlRange.Parse("[21,30)"), NpgsqlRange.Parse("[21,31)"), true, null) { TestName = "int4range" }; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/IO/FileSystemFactoryTest.cs b/Sources/SqlDatabase.Test/IO/FileSystemFactoryTest.cs index 039cea62..46f175ed 100644 --- a/Sources/SqlDatabase.Test/IO/FileSystemFactoryTest.cs +++ b/Sources/SqlDatabase.Test/IO/FileSystemFactoryTest.cs @@ -3,121 +3,120 @@ using NUnit.Framework; using SqlDatabase.TestApi; -namespace SqlDatabase.IO +namespace SqlDatabase.IO; + +[TestFixture] +public class FileSystemFactoryTest { - [TestFixture] - public class FileSystemFactoryTest + [Test] + public void NewFileSystemFolder() { - [Test] - public void NewFileSystemFolder() + using (var dir = new TempDirectory("Content.zip")) { - using (var dir = new TempDirectory("Content.zip")) - { - var folder = FileSystemFactory.FileSystemInfoFromPath(dir.Location); - Assert.IsInstanceOf(folder); - } + var folder = FileSystemFactory.FileSystemInfoFromPath(dir.Location); + Assert.IsInstanceOf(folder); } + } - [Test] - [TestCase("Content.zip", null)] - [TestCase(@"Content.zip\2", "22.txt")] - [TestCase(@"Content.zip\2\2.2", "2.2.txt")] - [TestCase(@"Content.zip\inner.zip", "11.txt")] - [TestCase(@"Content.zip\inner.zip\2", "22.txt")] - public void NewZipFolder(string path, string fileName) + [Test] + [TestCase("Content.zip", null)] + [TestCase(@"Content.zip\2", "22.txt")] + [TestCase(@"Content.zip\2\2.2", "2.2.txt")] + [TestCase(@"Content.zip\inner.zip", "11.txt")] + [TestCase(@"Content.zip\inner.zip\2", "22.txt")] + public void NewZipFolder(string path, string fileName) + { + using (var dir = new TempDirectory()) { - using (var dir = new TempDirectory()) - { - dir.CopyFileFromResources("Content.zip"); + dir.CopyFileFromResources("Content.zip"); - var folder = FileSystemFactory.FileSystemInfoFromPath(Path.Combine(dir.Location, path)); - Assert.IsNotNull(folder); + var folder = FileSystemFactory.FileSystemInfoFromPath(Path.Combine(dir.Location, path)); + Assert.IsNotNull(folder); - var files = ((IFolder)folder).GetFiles().ToList(); - if (fileName != null) - { - Assert.AreEqual(1, files.Count); - Assert.AreEqual(fileName, files[0].Name); - } + var files = ((IFolder)folder).GetFiles().ToList(); + if (fileName != null) + { + Assert.AreEqual(1, files.Count); + Assert.AreEqual(fileName, files[0].Name); } } + } - [Test] - [TestCase("Content.nupkg", null)] - [TestCase(@"Content.nupkg\2", "22.txt")] - [TestCase(@"Content.nupkg\inner.zip", "11.txt")] - public void NewNuGetFolder(string path, string fileName) + [Test] + [TestCase("Content.nupkg", null)] + [TestCase(@"Content.nupkg\2", "22.txt")] + [TestCase(@"Content.nupkg\inner.zip", "11.txt")] + public void NewNuGetFolder(string path, string fileName) + { + using (var dir = new TempDirectory()) { - using (var dir = new TempDirectory()) + dir.CopyFileFromResources("Content.zip"); + File.Move(Path.Combine(dir.Location, "Content.zip"), Path.Combine(dir.Location, "Content.nupkg")); + + var folder = FileSystemFactory.FileSystemInfoFromPath(Path.Combine(dir.Location, path)); + Assert.IsNotNull(folder); + + var files = ((IFolder)folder).GetFiles().ToList(); + if (fileName != null) { - dir.CopyFileFromResources("Content.zip"); - File.Move(Path.Combine(dir.Location, "Content.zip"), Path.Combine(dir.Location, "Content.nupkg")); - - var folder = FileSystemFactory.FileSystemInfoFromPath(Path.Combine(dir.Location, path)); - Assert.IsNotNull(folder); - - var files = ((IFolder)folder).GetFiles().ToList(); - if (fileName != null) - { - Assert.AreEqual(1, files.Count); - Assert.AreEqual(fileName, files[0].Name); - } + Assert.AreEqual(1, files.Count); + Assert.AreEqual(fileName, files[0].Name); } } + } - [Test] - [TestCase(@"{0E4E24C7-E12A-483A-BC8F-E90BC49FD798}")] - [TestCase(@"c:\{0E4E24C7-E12A-483A-BC8F-E90BC49FD798}")] - [TestCase(@"c:\{0E4E24C7-E12A-483A-BC8F-E90BC49FD798}\11")] - public void NotFound(string path) - { - Assert.Throws(() => FileSystemFactory.FileSystemInfoFromPath(path)); - } + [Test] + [TestCase(@"{0E4E24C7-E12A-483A-BC8F-E90BC49FD798}")] + [TestCase(@"c:\{0E4E24C7-E12A-483A-BC8F-E90BC49FD798}")] + [TestCase(@"c:\{0E4E24C7-E12A-483A-BC8F-E90BC49FD798}\11")] + public void NotFound(string path) + { + Assert.Throws(() => FileSystemFactory.FileSystemInfoFromPath(path)); + } - [Test] - [TestCase(@"Content.zip\xxx")] - [TestCase(@"Content.zip\2\xxx")] - [TestCase(@"Content.zip\2\33.txt")] - [TestCase(@"Content.zip\inner.zip\xxx")] - public void ZipNotFound(string path) + [Test] + [TestCase(@"Content.zip\xxx")] + [TestCase(@"Content.zip\2\xxx")] + [TestCase(@"Content.zip\2\33.txt")] + [TestCase(@"Content.zip\inner.zip\xxx")] + public void ZipNotFound(string path) + { + using (var dir = new TempDirectory()) { - using (var dir = new TempDirectory()) - { - dir.CopyFileFromResources("Content.zip"); + dir.CopyFileFromResources("Content.zip"); - var fullPath = Path.Combine(dir.Location, path); - Assert.Throws(() => FileSystemFactory.FileSystemInfoFromPath(fullPath)); - } + var fullPath = Path.Combine(dir.Location, path); + Assert.Throws(() => FileSystemFactory.FileSystemInfoFromPath(fullPath)); } + } - [Test] - public void NewFileSystemFile() + [Test] + public void NewFileSystemFile() + { + using (var dir = new TempDirectory()) { - using (var dir = new TempDirectory()) - { - var fileName = Path.Combine(dir.Location, "11.txt"); - File.WriteAllBytes(fileName, new byte[] { 1 }); + var fileName = Path.Combine(dir.Location, "11.txt"); + File.WriteAllBytes(fileName, new byte[] { 1 }); - var file = FileSystemFactory.FileSystemInfoFromPath(fileName); - Assert.IsInstanceOf(file); - } + var file = FileSystemFactory.FileSystemInfoFromPath(fileName); + Assert.IsInstanceOf(file); } + } - [Test] - [TestCase(@"Content.zip\11.txt")] - [TestCase(@"Content.zip\2\22.txt")] - [TestCase(@"Content.zip\inner.zip\11.txt")] - public void NewZipFile(string fileName) + [Test] + [TestCase(@"Content.zip\11.txt")] + [TestCase(@"Content.zip\2\22.txt")] + [TestCase(@"Content.zip\inner.zip\11.txt")] + public void NewZipFile(string fileName) + { + using (var dir = new TempDirectory()) { - using (var dir = new TempDirectory()) - { - dir.CopyFileFromResources("Content.zip"); + dir.CopyFileFromResources("Content.zip"); - var file = FileSystemFactory.FileSystemInfoFromPath(Path.Combine(dir.Location, fileName)); - Assert.IsInstanceOf(file); + var file = FileSystemFactory.FileSystemInfoFromPath(Path.Combine(dir.Location, fileName)); + Assert.IsInstanceOf(file); - ((IFile)file).OpenRead().Dispose(); - } + ((IFile)file).OpenRead().Dispose(); } } } \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/IO/FileSystemFileTest.cs b/Sources/SqlDatabase.Test/IO/FileSystemFileTest.cs index 3fb52415..9e748747 100644 --- a/Sources/SqlDatabase.Test/IO/FileSystemFileTest.cs +++ b/Sources/SqlDatabase.Test/IO/FileSystemFileTest.cs @@ -3,30 +3,29 @@ using Shouldly; using SqlDatabase.TestApi; -namespace SqlDatabase.IO +namespace SqlDatabase.IO; + +[TestFixture] +public class FileSystemFileTest { - [TestFixture] - public class FileSystemFileTest + [Test] + public void GetParent() { - [Test] - public void GetParent() + using (var file = new TempFile(".sql")) { - using (var file = new TempFile(".sql")) - { - var sut = new FileSystemFile(file.Location); + var sut = new FileSystemFile(file.Location); - var parent = sut.GetParent().ShouldBeOfType(); - parent.Location.ShouldBe(Path.GetDirectoryName(file.Location)); - } + var parent = sut.GetParent().ShouldBeOfType(); + parent.Location.ShouldBe(Path.GetDirectoryName(file.Location)); } + } - [Test] - public void GetParentDisk() - { - var sut = new FileSystemFile(@"c:\11.txt"); + [Test] + public void GetParentDisk() + { + var sut = new FileSystemFile(@"c:\11.txt"); - var parent = sut.GetParent().ShouldBeOfType(); - parent.Location.ShouldBe(@"c:\"); - } + var parent = sut.GetParent().ShouldBeOfType(); + parent.Location.ShouldBe(@"c:\"); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/IO/FileSystemFolderTest.cs b/Sources/SqlDatabase.Test/IO/FileSystemFolderTest.cs index 947c2a88..4fcf981b 100644 --- a/Sources/SqlDatabase.Test/IO/FileSystemFolderTest.cs +++ b/Sources/SqlDatabase.Test/IO/FileSystemFolderTest.cs @@ -3,54 +3,53 @@ using NUnit.Framework; using SqlDatabase.TestApi; -namespace SqlDatabase.IO +namespace SqlDatabase.IO; + +[TestFixture] +public class FileSystemFolderTest { - [TestFixture] - public class FileSystemFolderTest + [Test] + public void Ctor() { - [Test] - public void Ctor() - { - var folder = new FileSystemFolder(@"d:\11\22"); - Assert.AreEqual("22", folder.Name); - } + var folder = new FileSystemFolder(@"d:\11\22"); + Assert.AreEqual("22", folder.Name); + } - [Test] - public void GetFiles() + [Test] + public void GetFiles() + { + using (var dir = new TempDirectory()) { - using (var dir = new TempDirectory()) - { - var folder = new FileSystemFolder(dir.Location); - Assert.AreEqual(0, folder.GetFiles().Count()); + var folder = new FileSystemFolder(dir.Location); + Assert.AreEqual(0, folder.GetFiles().Count()); - dir.CopyFileFromResources("Content.zip"); - Directory.CreateDirectory(Path.Combine(dir.Location, "11.txt")); + dir.CopyFileFromResources("Content.zip"); + Directory.CreateDirectory(Path.Combine(dir.Location, "11.txt")); - File.WriteAllText(Path.Combine(dir.Location, "22.txt"), string.Empty); - File.WriteAllText(Path.Combine(dir.Location, "33.txt"), string.Empty); + File.WriteAllText(Path.Combine(dir.Location, "22.txt"), string.Empty); + File.WriteAllText(Path.Combine(dir.Location, "33.txt"), string.Empty); - var files = folder.GetFiles().ToArray(); - CollectionAssert.AreEquivalent(new[] { "22.txt", "33.txt" }, files.Select(i => i.Name).ToArray()); - } + var files = folder.GetFiles().ToArray(); + CollectionAssert.AreEquivalent(new[] { "22.txt", "33.txt" }, files.Select(i => i.Name).ToArray()); } + } - [Test] - public void GetFolders() + [Test] + public void GetFolders() + { + using (var dir = new TempDirectory()) { - using (var dir = new TempDirectory()) - { - var folder = new FileSystemFolder(dir.Location); - Assert.AreEqual(0, folder.GetFolders().Count()); + var folder = new FileSystemFolder(dir.Location); + Assert.AreEqual(0, folder.GetFolders().Count()); - File.WriteAllText(Path.Combine(dir.Location, "11.txt"), string.Empty); + File.WriteAllText(Path.Combine(dir.Location, "11.txt"), string.Empty); - dir.CopyFileFromResources("Content.zip"); - Directory.CreateDirectory(Path.Combine(dir.Location, "22.txt")); - Directory.CreateDirectory(Path.Combine(dir.Location, "33")); + dir.CopyFileFromResources("Content.zip"); + Directory.CreateDirectory(Path.Combine(dir.Location, "22.txt")); + Directory.CreateDirectory(Path.Combine(dir.Location, "33")); - var folders = folder.GetFolders().ToArray(); - CollectionAssert.AreEquivalent(new[] { "22.txt", "33", "Content.zip" }, folders.Select(i => i.Name).ToArray()); - } + var folders = folder.GetFolders().ToArray(); + CollectionAssert.AreEquivalent(new[] { "22.txt", "33", "Content.zip" }, folders.Select(i => i.Name).ToArray()); } } } \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/IO/InLineScriptFileTest.cs b/Sources/SqlDatabase.Test/IO/InLineScriptFileTest.cs index 7444df7c..0bb1956b 100644 --- a/Sources/SqlDatabase.Test/IO/InLineScriptFileTest.cs +++ b/Sources/SqlDatabase.Test/IO/InLineScriptFileTest.cs @@ -2,29 +2,28 @@ using NUnit.Framework; using Shouldly; -namespace SqlDatabase.IO +namespace SqlDatabase.IO; + +[TestFixture] +public class InLineScriptFileTest { - [TestFixture] - public class InLineScriptFileTest + [Test] + public void OpenRead() { - [Test] - public void OpenRead() - { - const string Content = "some text"; + const string Content = "some text"; - var stream = new InLineScriptFile("name", Content).OpenRead(); - using (stream) - { - stream.ShouldNotBeNull(); + var stream = new InLineScriptFile("name", Content).OpenRead(); + using (stream) + { + stream.ShouldNotBeNull(); - new StreamReader(stream).ReadToEnd().ShouldBe(Content); - } + new StreamReader(stream).ReadToEnd().ShouldBe(Content); } + } - [Test] - public void GetParent() - { - new InLineScriptFile("name", string.Empty).GetParent().ShouldBeNull(); - } + [Test] + public void GetParent() + { + new InLineScriptFile("name", string.Empty).GetParent().ShouldBeNull(); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/IO/ZipFolderTest.cs b/Sources/SqlDatabase.Test/IO/ZipFolderTest.cs index c68432a3..b865f165 100644 --- a/Sources/SqlDatabase.Test/IO/ZipFolderTest.cs +++ b/Sources/SqlDatabase.Test/IO/ZipFolderTest.cs @@ -4,101 +4,100 @@ using Shouldly; using SqlDatabase.TestApi; -namespace SqlDatabase.IO +namespace SqlDatabase.IO; + +[TestFixture] +public class ZipFolderTest { - [TestFixture] - public class ZipFolderTest + private TempDirectory _temp; + private ZipFolder _sut; + + [SetUp] + public void BeforeEachTest() { - private TempDirectory _temp; - private ZipFolder _sut; + _temp = new TempDirectory(); + _temp.CopyFileFromResources("Content.zip"); + _sut = new ZipFolder(Path.Combine(_temp.Location, "Content.zip")); + } - [SetUp] - public void BeforeEachTest() - { - _temp = new TempDirectory(); - _temp.CopyFileFromResources("Content.zip"); - _sut = new ZipFolder(Path.Combine(_temp.Location, "Content.zip")); - } + [TearDown] + public void AfterEachTest() + { + _temp?.Dispose(); + } - [TearDown] - public void AfterEachTest() - { - _temp?.Dispose(); - } + [Test] + public void Ctor() + { + var folder = new ZipFolder(@"d:\11.zip"); + Assert.AreEqual("11.zip", folder.Name); + } - [Test] - public void Ctor() - { - var folder = new ZipFolder(@"d:\11.zip"); - Assert.AreEqual("11.zip", folder.Name); - } + [Test] + public void GetFolders() + { + var subFolders = _sut.GetFolders().OrderBy(i => i.Name).ToArray(); - [Test] - public void GetFolders() - { - var subFolders = _sut.GetFolders().OrderBy(i => i.Name).ToArray(); + CollectionAssert.AreEqual( + new[] { "1", "2", "inner.zip" }, + subFolders.Select(i => i.Name).ToArray()); + } - CollectionAssert.AreEqual( - new[] { "1", "2", "inner.zip" }, - subFolders.Select(i => i.Name).ToArray()); - } + [Test] + public void GetFiles() + { + var files = _sut.GetFiles().OrderBy(i => i.Name).ToArray(); + CollectionAssert.AreEqual(new[] { "11.txt" }, files.Select(i => i.Name).ToArray()); - [Test] - public void GetFiles() + using (var stream = files[0].OpenRead()) + using (var reader = new StreamReader(stream)) { - var files = _sut.GetFiles().OrderBy(i => i.Name).ToArray(); - CollectionAssert.AreEqual(new[] { "11.txt" }, files.Select(i => i.Name).ToArray()); - - using (var stream = files[0].OpenRead()) - using (var reader = new StreamReader(stream)) - { - Assert.AreEqual("11", reader.ReadToEnd()); - } - - files[0].GetParent().GetFiles().OrderBy(i => i.Name).First().ShouldBe(files[0]); + Assert.AreEqual("11", reader.ReadToEnd()); } - [Test] - public void GetContentOfSubFolders() - { - var subFolders = _sut.GetFolders().OrderBy(i => i.Name).ToArray(); + files[0].GetParent().GetFiles().OrderBy(i => i.Name).First().ShouldBe(files[0]); + } - // 1 - Assert.AreEqual(0, subFolders[0].GetFolders().Count()); - Assert.AreEqual(0, subFolders[0].GetFiles().Count()); + [Test] + public void GetContentOfSubFolders() + { + var subFolders = _sut.GetFolders().OrderBy(i => i.Name).ToArray(); - // 2 - Assert.AreEqual(1, subFolders[1].GetFolders().Count()); + // 1 + Assert.AreEqual(0, subFolders[0].GetFolders().Count()); + Assert.AreEqual(0, subFolders[0].GetFiles().Count()); - var files = subFolders[1].GetFiles().ToArray(); - CollectionAssert.AreEqual(new[] { "22.txt" }, files.Select(i => i.Name).ToArray()); + // 2 + Assert.AreEqual(1, subFolders[1].GetFolders().Count()); - using (var stream = files[0].OpenRead()) - using (var reader = new StreamReader(stream)) - { - Assert.AreEqual("22", reader.ReadToEnd()); - } + var files = subFolders[1].GetFiles().ToArray(); + CollectionAssert.AreEqual(new[] { "22.txt" }, files.Select(i => i.Name).ToArray()); - files[0].GetParent().ShouldBe(subFolders[1]); + using (var stream = files[0].OpenRead()) + using (var reader = new StreamReader(stream)) + { + Assert.AreEqual("22", reader.ReadToEnd()); } - [Test] - public void ReadContentOfEmbeddedZip() - { - var innerZip = _sut.GetFolders().OrderBy(i => i.Name).Last(); + files[0].GetParent().ShouldBe(subFolders[1]); + } - Assert.AreEqual(2, innerZip.GetFolders().Count()); + [Test] + public void ReadContentOfEmbeddedZip() + { + var innerZip = _sut.GetFolders().OrderBy(i => i.Name).Last(); - var files = innerZip.GetFiles().ToArray(); - CollectionAssert.AreEqual(new[] { "11.txt" }, files.Select(i => i.Name).ToArray()); + Assert.AreEqual(2, innerZip.GetFolders().Count()); - using (var stream = files[0].OpenRead()) - using (var reader = new StreamReader(stream)) - { - Assert.AreEqual("11", reader.ReadToEnd()); - } + var files = innerZip.GetFiles().ToArray(); + CollectionAssert.AreEqual(new[] { "11.txt" }, files.Select(i => i.Name).ToArray()); - files[0].GetParent().GetFiles().OrderBy(i => i.Name).First().ShouldBe(files[0]); + using (var stream = files[0].OpenRead()) + using (var reader = new StreamReader(stream)) + { + Assert.AreEqual("11", reader.ReadToEnd()); } + + files[0].GetParent().GetFiles().OrderBy(i => i.Name).First().ShouldBe(files[0]); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/IntegrationTests/MsSql/ProgramTest.cs b/Sources/SqlDatabase.Test/IntegrationTests/MsSql/ProgramTest.cs index 75c0e778..5fec0140 100644 --- a/Sources/SqlDatabase.Test/IntegrationTests/MsSql/ProgramTest.cs +++ b/Sources/SqlDatabase.Test/IntegrationTests/MsSql/ProgramTest.cs @@ -12,266 +12,265 @@ using SqlDatabase.TestApi; using ConfigurationManager = System.Configuration.ConfigurationManager; -namespace SqlDatabase.IntegrationTests.MsSql -{ - [TestFixture] - public class ProgramTest - { - private readonly string _connectionString = new SqlConnectionStringBuilder(MsSqlQuery.ConnectionString) { InitialCatalog = "SqlDatabaseIT" }.ToString(); +namespace SqlDatabase.IntegrationTests.MsSql; - private string _scriptsLocation; - private AppConfiguration _configuration; - private TempFile _logFile; - - [SetUp] - public void BeforeEachTest() - { - TestPowerShellHost.GetOrCreateFactory(); +[TestFixture] +public class ProgramTest +{ + private readonly string _connectionString = new SqlConnectionStringBuilder(MsSqlQuery.ConnectionString) { InitialCatalog = "SqlDatabaseIT" }.ToString(); - _scriptsLocation = ConfigurationManager.AppSettings["MsSql.IntegrationTestsScriptsLocation"]; - if (!Path.IsPathRooted(_scriptsLocation)) - { - _scriptsLocation = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, _scriptsLocation); - } + private string _scriptsLocation; + private AppConfiguration _configuration; + private TempFile _logFile; - _configuration = new AppConfiguration(); + [SetUp] + public void BeforeEachTest() + { + TestPowerShellHost.GetOrCreateFactory(); - _logFile = new TempFile(".log"); + _scriptsLocation = ConfigurationManager.AppSettings["MsSql.IntegrationTestsScriptsLocation"]; + if (!Path.IsPathRooted(_scriptsLocation)) + { + _scriptsLocation = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, _scriptsLocation); } - [TearDown] - public void AfterEachTest() - { - FileAssert.Exists(_logFile.Location); - var fileContent = File.ReadAllLines(_logFile.Location); - _logFile.Dispose(); + _configuration = new AppConfiguration(); - fileContent.ShouldNotBeEmpty(); - } + _logFile = new TempFile(".log"); + } - [Test] - [Order(1)] + [TearDown] + public void AfterEachTest() + { + FileAssert.Exists(_logFile.Location); + var fileContent = File.ReadAllLines(_logFile.Location); + _logFile.Dispose(); - public void CreateDatabase() - { - var args = new GenericCommandLineBuilder() - .SetCommand(CommandLineFactory.CommandCreate) - .SetConnection(_connectionString) - .SetScripts(Path.Combine(_scriptsLocation, "new")) - .SetVariable("JohnCity", "London") - .SetVariable("MariaCity", "Paris") - .SetLogFileName(_logFile.Location) - .BuildArray(); + fileContent.ShouldNotBeEmpty(); + } - Assert.AreEqual(0, Program.Main(args)); + [Test] + [Order(1)] - const string Sql = @" + public void CreateDatabase() + { + var args = new GenericCommandLineBuilder() + .SetCommand(CommandLineFactory.CommandCreate) + .SetConnection(_connectionString) + .SetScripts(Path.Combine(_scriptsLocation, "new")) + .SetVariable("JohnCity", "London") + .SetVariable("MariaCity", "Paris") + .SetLogFileName(_logFile.Location) + .BuildArray(); + + Assert.AreEqual(0, Program.Main(args)); + + const string Sql = @" SELECT Person.Id, Person.Name, PersonAddress.City FROM demo.Person Person INNER JOIN demo.PersonAddress PersonAddress ON (PersonAddress.PersonId = Person.Id) ORDER BY Person.Id"; - Assert.AreEqual(new Version("1.2"), CreateDatabaseObject().GetCurrentVersion(null)); + Assert.AreEqual(new Version("1.2"), CreateDatabaseObject().GetCurrentVersion(null)); - using (var c = new SqlConnection(_connectionString)) - { - c.Open(); - var rows = c.Query(Sql).ToList(); - Assert.AreEqual(2, rows.Count); + using (var c = new SqlConnection(_connectionString)) + { + c.Open(); + var rows = c.Query(Sql).ToList(); + Assert.AreEqual(2, rows.Count); - Assert.AreEqual(1, rows[0].Id); - Assert.AreEqual("John", rows[0].Name); - Assert.AreEqual("London", rows[0].City); + Assert.AreEqual(1, rows[0].Id); + Assert.AreEqual("John", rows[0].Name); + Assert.AreEqual("London", rows[0].City); - Assert.AreEqual(2, rows[1].Id); - Assert.AreEqual("Maria", rows[1].Name); - Assert.AreEqual("Paris", rows[1].City); - } + Assert.AreEqual(2, rows[1].Id); + Assert.AreEqual("Maria", rows[1].Name); + Assert.AreEqual("Paris", rows[1].City); } + } - [Test] - [Order(2)] - public void UpgradeDatabase() - { - var args = new GenericCommandLineBuilder() - .SetCommand(CommandLineFactory.CommandUpgrade) - .SetConnection(_connectionString) - .SetScripts(Path.Combine(_scriptsLocation, "upgrade")) - .SetConfigurationFile(Path.Combine(_scriptsLocation, "Upgrade", "SqlDatabase.exe.config")) - .SetVariable("JohnSecondName", "Smitt") - .SetVariable("MariaSecondName", "X") - .SetLogFileName(_logFile.Location) - .BuildArray(); - - Assert.AreEqual(0, Program.Main(args)); - - const string Sql = @" + [Test] + [Order(2)] + public void UpgradeDatabase() + { + var args = new GenericCommandLineBuilder() + .SetCommand(CommandLineFactory.CommandUpgrade) + .SetConnection(_connectionString) + .SetScripts(Path.Combine(_scriptsLocation, "upgrade")) + .SetConfigurationFile(Path.Combine(_scriptsLocation, "Upgrade", "SqlDatabase.exe.config")) + .SetVariable("JohnSecondName", "Smitt") + .SetVariable("MariaSecondName", "X") + .SetLogFileName(_logFile.Location) + .BuildArray(); + + Assert.AreEqual(0, Program.Main(args)); + + const string Sql = @" SELECT Person.Id, Person.SecondName FROM demo.Person Person ORDER BY Person.Id"; - Assert.AreEqual(new Version("2.1"), CreateDatabaseObject().GetCurrentVersion(null)); + Assert.AreEqual(new Version("2.1"), CreateDatabaseObject().GetCurrentVersion(null)); - using (var c = new SqlConnection(_connectionString)) - { - c.Open(); - var rows = c.Query(Sql).ToList(); - Assert.AreEqual(2, rows.Count); + using (var c = new SqlConnection(_connectionString)) + { + c.Open(); + var rows = c.Query(Sql).ToList(); + Assert.AreEqual(2, rows.Count); - Assert.AreEqual(1, rows[0].Id); - Assert.AreEqual("Smitt", rows[0].SecondName); + Assert.AreEqual(1, rows[0].Id); + Assert.AreEqual("Smitt", rows[0].SecondName); - Assert.AreEqual(2, rows[1].Id); - Assert.AreEqual("X", rows[1].SecondName); - } + Assert.AreEqual(2, rows[1].Id); + Assert.AreEqual("X", rows[1].SecondName); } + } - [Test] - [Order(3)] - public void UpgradeDatabaseModularity() - { - var args = new GenericCommandLineBuilder() - .SetCommand(CommandLineFactory.CommandUpgrade) - .SetConnection(_connectionString) - .SetScripts(Path.Combine(_scriptsLocation, "UpgradeModularity")) - .SetConfigurationFile(Path.Combine(_scriptsLocation, "UpgradeModularity", "SqlDatabase.exe.config")) - .SetLogFileName(_logFile.Location); + [Test] + [Order(3)] + public void UpgradeDatabaseModularity() + { + var args = new GenericCommandLineBuilder() + .SetCommand(CommandLineFactory.CommandUpgrade) + .SetConnection(_connectionString) + .SetScripts(Path.Combine(_scriptsLocation, "UpgradeModularity")) + .SetConfigurationFile(Path.Combine(_scriptsLocation, "UpgradeModularity", "SqlDatabase.exe.config")) + .SetLogFileName(_logFile.Location); - Program.Main(args.BuildArray()).ShouldBe(0); + Program.Main(args.BuildArray()).ShouldBe(0); - const string Sql = @" + const string Sql = @" SELECT p.Name, a.City FROM moduleA.Person p LEFT JOIN moduleB.PersonAddress a ON a.PersonId = p.Id ORDER BY p.Name"; - var configuration = new SqlDatabase.Configuration.ConfigurationManager(); - configuration.LoadFrom(args.Line.ConfigurationFile); + var configuration = new SqlDatabase.Configuration.ConfigurationManager(); + configuration.LoadFrom(args.Line.ConfigurationFile); - var db = CreateDatabaseObject(configuration.SqlDatabase); - db.GetCurrentVersion("ModuleA").ShouldBe(new Version("2.0")); - db.GetCurrentVersion("ModuleB").ShouldBe(new Version("1.1")); - db.GetCurrentVersion("ModuleC").ShouldBe(new Version("2.0")); + var db = CreateDatabaseObject(configuration.SqlDatabase); + db.GetCurrentVersion("ModuleA").ShouldBe(new Version("2.0")); + db.GetCurrentVersion("ModuleB").ShouldBe(new Version("1.1")); + db.GetCurrentVersion("ModuleC").ShouldBe(new Version("2.0")); - using (var c = new SqlConnection(_connectionString)) - { - c.Open(); - var rows = c.Query(Sql).ToList(); - rows.Count.ShouldBe(2); + using (var c = new SqlConnection(_connectionString)) + { + c.Open(); + var rows = c.Query(Sql).ToList(); + rows.Count.ShouldBe(2); + + Assert.AreEqual("John", rows[0].Name); + Assert.AreEqual("London", rows[0].City); + + Assert.AreEqual("Maria", rows[1].Name); + Assert.IsNull(rows[1].City); + } + } + + [Test] + [Order(4)] + public void ExportDataToConsole() + { + // export + var args = new GenericCommandLineBuilder() + .SetCommand(CommandLineFactory.CommandExport) + .SetConnection(_connectionString) + .SetScripts(Path.Combine(_scriptsLocation, @"Export\export.sql")) + .SetExportToTable("dbo.ExportedData1") + .BuildArray(); + + int exitCode; + string output; + using (var console = new TempConsoleOut()) + { + exitCode = Program.Main(args); + output = console.GetOutput(); + } + + Console.WriteLine(output); + exitCode.ShouldBe(0); - Assert.AreEqual("John", rows[0].Name); - Assert.AreEqual("London", rows[0].City); + // exec + InvokeExecuteCommand(b => b.SetInLineScript(output)); + + // test + using (var c = new SqlConnection(_connectionString)) + { + c.Open(); - Assert.AreEqual("Maria", rows[1].Name); - Assert.IsNull(rows[1].City); - } + var test = c.ExecuteScalar("SELECT COUNT(1) FROM dbo.ExportedData1"); + test.ShouldBe(2); } + } - [Test] - [Order(4)] - public void ExportDataToConsole() + [Test] + [Order(5)] + public void ExportDataToFile() + { + using (var output = new TempFile(".sql")) { // export var args = new GenericCommandLineBuilder() .SetCommand(CommandLineFactory.CommandExport) .SetConnection(_connectionString) .SetScripts(Path.Combine(_scriptsLocation, @"Export\export.sql")) - .SetExportToTable("dbo.ExportedData1") + .SetExportToTable("dbo.ExportedData2") + .SetExportToFile(output.Location) .BuildArray(); - int exitCode; - string output; - using (var console = new TempConsoleOut()) - { - exitCode = Program.Main(args); - output = console.GetOutput(); - } - - Console.WriteLine(output); - exitCode.ShouldBe(0); + Program.Main(args).ShouldBe(0); + Console.WriteLine(File.ReadAllText(output.Location)); // exec - InvokeExecuteCommand(b => b.SetInLineScript(output)); - - // test - using (var c = new SqlConnection(_connectionString)) - { - c.Open(); - - var test = c.ExecuteScalar("SELECT COUNT(1) FROM dbo.ExportedData1"); - test.ShouldBe(2); - } + InvokeExecuteCommand(b => b.SetScripts(output.Location)); } - [Test] - [Order(5)] - public void ExportDataToFile() + // test + using (var c = new SqlConnection(_connectionString)) { - using (var output = new TempFile(".sql")) - { - // export - var args = new GenericCommandLineBuilder() - .SetCommand(CommandLineFactory.CommandExport) - .SetConnection(_connectionString) - .SetScripts(Path.Combine(_scriptsLocation, @"Export\export.sql")) - .SetExportToTable("dbo.ExportedData2") - .SetExportToFile(output.Location) - .BuildArray(); - - Program.Main(args).ShouldBe(0); - Console.WriteLine(File.ReadAllText(output.Location)); - - // exec - InvokeExecuteCommand(b => b.SetScripts(output.Location)); - } - - // test - using (var c = new SqlConnection(_connectionString)) - { - c.Open(); - - var test = c.ExecuteScalar("SELECT COUNT(1) FROM dbo.ExportedData2"); - test.ShouldBe(2); - } + c.Open(); + + var test = c.ExecuteScalar("SELECT COUNT(1) FROM dbo.ExportedData2"); + test.ShouldBe(2); } + } - [Test] - [Order(6)] - public void ExecuteScript() - { - InvokeExecuteCommand(b => - b.SetScripts(Path.Combine(_scriptsLocation, "execute", "drop.database.sql"))); + [Test] + [Order(6)] + public void ExecuteScript() + { + InvokeExecuteCommand(b => + b.SetScripts(Path.Combine(_scriptsLocation, "execute", "drop.database.sql"))); - var sql = "SELECT DB_ID('{0}')".FormatWith(new SqlConnectionStringBuilder(_connectionString).InitialCatalog); + var sql = "SELECT DB_ID('{0}')".FormatWith(new SqlConnectionStringBuilder(_connectionString).InitialCatalog); - using (var c = new SqlConnection(MsSqlQuery.ConnectionString)) - { - c.Open(); + using (var c = new SqlConnection(MsSqlQuery.ConnectionString)) + { + c.Open(); - var test = c.ExecuteScalar(sql); - Assert.IsNull(test); - } + var test = c.ExecuteScalar(sql); + Assert.IsNull(test); } + } - private void InvokeExecuteCommand(Action builder) - { - var cmd = new GenericCommandLineBuilder() - .SetCommand(CommandLineFactory.CommandExecute) - .SetConnection(_connectionString) - .SetLogFileName(_logFile.Location); + private void InvokeExecuteCommand(Action builder) + { + var cmd = new GenericCommandLineBuilder() + .SetCommand(CommandLineFactory.CommandExecute) + .SetConnection(_connectionString) + .SetLogFileName(_logFile.Location); - builder(cmd); - var args = cmd.BuildArray(); + builder(cmd); + var args = cmd.BuildArray(); - Program.Main(args).ShouldBe(0); - } + Program.Main(args).ShouldBe(0); + } - private IDatabase CreateDatabaseObject(AppConfiguration configuration = null) + private IDatabase CreateDatabaseObject(AppConfiguration configuration = null) + { + return new Database { - return new Database - { - Adapter = new MsSqlDatabaseAdapter(_connectionString, configuration ?? _configuration, new Mock(MockBehavior.Strict).Object) - }; - } + Adapter = new MsSqlDatabaseAdapter(_connectionString, configuration ?? _configuration, new Mock(MockBehavior.Strict).Object) + }; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/IntegrationTests/MySql/ProgramTest.cs b/Sources/SqlDatabase.Test/IntegrationTests/MySql/ProgramTest.cs index fdfe85c3..b02b765d 100644 --- a/Sources/SqlDatabase.Test/IntegrationTests/MySql/ProgramTest.cs +++ b/Sources/SqlDatabase.Test/IntegrationTests/MySql/ProgramTest.cs @@ -12,267 +12,266 @@ using SqlDatabase.TestApi; using ConfigurationManager = System.Configuration.ConfigurationManager; -namespace SqlDatabase.IntegrationTests.MySql -{ - [TestFixture] - public class ProgramTest - { - private readonly string _connectionString = new MySqlConnectionStringBuilder(MySqlQuery.ConnectionString) { Database = "sqldatabasetest_it" }.ToString(); - - private string _scriptsLocation; - private AppConfiguration _configuration; - private TempFile _logFile; +namespace SqlDatabase.IntegrationTests.MySql; - [SetUp] - public void BeforeEachTest() - { - TestPowerShellHost.GetOrCreateFactory(); +[TestFixture] +public class ProgramTest +{ + private readonly string _connectionString = new MySqlConnectionStringBuilder(MySqlQuery.ConnectionString) { Database = "sqldatabasetest_it" }.ToString(); - _scriptsLocation = ConfigurationManager.AppSettings["MySql.IntegrationTestsScriptsLocation"]; - if (!Path.IsPathRooted(_scriptsLocation)) - { - _scriptsLocation = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, _scriptsLocation); - } + private string _scriptsLocation; + private AppConfiguration _configuration; + private TempFile _logFile; - _configuration = new AppConfiguration(); + [SetUp] + public void BeforeEachTest() + { + TestPowerShellHost.GetOrCreateFactory(); - _logFile = new TempFile(".log"); + _scriptsLocation = ConfigurationManager.AppSettings["MySql.IntegrationTestsScriptsLocation"]; + if (!Path.IsPathRooted(_scriptsLocation)) + { + _scriptsLocation = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, _scriptsLocation); } - [TearDown] - public void AfterEachTest() - { - FileAssert.Exists(_logFile.Location); - var fileContent = File.ReadAllLines(_logFile.Location); - _logFile.Dispose(); + _configuration = new AppConfiguration(); - fileContent.ShouldNotBeEmpty(); - } + _logFile = new TempFile(".log"); + } - [Test] - [Order(1)] + [TearDown] + public void AfterEachTest() + { + FileAssert.Exists(_logFile.Location); + var fileContent = File.ReadAllLines(_logFile.Location); + _logFile.Dispose(); - public void CreateDatabase() - { - var args = new GenericCommandLineBuilder() - .SetCommand(CommandLineFactory.CommandCreate) - .SetConnection(_connectionString) - .SetScripts(Path.Combine(_scriptsLocation, "new")) - .SetVariable("JohnCity", "London") - .SetVariable("MariaCity", "Paris") - .SetLogFileName(_logFile.Location) - .BuildArray(); + fileContent.ShouldNotBeEmpty(); + } - Program.Main(args).ShouldBe(0); + [Test] + [Order(1)] - const string Sql = @" + public void CreateDatabase() + { + var args = new GenericCommandLineBuilder() + .SetCommand(CommandLineFactory.CommandCreate) + .SetConnection(_connectionString) + .SetScripts(Path.Combine(_scriptsLocation, "new")) + .SetVariable("JohnCity", "London") + .SetVariable("MariaCity", "Paris") + .SetLogFileName(_logFile.Location) + .BuildArray(); + + Program.Main(args).ShouldBe(0); + + const string Sql = @" SELECT person.id, person.name, person_address.city FROM person person INNER JOIN person_address person_address ON (person_address.person_id = person.id) ORDER BY person.id"; - CreateDatabaseObject().GetCurrentVersion(null).ShouldBe(new Version("1.2")); + CreateDatabaseObject().GetCurrentVersion(null).ShouldBe(new Version("1.2")); - using (var c = new MySqlConnection(_connectionString)) - { - c.Open(); + using (var c = new MySqlConnection(_connectionString)) + { + c.Open(); - var rows = c.Query(Sql).ToList(); - Assert.AreEqual(2, rows.Count); + var rows = c.Query(Sql).ToList(); + Assert.AreEqual(2, rows.Count); - Assert.AreEqual(1, rows[0].id); - Assert.AreEqual("John", rows[0].name); - Assert.AreEqual("London", rows[0].city); + Assert.AreEqual(1, rows[0].id); + Assert.AreEqual("John", rows[0].name); + Assert.AreEqual("London", rows[0].city); - Assert.AreEqual(2, rows[1].id); - Assert.AreEqual("Maria", rows[1].name); - Assert.AreEqual("Paris", rows[1].city); - } + Assert.AreEqual(2, rows[1].id); + Assert.AreEqual("Maria", rows[1].name); + Assert.AreEqual("Paris", rows[1].city); } + } - [Test] - [Order(2)] - public void UpgradeDatabase() - { - var args = new GenericCommandLineBuilder() - .SetCommand(CommandLineFactory.CommandUpgrade) - .SetConnection(_connectionString) - .SetScripts(Path.Combine(_scriptsLocation, "upgrade")) - .SetConfigurationFile(Path.Combine(_scriptsLocation, "Upgrade", "SqlDatabase.exe.config")) - .SetVariable("JohnSecondName", "Smitt") - .SetVariable("MariaSecondName", "X") - .SetLogFileName(_logFile.Location) - .BuildArray(); - - Program.Main(args).ShouldBe(0); - - const string Sql = @" + [Test] + [Order(2)] + public void UpgradeDatabase() + { + var args = new GenericCommandLineBuilder() + .SetCommand(CommandLineFactory.CommandUpgrade) + .SetConnection(_connectionString) + .SetScripts(Path.Combine(_scriptsLocation, "upgrade")) + .SetConfigurationFile(Path.Combine(_scriptsLocation, "Upgrade", "SqlDatabase.exe.config")) + .SetVariable("JohnSecondName", "Smitt") + .SetVariable("MariaSecondName", "X") + .SetLogFileName(_logFile.Location) + .BuildArray(); + + Program.Main(args).ShouldBe(0); + + const string Sql = @" SELECT person.id, person.second_name FROM person person ORDER BY person.id"; - CreateDatabaseObject().GetCurrentVersion(null).ShouldBe(new Version("2.1")); + CreateDatabaseObject().GetCurrentVersion(null).ShouldBe(new Version("2.1")); - using (var c = new MySqlConnection(_connectionString)) - { - c.Open(); - var rows = c.Query(Sql).ToList(); - Assert.AreEqual(2, rows.Count); + using (var c = new MySqlConnection(_connectionString)) + { + c.Open(); + var rows = c.Query(Sql).ToList(); + Assert.AreEqual(2, rows.Count); - Assert.AreEqual(1, rows[0].id); - Assert.AreEqual("Smitt", rows[0].second_name); + Assert.AreEqual(1, rows[0].id); + Assert.AreEqual("Smitt", rows[0].second_name); - Assert.AreEqual(2, rows[1].id); - Assert.AreEqual("X", rows[1].second_name); - } + Assert.AreEqual(2, rows[1].id); + Assert.AreEqual("X", rows[1].second_name); } + } - [Test] - [Order(3)] - public void UpgradeDatabaseModularity() - { - var args = new GenericCommandLineBuilder() - .SetCommand(CommandLineFactory.CommandUpgrade) - .SetConnection(_connectionString) - .SetScripts(Path.Combine(_scriptsLocation, "UpgradeModularity")) - .SetConfigurationFile(Path.Combine(_scriptsLocation, "UpgradeModularity", "SqlDatabase.exe.config")) - .SetLogFileName(_logFile.Location); + [Test] + [Order(3)] + public void UpgradeDatabaseModularity() + { + var args = new GenericCommandLineBuilder() + .SetCommand(CommandLineFactory.CommandUpgrade) + .SetConnection(_connectionString) + .SetScripts(Path.Combine(_scriptsLocation, "UpgradeModularity")) + .SetConfigurationFile(Path.Combine(_scriptsLocation, "UpgradeModularity", "SqlDatabase.exe.config")) + .SetLogFileName(_logFile.Location); - Program.Main(args.BuildArray()).ShouldBe(0); + Program.Main(args.BuildArray()).ShouldBe(0); - const string Sql = @" + const string Sql = @" SELECT p.name, a.city FROM module_a_person p LEFT JOIN module_b_person_address a ON a.person_id = p.id ORDER BY p.name"; - var configuration = new SqlDatabase.Configuration.ConfigurationManager(); - configuration.LoadFrom(args.Line.ConfigurationFile); + var configuration = new SqlDatabase.Configuration.ConfigurationManager(); + configuration.LoadFrom(args.Line.ConfigurationFile); - var db = CreateDatabaseObject(configuration.SqlDatabase); - db.GetCurrentVersion("ModuleA").ShouldBe(new Version("2.0")); - db.GetCurrentVersion("ModuleB").ShouldBe(new Version("1.1")); - db.GetCurrentVersion("ModuleC").ShouldBe(new Version("2.0")); + var db = CreateDatabaseObject(configuration.SqlDatabase); + db.GetCurrentVersion("ModuleA").ShouldBe(new Version("2.0")); + db.GetCurrentVersion("ModuleB").ShouldBe(new Version("1.1")); + db.GetCurrentVersion("ModuleC").ShouldBe(new Version("2.0")); - using (var c = new MySqlConnection(_connectionString)) - { - c.Open(); - var rows = c.Query(Sql).ToList(); - rows.Count.ShouldBe(2); + using (var c = new MySqlConnection(_connectionString)) + { + c.Open(); + var rows = c.Query(Sql).ToList(); + rows.Count.ShouldBe(2); - Assert.AreEqual("John", rows[0].name); - Assert.AreEqual("London", rows[0].city); + Assert.AreEqual("John", rows[0].name); + Assert.AreEqual("London", rows[0].city); - Assert.AreEqual("Maria", rows[1].name); - Assert.IsNull(rows[1].city); - } + Assert.AreEqual("Maria", rows[1].name); + Assert.IsNull(rows[1].city); } + } + + [Test] + [Order(4)] + public void ExportDataToConsole() + { + // export + var args = new GenericCommandLineBuilder() + .SetCommand(CommandLineFactory.CommandExport) + .SetConnection(_connectionString) + .SetScripts(Path.Combine(_scriptsLocation, @"Export\export.sql")) + .SetExportToTable("exported_data1") + .BuildArray(); + + int exitCode; + string output; + using (var console = new TempConsoleOut()) + { + exitCode = Program.Main(args); + output = console.GetOutput(); + } + + Console.WriteLine(output); + exitCode.ShouldBe(0); + + // exec + InvokeExecuteCommand(b => b.SetInLineScript(output)); - [Test] - [Order(4)] - public void ExportDataToConsole() + // test + using (var c = new MySqlConnection(_connectionString)) + { + c.Open(); + + var test = c.ExecuteScalar("SELECT COUNT(1) FROM exported_data1"); + test.ShouldBe(2); + } + } + + [Test] + [Order(5)] + public void ExportDataToFile() + { + using (var output = new TempFile(".sql")) { // export var args = new GenericCommandLineBuilder() .SetCommand(CommandLineFactory.CommandExport) .SetConnection(_connectionString) .SetScripts(Path.Combine(_scriptsLocation, @"Export\export.sql")) - .SetExportToTable("exported_data1") + .SetExportToTable("exported_data2") + .SetExportToFile(output.Location) .BuildArray(); - int exitCode; - string output; - using (var console = new TempConsoleOut()) - { - exitCode = Program.Main(args); - output = console.GetOutput(); - } - - Console.WriteLine(output); - exitCode.ShouldBe(0); + Program.Main(args).ShouldBe(0); + Console.WriteLine(File.ReadAllText(output.Location)); // exec - InvokeExecuteCommand(b => b.SetInLineScript(output)); - - // test - using (var c = new MySqlConnection(_connectionString)) - { - c.Open(); - - var test = c.ExecuteScalar("SELECT COUNT(1) FROM exported_data1"); - test.ShouldBe(2); - } + InvokeExecuteCommand(b => b.SetScripts(output.Location)); } - [Test] - [Order(5)] - public void ExportDataToFile() + // test + using (var c = new MySqlConnection(_connectionString)) { - using (var output = new TempFile(".sql")) - { - // export - var args = new GenericCommandLineBuilder() - .SetCommand(CommandLineFactory.CommandExport) - .SetConnection(_connectionString) - .SetScripts(Path.Combine(_scriptsLocation, @"Export\export.sql")) - .SetExportToTable("exported_data2") - .SetExportToFile(output.Location) - .BuildArray(); - - Program.Main(args).ShouldBe(0); - Console.WriteLine(File.ReadAllText(output.Location)); - - // exec - InvokeExecuteCommand(b => b.SetScripts(output.Location)); - } - - // test - using (var c = new MySqlConnection(_connectionString)) - { - c.Open(); - - var test = c.ExecuteScalar("SELECT COUNT(1) FROM exported_data2"); - test.ShouldBe(2); - } + c.Open(); + + var test = c.ExecuteScalar("SELECT COUNT(1) FROM exported_data2"); + test.ShouldBe(2); } + } - [Test] - [Order(6)] - public void ExecuteScript() - { - InvokeExecuteCommand(b => - b.SetScripts(Path.Combine(_scriptsLocation, "execute", "drop.database.ps1"))); + [Test] + [Order(6)] + public void ExecuteScript() + { + InvokeExecuteCommand(b => + b.SetScripts(Path.Combine(_scriptsLocation, "execute", "drop.database.ps1"))); - var sql = "SELECT 1 FROM information_schema.schemata WHERE LOWER(schema_name) = LOWER('{0}')".FormatWith(new MySqlConnectionStringBuilder(_connectionString).Database); + var sql = "SELECT 1 FROM information_schema.schemata WHERE LOWER(schema_name) = LOWER('{0}')".FormatWith(new MySqlConnectionStringBuilder(_connectionString).Database); - using (var c = new MySqlConnection(MySqlQuery.ConnectionString)) - { - c.Open(); + using (var c = new MySqlConnection(MySqlQuery.ConnectionString)) + { + c.Open(); - var test = c.ExecuteScalar(sql); - Assert.IsNull(test); - } + var test = c.ExecuteScalar(sql); + Assert.IsNull(test); } + } - private void InvokeExecuteCommand(Action builder) - { - var cmd = new GenericCommandLineBuilder() - .SetCommand(CommandLineFactory.CommandExecute) - .SetConnection(_connectionString) - .SetLogFileName(_logFile.Location); + private void InvokeExecuteCommand(Action builder) + { + var cmd = new GenericCommandLineBuilder() + .SetCommand(CommandLineFactory.CommandExecute) + .SetConnection(_connectionString) + .SetLogFileName(_logFile.Location); - builder(cmd); - var args = cmd.BuildArray(); + builder(cmd); + var args = cmd.BuildArray(); - Program.Main(args).ShouldBe(0); - } + Program.Main(args).ShouldBe(0); + } - private IDatabase CreateDatabaseObject(AppConfiguration configuration = null) + private IDatabase CreateDatabaseObject(AppConfiguration configuration = null) + { + return new Database { - return new Database - { - Adapter = new MySqlDatabaseAdapter(_connectionString, configuration ?? _configuration, new Mock(MockBehavior.Strict).Object) - }; - } + Adapter = new MySqlDatabaseAdapter(_connectionString, configuration ?? _configuration, new Mock(MockBehavior.Strict).Object) + }; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/IntegrationTests/PgSql/ProgramTest.cs b/Sources/SqlDatabase.Test/IntegrationTests/PgSql/ProgramTest.cs index 121a26a8..dbd52775 100644 --- a/Sources/SqlDatabase.Test/IntegrationTests/PgSql/ProgramTest.cs +++ b/Sources/SqlDatabase.Test/IntegrationTests/PgSql/ProgramTest.cs @@ -12,267 +12,266 @@ using SqlDatabase.TestApi; using ConfigurationManager = System.Configuration.ConfigurationManager; -namespace SqlDatabase.IntegrationTests.PgSql -{ - [TestFixture] - public class ProgramTest - { - private readonly string _connectionString = new NpgsqlConnectionStringBuilder(PgSqlQuery.ConnectionString) { Database = "sqldatabasetest_it" }.ToString(); - - private string _scriptsLocation; - private AppConfiguration _configuration; - private TempFile _logFile; +namespace SqlDatabase.IntegrationTests.PgSql; - [SetUp] - public void BeforeEachTest() - { - TestPowerShellHost.GetOrCreateFactory(); +[TestFixture] +public class ProgramTest +{ + private readonly string _connectionString = new NpgsqlConnectionStringBuilder(PgSqlQuery.ConnectionString) { Database = "sqldatabasetest_it" }.ToString(); - _scriptsLocation = ConfigurationManager.AppSettings["PgSql.IntegrationTestsScriptsLocation"]; - if (!Path.IsPathRooted(_scriptsLocation)) - { - _scriptsLocation = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, _scriptsLocation); - } + private string _scriptsLocation; + private AppConfiguration _configuration; + private TempFile _logFile; - _configuration = new AppConfiguration(); + [SetUp] + public void BeforeEachTest() + { + TestPowerShellHost.GetOrCreateFactory(); - _logFile = new TempFile(".log"); + _scriptsLocation = ConfigurationManager.AppSettings["PgSql.IntegrationTestsScriptsLocation"]; + if (!Path.IsPathRooted(_scriptsLocation)) + { + _scriptsLocation = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, _scriptsLocation); } - [TearDown] - public void AfterEachTest() - { - FileAssert.Exists(_logFile.Location); - var fileContent = File.ReadAllLines(_logFile.Location); - _logFile.Dispose(); + _configuration = new AppConfiguration(); - fileContent.ShouldNotBeEmpty(); - } + _logFile = new TempFile(".log"); + } - [Test] - [Order(1)] + [TearDown] + public void AfterEachTest() + { + FileAssert.Exists(_logFile.Location); + var fileContent = File.ReadAllLines(_logFile.Location); + _logFile.Dispose(); - public void CreateDatabase() - { - var args = new GenericCommandLineBuilder() - .SetCommand(CommandLineFactory.CommandCreate) - .SetConnection(_connectionString) - .SetScripts(Path.Combine(_scriptsLocation, "new")) - .SetVariable("JohnCity", "London") - .SetVariable("MariaCity", "Paris") - .SetLogFileName(_logFile.Location) - .BuildArray(); + fileContent.ShouldNotBeEmpty(); + } - Program.Main(args).ShouldBe(0); + [Test] + [Order(1)] - const string Sql = @" + public void CreateDatabase() + { + var args = new GenericCommandLineBuilder() + .SetCommand(CommandLineFactory.CommandCreate) + .SetConnection(_connectionString) + .SetScripts(Path.Combine(_scriptsLocation, "new")) + .SetVariable("JohnCity", "London") + .SetVariable("MariaCity", "Paris") + .SetLogFileName(_logFile.Location) + .BuildArray(); + + Program.Main(args).ShouldBe(0); + + const string Sql = @" SELECT person.id, person.name, person_address.city FROM demo.person person INNER JOIN demo.person_address person_address ON (person_address.person_id = person.id) ORDER BY person.id"; - CreateDatabaseObject().GetCurrentVersion(null).ShouldBe(new Version("1.2")); + CreateDatabaseObject().GetCurrentVersion(null).ShouldBe(new Version("1.2")); - using (var c = new NpgsqlConnection(_connectionString)) - { - c.Open(); + using (var c = new NpgsqlConnection(_connectionString)) + { + c.Open(); - var rows = c.Query(Sql).ToList(); - Assert.AreEqual(2, rows.Count); + var rows = c.Query(Sql).ToList(); + Assert.AreEqual(2, rows.Count); - Assert.AreEqual(1, rows[0].id); - Assert.AreEqual("John", rows[0].name); - Assert.AreEqual("London", rows[0].city); + Assert.AreEqual(1, rows[0].id); + Assert.AreEqual("John", rows[0].name); + Assert.AreEqual("London", rows[0].city); - Assert.AreEqual(2, rows[1].id); - Assert.AreEqual("Maria", rows[1].name); - Assert.AreEqual("Paris", rows[1].city); - } + Assert.AreEqual(2, rows[1].id); + Assert.AreEqual("Maria", rows[1].name); + Assert.AreEqual("Paris", rows[1].city); } + } - [Test] - [Order(2)] - public void UpgradeDatabase() - { - var args = new GenericCommandLineBuilder() - .SetCommand(CommandLineFactory.CommandUpgrade) - .SetConnection(_connectionString) - .SetScripts(Path.Combine(_scriptsLocation, "upgrade")) - .SetConfigurationFile(Path.Combine(_scriptsLocation, "Upgrade", "SqlDatabase.exe.config")) - .SetVariable("JohnSecondName", "Smitt") - .SetVariable("MariaSecondName", "X") - .SetLogFileName(_logFile.Location) - .BuildArray(); - - Program.Main(args).ShouldBe(0); - - const string Sql = @" + [Test] + [Order(2)] + public void UpgradeDatabase() + { + var args = new GenericCommandLineBuilder() + .SetCommand(CommandLineFactory.CommandUpgrade) + .SetConnection(_connectionString) + .SetScripts(Path.Combine(_scriptsLocation, "upgrade")) + .SetConfigurationFile(Path.Combine(_scriptsLocation, "Upgrade", "SqlDatabase.exe.config")) + .SetVariable("JohnSecondName", "Smitt") + .SetVariable("MariaSecondName", "X") + .SetLogFileName(_logFile.Location) + .BuildArray(); + + Program.Main(args).ShouldBe(0); + + const string Sql = @" SELECT person.id, person.second_name FROM demo.person person ORDER BY person.id"; - CreateDatabaseObject().GetCurrentVersion(null).ShouldBe(new Version("2.1")); + CreateDatabaseObject().GetCurrentVersion(null).ShouldBe(new Version("2.1")); - using (var c = new NpgsqlConnection(_connectionString)) - { - c.Open(); - var rows = c.Query(Sql).ToList(); - Assert.AreEqual(2, rows.Count); + using (var c = new NpgsqlConnection(_connectionString)) + { + c.Open(); + var rows = c.Query(Sql).ToList(); + Assert.AreEqual(2, rows.Count); - Assert.AreEqual(1, rows[0].id); - Assert.AreEqual("Smitt", rows[0].second_name); + Assert.AreEqual(1, rows[0].id); + Assert.AreEqual("Smitt", rows[0].second_name); - Assert.AreEqual(2, rows[1].id); - Assert.AreEqual("X", rows[1].second_name); - } + Assert.AreEqual(2, rows[1].id); + Assert.AreEqual("X", rows[1].second_name); } + } - [Test] - [Order(3)] - public void UpgradeDatabaseModularity() - { - var args = new GenericCommandLineBuilder() - .SetCommand(CommandLineFactory.CommandUpgrade) - .SetConnection(_connectionString) - .SetScripts(Path.Combine(_scriptsLocation, "UpgradeModularity")) - .SetConfigurationFile(Path.Combine(_scriptsLocation, "UpgradeModularity", "SqlDatabase.exe.config")) - .SetLogFileName(_logFile.Location); + [Test] + [Order(3)] + public void UpgradeDatabaseModularity() + { + var args = new GenericCommandLineBuilder() + .SetCommand(CommandLineFactory.CommandUpgrade) + .SetConnection(_connectionString) + .SetScripts(Path.Combine(_scriptsLocation, "UpgradeModularity")) + .SetConfigurationFile(Path.Combine(_scriptsLocation, "UpgradeModularity", "SqlDatabase.exe.config")) + .SetLogFileName(_logFile.Location); - Program.Main(args.BuildArray()).ShouldBe(0); + Program.Main(args.BuildArray()).ShouldBe(0); - const string Sql = @" + const string Sql = @" SELECT p.name, a.city FROM module_a.person p LEFT JOIN module_b.person_address a ON a.person_id = p.id ORDER BY p.name"; - var configuration = new SqlDatabase.Configuration.ConfigurationManager(); - configuration.LoadFrom(args.Line.ConfigurationFile); + var configuration = new SqlDatabase.Configuration.ConfigurationManager(); + configuration.LoadFrom(args.Line.ConfigurationFile); - var db = CreateDatabaseObject(configuration.SqlDatabase); - db.GetCurrentVersion("ModuleA").ShouldBe(new Version("2.0")); - db.GetCurrentVersion("ModuleB").ShouldBe(new Version("1.1")); - db.GetCurrentVersion("ModuleC").ShouldBe(new Version("2.0")); + var db = CreateDatabaseObject(configuration.SqlDatabase); + db.GetCurrentVersion("ModuleA").ShouldBe(new Version("2.0")); + db.GetCurrentVersion("ModuleB").ShouldBe(new Version("1.1")); + db.GetCurrentVersion("ModuleC").ShouldBe(new Version("2.0")); - using (var c = new NpgsqlConnection(_connectionString)) - { - c.Open(); - var rows = c.Query(Sql).ToList(); - rows.Count.ShouldBe(2); + using (var c = new NpgsqlConnection(_connectionString)) + { + c.Open(); + var rows = c.Query(Sql).ToList(); + rows.Count.ShouldBe(2); - Assert.AreEqual("John", rows[0].name); - Assert.AreEqual("London", rows[0].city); + Assert.AreEqual("John", rows[0].name); + Assert.AreEqual("London", rows[0].city); - Assert.AreEqual("Maria", rows[1].name); - Assert.IsNull(rows[1].city); - } + Assert.AreEqual("Maria", rows[1].name); + Assert.IsNull(rows[1].city); } + } + + [Test] + [Order(4)] + public void ExportDataToConsole() + { + // export + var args = new GenericCommandLineBuilder() + .SetCommand(CommandLineFactory.CommandExport) + .SetConnection(_connectionString) + .SetScripts(Path.Combine(_scriptsLocation, @"Export\export.sql")) + .SetExportToTable("public.exported_data1") + .BuildArray(); + + int exitCode; + string output; + using (var console = new TempConsoleOut()) + { + exitCode = Program.Main(args); + output = console.GetOutput(); + } + + Console.WriteLine(output); + exitCode.ShouldBe(0); + + // exec + InvokeExecuteCommand(b => b.SetInLineScript(output)); - [Test] - [Order(4)] - public void ExportDataToConsole() + // test + using (var c = new NpgsqlConnection(_connectionString)) + { + c.Open(); + + var test = c.ExecuteScalar("SELECT COUNT(1) FROM public.exported_data1"); + test.ShouldBe(2); + } + } + + [Test] + [Order(5)] + public void ExportDataToFile() + { + using (var output = new TempFile(".sql")) { // export var args = new GenericCommandLineBuilder() .SetCommand(CommandLineFactory.CommandExport) .SetConnection(_connectionString) .SetScripts(Path.Combine(_scriptsLocation, @"Export\export.sql")) - .SetExportToTable("public.exported_data1") + .SetExportToTable("public.exported_data2") + .SetExportToFile(output.Location) .BuildArray(); - int exitCode; - string output; - using (var console = new TempConsoleOut()) - { - exitCode = Program.Main(args); - output = console.GetOutput(); - } - - Console.WriteLine(output); - exitCode.ShouldBe(0); + Program.Main(args).ShouldBe(0); + Console.WriteLine(File.ReadAllText(output.Location)); // exec - InvokeExecuteCommand(b => b.SetInLineScript(output)); - - // test - using (var c = new NpgsqlConnection(_connectionString)) - { - c.Open(); - - var test = c.ExecuteScalar("SELECT COUNT(1) FROM public.exported_data1"); - test.ShouldBe(2); - } + InvokeExecuteCommand(b => b.SetScripts(output.Location)); } - [Test] - [Order(5)] - public void ExportDataToFile() + // test + using (var c = new NpgsqlConnection(_connectionString)) { - using (var output = new TempFile(".sql")) - { - // export - var args = new GenericCommandLineBuilder() - .SetCommand(CommandLineFactory.CommandExport) - .SetConnection(_connectionString) - .SetScripts(Path.Combine(_scriptsLocation, @"Export\export.sql")) - .SetExportToTable("public.exported_data2") - .SetExportToFile(output.Location) - .BuildArray(); - - Program.Main(args).ShouldBe(0); - Console.WriteLine(File.ReadAllText(output.Location)); - - // exec - InvokeExecuteCommand(b => b.SetScripts(output.Location)); - } - - // test - using (var c = new NpgsqlConnection(_connectionString)) - { - c.Open(); - - var test = c.ExecuteScalar("SELECT COUNT(1) FROM public.exported_data2"); - test.ShouldBe(2); - } + c.Open(); + + var test = c.ExecuteScalar("SELECT COUNT(1) FROM public.exported_data2"); + test.ShouldBe(2); } + } - [Test] - [Order(6)] - public void ExecuteScript() - { - InvokeExecuteCommand(b => - b.SetScripts(Path.Combine(_scriptsLocation, "execute", "drop.database.ps1"))); + [Test] + [Order(6)] + public void ExecuteScript() + { + InvokeExecuteCommand(b => + b.SetScripts(Path.Combine(_scriptsLocation, "execute", "drop.database.ps1"))); - var sql = "SELECT 1 FROM PG_DATABASE WHERE LOWER(DATNAME) = LOWER('{0}')".FormatWith(new NpgsqlConnectionStringBuilder(_connectionString).Database); + var sql = "SELECT 1 FROM PG_DATABASE WHERE LOWER(DATNAME) = LOWER('{0}')".FormatWith(new NpgsqlConnectionStringBuilder(_connectionString).Database); - using (var c = new NpgsqlConnection(PgSqlQuery.ConnectionString)) - { - c.Open(); + using (var c = new NpgsqlConnection(PgSqlQuery.ConnectionString)) + { + c.Open(); - var test = c.ExecuteScalar(sql); - Assert.IsNull(test); - } + var test = c.ExecuteScalar(sql); + Assert.IsNull(test); } + } - private void InvokeExecuteCommand(Action builder) - { - var cmd = new GenericCommandLineBuilder() - .SetCommand(CommandLineFactory.CommandExecute) - .SetConnection(_connectionString) - .SetLogFileName(_logFile.Location); + private void InvokeExecuteCommand(Action builder) + { + var cmd = new GenericCommandLineBuilder() + .SetCommand(CommandLineFactory.CommandExecute) + .SetConnection(_connectionString) + .SetLogFileName(_logFile.Location); - builder(cmd); - var args = cmd.BuildArray(); + builder(cmd); + var args = cmd.BuildArray(); - Program.Main(args).ShouldBe(0); - } + Program.Main(args).ShouldBe(0); + } - private IDatabase CreateDatabaseObject(AppConfiguration configuration = null) + private IDatabase CreateDatabaseObject(AppConfiguration configuration = null) + { + return new Database { - return new Database - { - Adapter = new PgSqlDatabaseAdapter(_connectionString, configuration ?? _configuration, new Mock(MockBehavior.Strict).Object) - }; - } + Adapter = new PgSqlDatabaseAdapter(_connectionString, configuration ?? _configuration, new Mock(MockBehavior.Strict).Object) + }; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Log/CombinedLoggerTest.cs b/Sources/SqlDatabase.Test/Log/CombinedLoggerTest.cs index 4f5f92b4..665bf7b4 100644 --- a/Sources/SqlDatabase.Test/Log/CombinedLoggerTest.cs +++ b/Sources/SqlDatabase.Test/Log/CombinedLoggerTest.cs @@ -3,98 +3,97 @@ using NUnit.Framework; using Shouldly; -namespace SqlDatabase.Log +namespace SqlDatabase.Log; + +[TestFixture] +public class CombinedLoggerTest { - [TestFixture] - public class CombinedLoggerTest + private CombinedLogger _sut; + private Mock _logger1; + private Mock _logger2; + + public interface IDisposableLogger : ILogger, IDisposable + { + } + + [SetUp] + public void BeforeEachTest() { - private CombinedLogger _sut; - private Mock _logger1; - private Mock _logger2; - - public interface IDisposableLogger : ILogger, IDisposable - { - } - - [SetUp] - public void BeforeEachTest() - { - _logger1 = new Mock(MockBehavior.Strict); - _logger2 = new Mock(MockBehavior.Strict); - _sut = new CombinedLogger(_logger1.Object, true, _logger2.Object, true); - } - - [Test] - public void Info() - { - _logger1.Setup(l => l.Info("some message")); - _logger2.Setup(l => l.Info("some message")); - - _sut.Info("some message"); - - _logger1.VerifyAll(); - _logger2.VerifyAll(); - } - - [Test] - public void Error() - { - _logger1.Setup(l => l.Error("some message")); - _logger2.Setup(l => l.Error("some message")); - - _sut.Error("some message"); - - _logger1.VerifyAll(); - _logger2.VerifyAll(); - } - - [Test] - public void Indent() - { - var indent1 = new Mock(MockBehavior.Strict); - var indent2 = new Mock(MockBehavior.Strict); - - _logger1 - .Setup(l => l.Indent()) - .Returns(indent1.Object); - _logger2 - .Setup(l => l.Indent()) - .Returns(indent2.Object); - - var actual = _sut.Indent(); - - actual.ShouldNotBeNull(); - _logger1.VerifyAll(); - _logger2.VerifyAll(); - - indent1.Setup(i => i.Dispose()); - indent2.Setup(i => i.Dispose()); - - actual.Dispose(); - - indent1.VerifyAll(); - indent2.VerifyAll(); - } - - [Test] - public void DisposeOwned() - { - _logger1.Setup(l => l.Dispose()); - _logger2.Setup(l => l.Dispose()); - - _sut.Dispose(); - - _logger1.VerifyAll(); - _logger2.VerifyAll(); - } - - [Test] - public void DisposeNotOwned() - { - _sut.OwnLogger1 = false; - _sut.OwnLogger2 = false; - - _sut.Dispose(); - } + _logger1 = new Mock(MockBehavior.Strict); + _logger2 = new Mock(MockBehavior.Strict); + _sut = new CombinedLogger(_logger1.Object, true, _logger2.Object, true); + } + + [Test] + public void Info() + { + _logger1.Setup(l => l.Info("some message")); + _logger2.Setup(l => l.Info("some message")); + + _sut.Info("some message"); + + _logger1.VerifyAll(); + _logger2.VerifyAll(); + } + + [Test] + public void Error() + { + _logger1.Setup(l => l.Error("some message")); + _logger2.Setup(l => l.Error("some message")); + + _sut.Error("some message"); + + _logger1.VerifyAll(); + _logger2.VerifyAll(); + } + + [Test] + public void Indent() + { + var indent1 = new Mock(MockBehavior.Strict); + var indent2 = new Mock(MockBehavior.Strict); + + _logger1 + .Setup(l => l.Indent()) + .Returns(indent1.Object); + _logger2 + .Setup(l => l.Indent()) + .Returns(indent2.Object); + + var actual = _sut.Indent(); + + actual.ShouldNotBeNull(); + _logger1.VerifyAll(); + _logger2.VerifyAll(); + + indent1.Setup(i => i.Dispose()); + indent2.Setup(i => i.Dispose()); + + actual.Dispose(); + + indent1.VerifyAll(); + indent2.VerifyAll(); + } + + [Test] + public void DisposeOwned() + { + _logger1.Setup(l => l.Dispose()); + _logger2.Setup(l => l.Dispose()); + + _sut.Dispose(); + + _logger1.VerifyAll(); + _logger2.VerifyAll(); + } + + [Test] + public void DisposeNotOwned() + { + _sut.OwnLogger1 = false; + _sut.OwnLogger2 = false; + + _sut.Dispose(); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Log/FileLoggerTest.cs b/Sources/SqlDatabase.Test/Log/FileLoggerTest.cs index 4687df89..7cd4e8b0 100644 --- a/Sources/SqlDatabase.Test/Log/FileLoggerTest.cs +++ b/Sources/SqlDatabase.Test/Log/FileLoggerTest.cs @@ -4,109 +4,108 @@ using Shouldly; using SqlDatabase.TestApi; -namespace SqlDatabase.Log +namespace SqlDatabase.Log; + +[TestFixture] +public class FileLoggerTest { - [TestFixture] - public class FileLoggerTest + private TempFile _file; + + [SetUp] + public void BeforeEachTest() { - private TempFile _file; + _file = new TempFile(".log"); + } - [SetUp] - public void BeforeEachTest() - { - _file = new TempFile(".log"); - } + [TearDown] + public void AfterEachTest() + { + _file?.Dispose(); + } - [TearDown] - public void AfterEachTest() + [Test] + public void Info() + { + using (var sut = new FileLogger(_file.Location)) { - _file?.Dispose(); + sut.Info("some message"); } - [Test] - public void Info() - { - using (var sut = new FileLogger(_file.Location)) - { - sut.Info("some message"); - } + var actual = File.ReadAllText(_file.Location); - var actual = File.ReadAllText(_file.Location); + Console.WriteLine(actual); + actual.ShouldContain(" INFO "); + actual.ShouldContain(" some message"); + } - Console.WriteLine(actual); - actual.ShouldContain(" INFO "); - actual.ShouldContain(" some message"); + [Test] + public void Error() + { + using (var sut = new FileLogger(_file.Location)) + { + sut.Error("some message"); } - [Test] - public void Error() - { - using (var sut = new FileLogger(_file.Location)) - { - sut.Error("some message"); - } + var actual = File.ReadAllText(_file.Location); - var actual = File.ReadAllText(_file.Location); + Console.WriteLine(actual); + actual.ShouldContain(" ERROR "); + actual.ShouldContain(" some message"); + } - Console.WriteLine(actual); - actual.ShouldContain(" ERROR "); - actual.ShouldContain(" some message"); - } + [Test] + public void Append() + { + File.WriteAllLines(_file.Location, new[] { "do not remove" }); - [Test] - public void Append() + using (var sut = new FileLogger(_file.Location)) { - File.WriteAllLines(_file.Location, new[] { "do not remove" }); - - using (var sut = new FileLogger(_file.Location)) - { - sut.Info("some message"); - sut.Error("some error"); - } + sut.Info("some message"); + sut.Error("some error"); + } - var actual = File.ReadAllText(_file.Location); + var actual = File.ReadAllText(_file.Location); - Console.WriteLine(actual); - actual.ShouldContain("do not remove"); - actual.ShouldContain(" INFO "); - actual.ShouldContain(" some message"); - actual.ShouldContain(" ERROR "); - actual.ShouldContain(" some error"); - } + Console.WriteLine(actual); + actual.ShouldContain("do not remove"); + actual.ShouldContain(" INFO "); + actual.ShouldContain(" some message"); + actual.ShouldContain(" ERROR "); + actual.ShouldContain(" some error"); + } - [Test] - public void FileIsAvailableForRead() + [Test] + public void FileIsAvailableForRead() + { + string actual; + using (var sut = new FileLogger(_file.Location)) { - string actual; - using (var sut = new FileLogger(_file.Location)) + sut.Info("some message"); + sut.Flush(); + + using (var stream = new FileStream(_file.Location, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + using (var reader = new StreamReader(stream)) { - sut.Info("some message"); - sut.Flush(); - - using (var stream = new FileStream(_file.Location, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) - using (var reader = new StreamReader(stream)) - { - actual = reader.ReadToEnd(); - } + actual = reader.ReadToEnd(); } - - Console.WriteLine(actual); - actual.ShouldContain(" INFO "); - actual.ShouldContain(" some message"); } - [Test] - public void WriteNull() + Console.WriteLine(actual); + actual.ShouldContain(" INFO "); + actual.ShouldContain(" some message"); + } + + [Test] + public void WriteNull() + { + using (var sut = new FileLogger(_file.Location)) { - using (var sut = new FileLogger(_file.Location)) - { - sut.Info(null); - } + sut.Info(null); + } - var actual = File.ReadAllText(_file.Location); + var actual = File.ReadAllText(_file.Location); - Console.WriteLine(actual); - actual.ShouldContain(" INFO "); - } + Console.WriteLine(actual); + actual.ShouldContain(" INFO "); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Log/LoggerBaseTest.cs b/Sources/SqlDatabase.Test/Log/LoggerBaseTest.cs index 5909ae0a..09d27d13 100644 --- a/Sources/SqlDatabase.Test/Log/LoggerBaseTest.cs +++ b/Sources/SqlDatabase.Test/Log/LoggerBaseTest.cs @@ -3,85 +3,84 @@ using Moq.Protected; using NUnit.Framework; -namespace SqlDatabase.Log +namespace SqlDatabase.Log; + +[TestFixture] +public class LoggerBaseTest { - [TestFixture] - public class LoggerBaseTest + private IList _info; + private IList _error; + private LoggerBase _sut; + + [SetUp] + public void BeforeEachTest() { - private IList _info; - private IList _error; - private LoggerBase _sut; + _info = new List(); + _error = new List(); - [SetUp] - public void BeforeEachTest() - { - _info = new List(); - _error = new List(); - - var logger = new Mock(MockBehavior.Strict); - logger - .Protected() - .Setup("WriteError", ItExpr.IsAny()) - .Callback(_error.Add); - logger - .Protected() - .Setup("WriteInfo", ItExpr.IsAny()) - .Callback(_info.Add); - - _sut = logger.Object; - } + var logger = new Mock(MockBehavior.Strict); + logger + .Protected() + .Setup("WriteError", ItExpr.IsAny()) + .Callback(_error.Add); + logger + .Protected() + .Setup("WriteInfo", ItExpr.IsAny()) + .Callback(_info.Add); - [Test] - public void Info() - { - _sut.Info("the text"); + _sut = logger.Object; + } - Assert.AreEqual(1, _info.Count); - Assert.AreEqual(0, _error.Count); - Assert.AreEqual("the text", _info[0]); - } + [Test] + public void Info() + { + _sut.Info("the text"); - [Test] - public void Error() - { - _sut.Error("the text"); + Assert.AreEqual(1, _info.Count); + Assert.AreEqual(0, _error.Count); + Assert.AreEqual("the text", _info[0]); + } - Assert.AreEqual(0, _info.Count); - Assert.AreEqual(1, _error.Count); - Assert.AreEqual("the text", _error[0]); - } + [Test] + public void Error() + { + _sut.Error("the text"); - [Test] - public void NoIndentOnError() - { - _sut.Indent(); - _sut.Error("the text"); + Assert.AreEqual(0, _info.Count); + Assert.AreEqual(1, _error.Count); + Assert.AreEqual("the text", _error[0]); + } - Assert.AreEqual("the text", _error[0]); - } + [Test] + public void NoIndentOnError() + { + _sut.Indent(); + _sut.Error("the text"); + + Assert.AreEqual("the text", _error[0]); + } - [Test] - public void IndentInfo() + [Test] + public void IndentInfo() + { + _sut.Info("1-"); + + using (_sut.Indent()) { - _sut.Info("1-"); + _sut.Info("2-"); using (_sut.Indent()) { - _sut.Info("2-"); - - using (_sut.Indent()) - { - _sut.Info("3"); - } - - _sut.Info("2+"); + _sut.Info("3"); } - Assert.AreEqual(4, _info.Count); - Assert.AreEqual("1-", _info[0]); - Assert.AreEqual(" 2-", _info[1]); - Assert.AreEqual(" 3", _info[2]); - Assert.AreEqual(" 2+", _info[3]); + _sut.Info("2+"); } + + Assert.AreEqual(4, _info.Count); + Assert.AreEqual("1-", _info[0]); + Assert.AreEqual(" 2-", _info[1]); + Assert.AreEqual(" 3", _info[2]); + Assert.AreEqual(" 2+", _info[3]); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/DbCommandStub.cs b/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/DbCommandStub.cs index 0a311927..aa28051f 100644 --- a/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/DbCommandStub.cs +++ b/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/DbCommandStub.cs @@ -2,89 +2,88 @@ using System.Data; using System.Data.Common; -namespace SqlDatabase.Scripts.AssemblyInternal +namespace SqlDatabase.Scripts.AssemblyInternal; + +internal sealed class DbCommandStub : DbCommand { - internal sealed class DbCommandStub : DbCommand + private readonly IDbCommand _command; + + public DbCommandStub(IDbCommand command) + { + _command = command; + } + + public override string CommandText + { + get => _command.CommandText; + set => _command.CommandText = value; + } + + public override int CommandTimeout + { + get => _command.CommandTimeout; + set => _command.CommandTimeout = value; + } + + public override CommandType CommandType + { + get => _command.CommandType; + set => _command.CommandType = value; + } + + public override UpdateRowSource UpdatedRowSource + { + get => _command.UpdatedRowSource; + set => _command.UpdatedRowSource = value; + } + + public override bool DesignTimeVisible + { + get => throw new NotSupportedException(); + set => throw new NotSupportedException(); + } + + protected override DbConnection DbConnection + { + get => throw new NotSupportedException(); + set => throw new NotSupportedException(); + } + + protected override DbParameterCollection DbParameterCollection => throw new NotSupportedException(); + + protected override DbTransaction DbTransaction + { + get => throw new NotSupportedException(); + set => throw new NotSupportedException(); + } + + public override void Cancel() + { + _command.Cancel(); + } + + public override void Prepare() + { + _command.Prepare(); + } + + public override int ExecuteNonQuery() + { + return _command.ExecuteNonQuery(); + } + + public override object ExecuteScalar() + { + return _command.ExecuteScalar(); + } + + protected override DbParameter CreateDbParameter() + { + throw new NotSupportedException(); + } + + protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior) { - private readonly IDbCommand _command; - - public DbCommandStub(IDbCommand command) - { - _command = command; - } - - public override string CommandText - { - get => _command.CommandText; - set => _command.CommandText = value; - } - - public override int CommandTimeout - { - get => _command.CommandTimeout; - set => _command.CommandTimeout = value; - } - - public override CommandType CommandType - { - get => _command.CommandType; - set => _command.CommandType = value; - } - - public override UpdateRowSource UpdatedRowSource - { - get => _command.UpdatedRowSource; - set => _command.UpdatedRowSource = value; - } - - public override bool DesignTimeVisible - { - get => throw new NotSupportedException(); - set => throw new NotSupportedException(); - } - - protected override DbConnection DbConnection - { - get => throw new NotSupportedException(); - set => throw new NotSupportedException(); - } - - protected override DbParameterCollection DbParameterCollection => throw new NotSupportedException(); - - protected override DbTransaction DbTransaction - { - get => throw new NotSupportedException(); - set => throw new NotSupportedException(); - } - - public override void Cancel() - { - _command.Cancel(); - } - - public override void Prepare() - { - _command.Prepare(); - } - - public override int ExecuteNonQuery() - { - return _command.ExecuteNonQuery(); - } - - public override object ExecuteScalar() - { - return _command.ExecuteScalar(); - } - - protected override DbParameter CreateDbParameter() - { - throw new NotSupportedException(); - } - - protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior) - { - throw new NotSupportedException(); - } + throw new NotSupportedException(); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/DefaultEntryPointTest.cs b/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/DefaultEntryPointTest.cs index 0eea9a4f..45177d1d 100644 --- a/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/DefaultEntryPointTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/DefaultEntryPointTest.cs @@ -4,86 +4,85 @@ using Moq; using NUnit.Framework; -namespace SqlDatabase.Scripts.AssemblyInternal +namespace SqlDatabase.Scripts.AssemblyInternal; + +[TestFixture] +public class DefaultEntryPointTest { - [TestFixture] - public class DefaultEntryPointTest + private DefaultEntryPoint _sut; + private IList _logOutput; + private Mock _command; + private Mock> _variables; + + [SetUp] + public void BeforeEachTest() { - private DefaultEntryPoint _sut; - private IList _logOutput; - private Mock _command; - private Mock> _variables; + _command = new Mock(MockBehavior.Strict); + _variables = new Mock>(MockBehavior.Strict); - [SetUp] - public void BeforeEachTest() - { - _command = new Mock(MockBehavior.Strict); - _variables = new Mock>(MockBehavior.Strict); - - _logOutput = new List(); - - var log = new Mock(MockBehavior.Strict); - log - .Setup(l => l.Info(It.IsAny())) - .Callback(m => - { - Console.WriteLine("Info: {0}", m); - _logOutput.Add(m); - }); - log - .Setup(l => l.Error(It.IsAny())) - .Callback(m => - { - Console.WriteLine("Error: {0}", m); - _logOutput.Add(m); - }); - - _sut = new DefaultEntryPoint { Log = log.Object }; - } - - [Test] - public void Execute() - { - var executeCounter = 0; + _logOutput = new List(); - _sut.Method = (c, v) => + var log = new Mock(MockBehavior.Strict); + log + .Setup(l => l.Info(It.IsAny())) + .Callback(m => { - Assert.AreEqual(_command.Object, c); - Assert.AreEqual(_variables.Object, v); - - executeCounter++; - }; + Console.WriteLine("Info: {0}", m); + _logOutput.Add(m); + }); + log + .Setup(l => l.Error(It.IsAny())) + .Callback(m => + { + Console.WriteLine("Error: {0}", m); + _logOutput.Add(m); + }); - Assert.IsTrue(_sut.Execute(_command.Object, _variables.Object)); + _sut = new DefaultEntryPoint { Log = log.Object }; + } - Assert.AreEqual(1, executeCounter); - Assert.AreEqual(0, _logOutput.Count); - } + [Test] + public void Execute() + { + var executeCounter = 0; - [Test] - public void DisposeInstanceOnExecute() + _sut.Method = (c, v) => { - var instance = new Mock(MockBehavior.Strict); - instance.Setup(i => i.Dispose()); + Assert.AreEqual(_command.Object, c); + Assert.AreEqual(_variables.Object, v); - _sut.ScriptInstance = instance.Object; - _sut.Method = (c, v) => - { - }; + executeCounter++; + }; - Assert.IsTrue(_sut.Execute(_command.Object, _variables.Object)); + Assert.IsTrue(_sut.Execute(_command.Object, _variables.Object)); - instance.VerifyAll(); - } + Assert.AreEqual(1, executeCounter); + Assert.AreEqual(0, _logOutput.Count); + } + + [Test] + public void DisposeInstanceOnExecute() + { + var instance = new Mock(MockBehavior.Strict); + instance.Setup(i => i.Dispose()); - [Test] - public void ExceptionOnExecute() + _sut.ScriptInstance = instance.Object; + _sut.Method = (c, v) => { - _sut.Method = (c, v) => throw new InvalidOperationException(); + }; + + Assert.IsTrue(_sut.Execute(_command.Object, _variables.Object)); + + instance.VerifyAll(); + } + + [Test] + public void ExceptionOnExecute() + { + _sut.Method = (c, v) => throw new InvalidOperationException(); - Assert.IsFalse(_sut.Execute(_command.Object, _variables.Object)); + Assert.IsFalse(_sut.Execute(_command.Object, _variables.Object)); - Assert.Greater(_logOutput.Count, 0); - } + Assert.Greater(_logOutput.Count, 0); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/EntryPointResolverTest.Stubs.cs b/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/EntryPointResolverTest.Stubs.cs index 9bd5f31d..eb67a118 100644 --- a/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/EntryPointResolverTest.Stubs.cs +++ b/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/EntryPointResolverTest.Stubs.cs @@ -3,45 +3,44 @@ using System.Data; using System.Data.SqlClient; -namespace SqlDatabase.Scripts.AssemblyInternal +namespace SqlDatabase.Scripts.AssemblyInternal; + +public partial class EntryPointResolverTest { - public partial class EntryPointResolverTest + public sealed class ExampleSqlDatabaseScript { - public sealed class ExampleSqlDatabaseScript + public void Execute(IDbCommand command, IReadOnlyDictionary variables) { - public void Execute(IDbCommand command, IReadOnlyDictionary variables) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } + } - public sealed class DatabaseScriptWithInvalidConstructor + public sealed class DatabaseScriptWithInvalidConstructor + { + public DatabaseScriptWithInvalidConstructor() { - public DatabaseScriptWithInvalidConstructor() - { - throw new NotSupportedException(); - } + throw new NotSupportedException(); + } - public void Execute(IDbCommand command, IReadOnlyDictionary variables) - { - throw new NotImplementedException(); - } + public void Execute(IDbCommand command, IReadOnlyDictionary variables) + { + throw new NotImplementedException(); } + } - public sealed class DatabaseScriptWithOneParameter + public sealed class DatabaseScriptWithOneParameter + { + public void ExecuteCommand(IDbCommand command) { - public void ExecuteCommand(IDbCommand command) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } + } - public sealed class DatabaseScriptWithConnection + public sealed class DatabaseScriptWithConnection + { + public void Run(SqlConnection connection) { - public void Run(SqlConnection connection) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/EntryPointResolverTest.cs b/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/EntryPointResolverTest.cs index f068cc5d..e5764739 100644 --- a/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/EntryPointResolverTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/EntryPointResolverTest.cs @@ -4,98 +4,97 @@ using NUnit.Framework; using Shouldly; -namespace SqlDatabase.Scripts.AssemblyInternal +namespace SqlDatabase.Scripts.AssemblyInternal; + +[TestFixture] +public partial class EntryPointResolverTest { - [TestFixture] - public partial class EntryPointResolverTest + private EntryPointResolver _sut; + private IList _logErrorOutput; + + [SetUp] + public void BeforeEachTest() + { + _logErrorOutput = new List(); + + var log = new Mock(MockBehavior.Strict); + log + .Setup(l => l.Info(It.IsAny())) + .Callback(m => + { + Console.WriteLine("Info: {0}", m); + }); + log + .Setup(l => l.Error(It.IsAny())) + .Callback(m => + { + Console.WriteLine("Error: {0}", m); + _logErrorOutput.Add(m); + }); + + _sut = new EntryPointResolver { Log = log.Object }; + } + + [Test] + [TestCase(nameof(ExampleSqlDatabaseScript))] + [TestCase(nameof(EntryPointResolverTest) + "+" + nameof(ExampleSqlDatabaseScript))] + [TestCase("AssemblyInternal." + nameof(EntryPointResolverTest) + "+" + nameof(ExampleSqlDatabaseScript))] + [TestCase("Scripts.AssemblyInternal." + nameof(EntryPointResolverTest) + "+" + nameof(ExampleSqlDatabaseScript))] + [TestCase("SqlDatabase.Scripts.AssemblyInternal." + nameof(EntryPointResolverTest) + "+" + nameof(ExampleSqlDatabaseScript))] + public void ResolveFromExample(string className) + { + _sut.ExecutorClassName = className; + _sut.ExecutorMethodName = nameof(ExampleSqlDatabaseScript.Execute); + + var actual = _sut.Resolve(GetType().Assembly); + CollectionAssert.IsEmpty(_logErrorOutput); + Assert.IsInstanceOf(actual); + + var entryPoint = (DefaultEntryPoint)actual; + entryPoint.Log.ShouldNotBeNull(); + entryPoint.ScriptInstance.ShouldBeOfType(); + entryPoint.Method.Method.Name.ShouldBe(nameof(ExampleSqlDatabaseScript.Execute)); + } + + [Test] + public void FailToCreateInstance() { - private EntryPointResolver _sut; - private IList _logErrorOutput; - - [SetUp] - public void BeforeEachTest() - { - _logErrorOutput = new List(); - - var log = new Mock(MockBehavior.Strict); - log - .Setup(l => l.Info(It.IsAny())) - .Callback(m => - { - Console.WriteLine("Info: {0}", m); - }); - log - .Setup(l => l.Error(It.IsAny())) - .Callback(m => - { - Console.WriteLine("Error: {0}", m); - _logErrorOutput.Add(m); - }); - - _sut = new EntryPointResolver { Log = log.Object }; - } - - [Test] - [TestCase(nameof(ExampleSqlDatabaseScript))] - [TestCase(nameof(EntryPointResolverTest) + "+" + nameof(ExampleSqlDatabaseScript))] - [TestCase("AssemblyInternal." + nameof(EntryPointResolverTest) + "+" + nameof(ExampleSqlDatabaseScript))] - [TestCase("Scripts.AssemblyInternal." + nameof(EntryPointResolverTest) + "+" + nameof(ExampleSqlDatabaseScript))] - [TestCase("SqlDatabase.Scripts.AssemblyInternal." + nameof(EntryPointResolverTest) + "+" + nameof(ExampleSqlDatabaseScript))] - public void ResolveFromExample(string className) - { - _sut.ExecutorClassName = className; - _sut.ExecutorMethodName = nameof(ExampleSqlDatabaseScript.Execute); - - var actual = _sut.Resolve(GetType().Assembly); - CollectionAssert.IsEmpty(_logErrorOutput); - Assert.IsInstanceOf(actual); - - var entryPoint = (DefaultEntryPoint)actual; - entryPoint.Log.ShouldNotBeNull(); - entryPoint.ScriptInstance.ShouldBeOfType(); - entryPoint.Method.Method.Name.ShouldBe(nameof(ExampleSqlDatabaseScript.Execute)); - } - - [Test] - public void FailToCreateInstance() - { - _sut.ExecutorClassName = nameof(DatabaseScriptWithInvalidConstructor); - _sut.ExecutorMethodName = nameof(DatabaseScriptWithInvalidConstructor.Execute); - - Assert.IsNull(_sut.Resolve(GetType().Assembly)); - CollectionAssert.IsNotEmpty(_logErrorOutput); - } - - [Test] - public void ResolveExecuteWithCommandOnly() - { - _sut.ExecutorClassName = nameof(DatabaseScriptWithOneParameter); - _sut.ExecutorMethodName = nameof(DatabaseScriptWithOneParameter.ExecuteCommand); - - var actual = _sut.Resolve(GetType().Assembly); - CollectionAssert.IsEmpty(_logErrorOutput); - Assert.IsInstanceOf(actual); - - var entryPoint = (DefaultEntryPoint)actual; - Assert.IsNotNull(entryPoint.Log); - Assert.IsInstanceOf(entryPoint.ScriptInstance); - Assert.IsNotNull(entryPoint.Method); - } - - [Test] - public void ResolveExecuteWithConnection() - { - _sut.ExecutorClassName = nameof(DatabaseScriptWithConnection); - _sut.ExecutorMethodName = nameof(DatabaseScriptWithConnection.Run); - - var actual = _sut.Resolve(GetType().Assembly); - CollectionAssert.IsEmpty(_logErrorOutput); - Assert.IsInstanceOf(actual); - - var entryPoint = (DefaultEntryPoint)actual; - Assert.IsNotNull(entryPoint.Log); - Assert.IsInstanceOf(entryPoint.ScriptInstance); - Assert.IsNotNull(entryPoint.Method); - } + _sut.ExecutorClassName = nameof(DatabaseScriptWithInvalidConstructor); + _sut.ExecutorMethodName = nameof(DatabaseScriptWithInvalidConstructor.Execute); + + Assert.IsNull(_sut.Resolve(GetType().Assembly)); + CollectionAssert.IsNotEmpty(_logErrorOutput); + } + + [Test] + public void ResolveExecuteWithCommandOnly() + { + _sut.ExecutorClassName = nameof(DatabaseScriptWithOneParameter); + _sut.ExecutorMethodName = nameof(DatabaseScriptWithOneParameter.ExecuteCommand); + + var actual = _sut.Resolve(GetType().Assembly); + CollectionAssert.IsEmpty(_logErrorOutput); + Assert.IsInstanceOf(actual); + + var entryPoint = (DefaultEntryPoint)actual; + Assert.IsNotNull(entryPoint.Log); + Assert.IsInstanceOf(entryPoint.ScriptInstance); + Assert.IsNotNull(entryPoint.Method); + } + + [Test] + public void ResolveExecuteWithConnection() + { + _sut.ExecutorClassName = nameof(DatabaseScriptWithConnection); + _sut.ExecutorMethodName = nameof(DatabaseScriptWithConnection.Run); + + var actual = _sut.Resolve(GetType().Assembly); + CollectionAssert.IsEmpty(_logErrorOutput); + Assert.IsInstanceOf(actual); + + var entryPoint = (DefaultEntryPoint)actual; + Assert.IsNotNull(entryPoint.Log); + Assert.IsInstanceOf(entryPoint.ScriptInstance); + Assert.IsNotNull(entryPoint.Method); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/ExecuteMethodResolverCommandDictionaryTest.cs b/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/ExecuteMethodResolverCommandDictionaryTest.cs index a02a45b3..e772b882 100644 --- a/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/ExecuteMethodResolverCommandDictionaryTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/ExecuteMethodResolverCommandDictionaryTest.cs @@ -4,49 +4,48 @@ using Moq; using NUnit.Framework; -namespace SqlDatabase.Scripts.AssemblyInternal +namespace SqlDatabase.Scripts.AssemblyInternal; + +[TestFixture] +public class ExecuteMethodResolverCommandDictionaryTest { - [TestFixture] - public class ExecuteMethodResolverCommandDictionaryTest + private ExecuteMethodResolverCommandDictionary _sut; + private IDbCommand _executeCommand; + private IReadOnlyDictionary _executeVariables; + + [SetUp] + public void BeforeEachTest() + { + _sut = new ExecuteMethodResolverCommandDictionary(); + } + + [Test] + public void IsMatch() + { + var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); + Assert.IsTrue(_sut.IsMatch(method)); + } + + [Test] + public void CreateDelegate() + { + var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); + var actual = _sut.CreateDelegate(this, method); + Assert.IsNotNull(actual); + + var command = new Mock(MockBehavior.Strict); + var variables = new Mock>(MockBehavior.Strict); + + actual(command.Object, variables.Object); + + Assert.AreEqual(_executeCommand, command.Object); + Assert.AreEqual(_executeVariables, variables.Object); + } + + private void Execute(IDbCommand command, IReadOnlyDictionary variables) { - private ExecuteMethodResolverCommandDictionary _sut; - private IDbCommand _executeCommand; - private IReadOnlyDictionary _executeVariables; - - [SetUp] - public void BeforeEachTest() - { - _sut = new ExecuteMethodResolverCommandDictionary(); - } - - [Test] - public void IsMatch() - { - var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); - Assert.IsTrue(_sut.IsMatch(method)); - } - - [Test] - public void CreateDelegate() - { - var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); - var actual = _sut.CreateDelegate(this, method); - Assert.IsNotNull(actual); - - var command = new Mock(MockBehavior.Strict); - var variables = new Mock>(MockBehavior.Strict); - - actual(command.Object, variables.Object); - - Assert.AreEqual(_executeCommand, command.Object); - Assert.AreEqual(_executeVariables, variables.Object); - } - - private void Execute(IDbCommand command, IReadOnlyDictionary variables) - { - Assert.IsNull(_executeCommand); - _executeCommand = command; - _executeVariables = variables; - } + Assert.IsNull(_executeCommand); + _executeCommand = command; + _executeVariables = variables; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/ExecuteMethodResolverCommandTest.cs b/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/ExecuteMethodResolverCommandTest.cs index ab55f821..596c9f4e 100644 --- a/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/ExecuteMethodResolverCommandTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/ExecuteMethodResolverCommandTest.cs @@ -3,43 +3,42 @@ using Moq; using NUnit.Framework; -namespace SqlDatabase.Scripts.AssemblyInternal +namespace SqlDatabase.Scripts.AssemblyInternal; + +[TestFixture] +public class ExecuteMethodResolverCommandTest { - [TestFixture] - public class ExecuteMethodResolverCommandTest - { - private ExecuteMethodResolverCommand _sut; - private IDbCommand _executeCommand; + private ExecuteMethodResolverCommand _sut; + private IDbCommand _executeCommand; - [SetUp] - public void BeforeEachTest() - { - _sut = new ExecuteMethodResolverCommand(); - } + [SetUp] + public void BeforeEachTest() + { + _sut = new ExecuteMethodResolverCommand(); + } - [Test] - public void IsMatch() - { - var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); - Assert.IsTrue(_sut.IsMatch(method)); - } + [Test] + public void IsMatch() + { + var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); + Assert.IsTrue(_sut.IsMatch(method)); + } - [Test] - public void CreateDelegate() - { - var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); - var actual = _sut.CreateDelegate(this, method); - Assert.IsNotNull(actual); + [Test] + public void CreateDelegate() + { + var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); + var actual = _sut.CreateDelegate(this, method); + Assert.IsNotNull(actual); - var command = new Mock(MockBehavior.Strict); - actual(command.Object, null); - Assert.AreEqual(_executeCommand, command.Object); - } + var command = new Mock(MockBehavior.Strict); + actual(command.Object, null); + Assert.AreEqual(_executeCommand, command.Object); + } - private void Execute(IDbCommand command) - { - Assert.IsNull(_executeCommand); - _executeCommand = command; - } + private void Execute(IDbCommand command) + { + Assert.IsNull(_executeCommand); + _executeCommand = command; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/ExecuteMethodResolverDbConnectionTest.cs b/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/ExecuteMethodResolverDbConnectionTest.cs index 8775e601..bce6318b 100644 --- a/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/ExecuteMethodResolverDbConnectionTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/ExecuteMethodResolverDbConnectionTest.cs @@ -4,49 +4,48 @@ using Moq; using NUnit.Framework; -namespace SqlDatabase.Scripts.AssemblyInternal +namespace SqlDatabase.Scripts.AssemblyInternal; + +[TestFixture] +public class ExecuteMethodResolverDbConnectionTest { - [TestFixture] - public class ExecuteMethodResolverDbConnectionTest + private ExecuteMethodResolverDbConnection _sut; + private IDbConnection _executeConnection; + + [SetUp] + public void BeforeEachTest() + { + _sut = new ExecuteMethodResolverDbConnection(); + } + + [Test] + public void IsMatch() + { + var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); + Assert.IsTrue(_sut.IsMatch(method)); + } + + [Test] + public void CreateDelegate() + { + var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); + var actual = _sut.CreateDelegate(this, method); + Assert.IsNotNull(actual); + + var connection = new Mock(MockBehavior.Strict); + + var command = new Mock(MockBehavior.Strict); + command + .SetupGet(c => c.Connection) + .Returns(connection.Object); + + actual(command.Object, null); + Assert.AreEqual(_executeConnection, connection.Object); + } + + private void Execute(IDbConnection connection) { - private ExecuteMethodResolverDbConnection _sut; - private IDbConnection _executeConnection; - - [SetUp] - public void BeforeEachTest() - { - _sut = new ExecuteMethodResolverDbConnection(); - } - - [Test] - public void IsMatch() - { - var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); - Assert.IsTrue(_sut.IsMatch(method)); - } - - [Test] - public void CreateDelegate() - { - var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); - var actual = _sut.CreateDelegate(this, method); - Assert.IsNotNull(actual); - - var connection = new Mock(MockBehavior.Strict); - - var command = new Mock(MockBehavior.Strict); - command - .SetupGet(c => c.Connection) - .Returns(connection.Object); - - actual(command.Object, null); - Assert.AreEqual(_executeConnection, connection.Object); - } - - private void Execute(IDbConnection connection) - { - Assert.IsNull(_executeConnection); - _executeConnection = connection; - } + Assert.IsNull(_executeConnection); + _executeConnection = connection; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/ExecuteMethodResolverDictionaryCommandTest.cs b/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/ExecuteMethodResolverDictionaryCommandTest.cs index f50633dc..c5a19fe7 100644 --- a/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/ExecuteMethodResolverDictionaryCommandTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/ExecuteMethodResolverDictionaryCommandTest.cs @@ -4,49 +4,48 @@ using Moq; using NUnit.Framework; -namespace SqlDatabase.Scripts.AssemblyInternal +namespace SqlDatabase.Scripts.AssemblyInternal; + +[TestFixture] +public class ExecuteMethodResolverDictionaryCommandTest { - [TestFixture] - public class ExecuteMethodResolverDictionaryCommandTest + private ExecuteMethodResolverDictionaryCommand _sut; + private IDbCommand _executeCommand; + private IReadOnlyDictionary _executeVariables; + + [SetUp] + public void BeforeEachTest() + { + _sut = new ExecuteMethodResolverDictionaryCommand(); + } + + [Test] + public void IsMatch() + { + var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); + Assert.IsTrue(_sut.IsMatch(method)); + } + + [Test] + public void CreateDelegate() + { + var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); + var actual = _sut.CreateDelegate(this, method); + Assert.IsNotNull(actual); + + var command = new Mock(MockBehavior.Strict); + var variables = new Mock>(MockBehavior.Strict); + + actual(command.Object, variables.Object); + + Assert.AreEqual(_executeCommand, command.Object); + Assert.AreEqual(_executeVariables, variables.Object); + } + + private void Execute(IReadOnlyDictionary variables, IDbCommand command) { - private ExecuteMethodResolverDictionaryCommand _sut; - private IDbCommand _executeCommand; - private IReadOnlyDictionary _executeVariables; - - [SetUp] - public void BeforeEachTest() - { - _sut = new ExecuteMethodResolverDictionaryCommand(); - } - - [Test] - public void IsMatch() - { - var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); - Assert.IsTrue(_sut.IsMatch(method)); - } - - [Test] - public void CreateDelegate() - { - var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); - var actual = _sut.CreateDelegate(this, method); - Assert.IsNotNull(actual); - - var command = new Mock(MockBehavior.Strict); - var variables = new Mock>(MockBehavior.Strict); - - actual(command.Object, variables.Object); - - Assert.AreEqual(_executeCommand, command.Object); - Assert.AreEqual(_executeVariables, variables.Object); - } - - private void Execute(IReadOnlyDictionary variables, IDbCommand command) - { - Assert.IsNull(_executeCommand); - _executeCommand = command; - _executeVariables = variables; - } + Assert.IsNull(_executeCommand); + _executeCommand = command; + _executeVariables = variables; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/ExecuteMethodResolverSqlConnectionTest.cs b/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/ExecuteMethodResolverSqlConnectionTest.cs index 93da2083..ffb4d9f4 100644 --- a/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/ExecuteMethodResolverSqlConnectionTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/AssemblyInternal/ExecuteMethodResolverSqlConnectionTest.cs @@ -4,49 +4,48 @@ using Moq; using NUnit.Framework; -namespace SqlDatabase.Scripts.AssemblyInternal +namespace SqlDatabase.Scripts.AssemblyInternal; + +[TestFixture] +public class ExecuteMethodResolverSqlConnectionTest { - [TestFixture] - public class ExecuteMethodResolverSqlConnectionTest + private ExecuteMethodResolverSqlConnection _sut; + private SqlConnection _executeConnection; + + [SetUp] + public void BeforeEachTest() + { + _sut = new ExecuteMethodResolverSqlConnection(); + } + + [Test] + public void IsMatch() + { + var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); + Assert.IsTrue(_sut.IsMatch(method)); + } + + [Test] + public void CreateDelegate() + { + var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); + var actual = _sut.CreateDelegate(this, method); + Assert.IsNotNull(actual); + + var connection = new SqlConnection(); + + var command = new Mock(MockBehavior.Strict); + command + .SetupGet(c => c.Connection) + .Returns(connection); + + actual(command.Object, null); + Assert.AreEqual(_executeConnection, connection); + } + + private void Execute(SqlConnection connection) { - private ExecuteMethodResolverSqlConnection _sut; - private SqlConnection _executeConnection; - - [SetUp] - public void BeforeEachTest() - { - _sut = new ExecuteMethodResolverSqlConnection(); - } - - [Test] - public void IsMatch() - { - var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); - Assert.IsTrue(_sut.IsMatch(method)); - } - - [Test] - public void CreateDelegate() - { - var method = GetType().GetMethod(nameof(Execute), BindingFlags.Instance | BindingFlags.NonPublic); - var actual = _sut.CreateDelegate(this, method); - Assert.IsNotNull(actual); - - var connection = new SqlConnection(); - - var command = new Mock(MockBehavior.Strict); - command - .SetupGet(c => c.Connection) - .Returns(connection); - - actual(command.Object, null); - Assert.AreEqual(_executeConnection, connection); - } - - private void Execute(SqlConnection connection) - { - Assert.IsNull(_executeConnection); - _executeConnection = connection; - } + Assert.IsNull(_executeConnection); + _executeConnection = connection; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/AssemblyScriptTest.cs b/Sources/SqlDatabase.Test/Scripts/AssemblyScriptTest.cs index bc1b2f11..84714044 100644 --- a/Sources/SqlDatabase.Test/Scripts/AssemblyScriptTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/AssemblyScriptTest.cs @@ -9,158 +9,157 @@ using SqlDatabase.Configuration; using SqlDatabase.Scripts.AssemblyInternal; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +[TestFixture] +public class AssemblyScriptTest { - [TestFixture] - public class AssemblyScriptTest - { - private AssemblyScript _sut; - private Variables _variables; - private Mock _log; - private Mock _command; + private AssemblyScript _sut; + private Variables _variables; + private Mock _log; + private Mock _command; - private IList _logOutput; - private IList _executedScripts; + private IList _logOutput; + private IList _executedScripts; - [SetUp] - public void BeforeEachTest() - { - _variables = new Variables(); - - _logOutput = new List(); - _log = new Mock(MockBehavior.Strict); - _log - .Setup(l => l.Info(It.IsAny())) - .Callback(_logOutput.Add); - - _executedScripts = new List(); - _command = new Mock(MockBehavior.Strict); - _command.SetupProperty(c => c.CommandText); - _command - .Setup(c => c.ExecuteNonQuery()) - .Callback(() => _executedScripts.Add(_command.Object.CommandText)) - .Returns(0); - - _sut = new AssemblyScript(); - _sut.Configuration = new AssemblyScriptConfiguration(); - } + [SetUp] + public void BeforeEachTest() + { + _variables = new Variables(); + + _logOutput = new List(); + _log = new Mock(MockBehavior.Strict); + _log + .Setup(l => l.Info(It.IsAny())) + .Callback(_logOutput.Add); + + _executedScripts = new List(); + _command = new Mock(MockBehavior.Strict); + _command.SetupProperty(c => c.CommandText); + _command + .Setup(c => c.ExecuteNonQuery()) + .Callback(() => _executedScripts.Add(_command.Object.CommandText)) + .Returns(0); + + _sut = new AssemblyScript(); + _sut.Configuration = new AssemblyScriptConfiguration(); + } - [Test] - public void ExecuteExampleMsSql() - { - _sut.Configuration.ClassName = "MsSql.SqlDatabaseScript"; + [Test] + public void ExecuteExampleMsSql() + { + _sut.Configuration.ClassName = "MsSql.SqlDatabaseScript"; - _variables.DatabaseName = "dbName"; - _variables.CurrentVersion = "1.0"; - _variables.TargetVersion = "2.0"; + _variables.DatabaseName = "dbName"; + _variables.CurrentVersion = "1.0"; + _variables.TargetVersion = "2.0"; - _sut.DisplayName = "2.1_2.2.dll"; - _sut.ReadAssemblyContent = () => File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "2.1_2.2.dll")); + _sut.DisplayName = "2.1_2.2.dll"; + _sut.ReadAssemblyContent = () => File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "2.1_2.2.dll")); #if !NET452 - using (new ConsoleListener(_log.Object)) + using (new ConsoleListener(_log.Object)) #endif - { - _sut.Execute(new DbCommandStub(_command.Object), _variables, _log.Object); - } + { + _sut.Execute(new DbCommandStub(_command.Object), _variables, _log.Object); + } - _logOutput.ShouldContain("start execution"); + _logOutput.ShouldContain("start execution"); - _executedScripts.ShouldContain("print 'upgrade database dbName from version 1.0 to 2.0'"); + _executedScripts.ShouldContain("print 'upgrade database dbName from version 1.0 to 2.0'"); - _executedScripts.ShouldContain("create table dbo.DemoTable (Id INT)"); - _executedScripts.ShouldContain("print 'drop table DemoTable'"); - _executedScripts.ShouldContain("drop table dbo.DemoTable"); + _executedScripts.ShouldContain("create table dbo.DemoTable (Id INT)"); + _executedScripts.ShouldContain("print 'drop table DemoTable'"); + _executedScripts.ShouldContain("drop table dbo.DemoTable"); - _logOutput.ShouldContain("finish execution"); - } + _logOutput.ShouldContain("finish execution"); + } - [Test] - public void ExecuteExamplePgSql() - { - _sut.Configuration.ClassName = "PgSql.SqlDatabaseScript"; + [Test] + public void ExecuteExamplePgSql() + { + _sut.Configuration.ClassName = "PgSql.SqlDatabaseScript"; - _variables.DatabaseName = "dbName"; - _variables.CurrentVersion = "1.0"; - _variables.TargetVersion = "2.0"; + _variables.DatabaseName = "dbName"; + _variables.CurrentVersion = "1.0"; + _variables.TargetVersion = "2.0"; - _sut.DisplayName = "2.1_2.2.dll"; - _sut.ReadAssemblyContent = () => File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "2.1_2.2.dll")); + _sut.DisplayName = "2.1_2.2.dll"; + _sut.ReadAssemblyContent = () => File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "2.1_2.2.dll")); #if !NET452 - using (new ConsoleListener(_log.Object)) + using (new ConsoleListener(_log.Object)) #endif - { - _sut.Execute(new DbCommandStub(_command.Object), _variables, _log.Object); - } + { + _sut.Execute(new DbCommandStub(_command.Object), _variables, _log.Object); + } - _logOutput.ShouldContain("start execution"); + _logOutput.ShouldContain("start execution"); - _executedScripts.Count.ShouldBe(4); - _executedScripts[0].ShouldContain("upgrade database dbName from version 1.0 to 2.0"); - _executedScripts[1].ShouldContain("create table public.demo_table (id integer)"); - _executedScripts[2].ShouldContain("'drop table demo_table'"); - _executedScripts[3].ShouldContain("drop table public.demo_table"); + _executedScripts.Count.ShouldBe(4); + _executedScripts[0].ShouldContain("upgrade database dbName from version 1.0 to 2.0"); + _executedScripts[1].ShouldContain("create table public.demo_table (id integer)"); + _executedScripts[2].ShouldContain("'drop table demo_table'"); + _executedScripts[3].ShouldContain("drop table public.demo_table"); - _logOutput.ShouldContain("finish execution"); - } + _logOutput.ShouldContain("finish execution"); + } - [Test] - public void FailToResolveExecutor() - { - var domain = new Mock(MockBehavior.Strict); - domain - .Setup(d => d.ResolveScriptExecutor(_sut.Configuration.ClassName, _sut.Configuration.MethodName)) - .Returns(false); + [Test] + public void FailToResolveExecutor() + { + var domain = new Mock(MockBehavior.Strict); + domain + .Setup(d => d.ResolveScriptExecutor(_sut.Configuration.ClassName, _sut.Configuration.MethodName)) + .Returns(false); - Assert.Throws(() => _sut.ResolveScriptExecutor(domain.Object)); - } + Assert.Throws(() => _sut.ResolveScriptExecutor(domain.Object)); + } - [Test] - public void FailOnExecute() - { - var domain = new Mock(MockBehavior.Strict); - domain - .Setup(d => d.Execute(_command.Object, _variables)) - .Returns(false); + [Test] + public void FailOnExecute() + { + var domain = new Mock(MockBehavior.Strict); + domain + .Setup(d => d.Execute(_command.Object, _variables)) + .Returns(false); - Assert.Throws(() => _sut.Execute(domain.Object, _command.Object, _variables)); - } + Assert.Throws(() => _sut.Execute(domain.Object, _command.Object, _variables)); + } - [Test] - public void ExecuteWhatIf() - { - var domain = new Mock(MockBehavior.Strict); + [Test] + public void ExecuteWhatIf() + { + var domain = new Mock(MockBehavior.Strict); - _sut.Execute(domain.Object, null, _variables); - } + _sut.Execute(domain.Object, null, _variables); + } - [Test] - public void GetDependencies() - { - var description = Encoding.Default.GetBytes(@" + [Test] + public void GetDependencies() + { + var description = Encoding.Default.GetBytes(@" -- module dependency: a 1.0 -- module dependency: b 1.0"); - _sut.ReadDescriptionContent = () => new MemoryStream(description); + _sut.ReadDescriptionContent = () => new MemoryStream(description); - var actual = _sut.GetDependencies(); - - actual.ShouldBe(new[] - { - new ScriptDependency("a", new Version("1.0")), - new ScriptDependency("b", new Version("1.0")) - }); - } + var actual = _sut.GetDependencies(); - [Test] - public void GetDependenciesNoDescription() + actual.ShouldBe(new[] { - _sut.ReadDescriptionContent = () => null; + new ScriptDependency("a", new Version("1.0")), + new ScriptDependency("b", new Version("1.0")) + }); + } + + [Test] + public void GetDependenciesNoDescription() + { + _sut.ReadDescriptionContent = () => null; - var actual = _sut.GetDependencies(); + var actual = _sut.GetDependencies(); - actual.ShouldBeEmpty(); - } + actual.ShouldBeEmpty(); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/CreateScriptSequenceTest.cs b/Sources/SqlDatabase.Test/Scripts/CreateScriptSequenceTest.cs index e42ba7a1..c280e843 100644 --- a/Sources/SqlDatabase.Test/Scripts/CreateScriptSequenceTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/CreateScriptSequenceTest.cs @@ -5,104 +5,103 @@ using SqlDatabase.IO; using SqlDatabase.TestApi; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +[TestFixture] +public class CreateScriptSequenceTest { - [TestFixture] - public class CreateScriptSequenceTest + private CreateScriptSequence _sut; + + [SetUp] + public void BeforeEachTest() { - private CreateScriptSequence _sut; + var scriptFactory = new Mock(MockBehavior.Strict); + scriptFactory + .Setup(f => f.IsSupported(It.IsAny())) + .Returns(s => ".sql".Equals(Path.GetExtension(s)) || ".exe".Equals(Path.GetExtension(s))); - [SetUp] - public void BeforeEachTest() - { - var scriptFactory = new Mock(MockBehavior.Strict); - scriptFactory - .Setup(f => f.IsSupported(It.IsAny())) - .Returns(s => ".sql".Equals(Path.GetExtension(s)) || ".exe".Equals(Path.GetExtension(s))); - - scriptFactory - .Setup(s => s.FromFile(It.IsNotNull())) - .Returns(file => - { - var script = new Mock(MockBehavior.Strict); - script.SetupProperty(s => s.DisplayName, file.Name); - - return script.Object; - }); - - _sut = new CreateScriptSequence + scriptFactory + .Setup(s => s.FromFile(It.IsNotNull())) + .Returns(file => { - ScriptFactory = scriptFactory.Object - }; - } + var script = new Mock(MockBehavior.Strict); + script.SetupProperty(s => s.DisplayName, file.Name); - [Test] - public void BuildSequenceFromOneFolder() + return script.Object; + }); + + _sut = new CreateScriptSequence { - var folderX = new[] - { - FileFactory.File("a.sql"), - FileFactory.File("x.sql"), - FileFactory.File("ignore") - }; + ScriptFactory = scriptFactory.Object + }; + } + + [Test] + public void BuildSequenceFromOneFolder() + { + var folderX = new[] + { + FileFactory.File("a.sql"), + FileFactory.File("x.sql"), + FileFactory.File("ignore") + }; + + var folderA = new[] + { + FileFactory.File("x.exe"), + FileFactory.File("a.exe"), + FileFactory.File("ignore") + }; - var folderA = new[] + var files = new[] + { + FileFactory.File("x.sql"), + FileFactory.File("a.exe"), + FileFactory.File("ignore") + }; + + var content = new IFileSystemInfo[] { - FileFactory.File("x.exe"), - FileFactory.File("a.exe"), - FileFactory.File("ignore") - }; + FileFactory.Folder("x", folderX), + FileFactory.Folder("a", folderA) + } + .Concat(files) + .ToArray(); + + _sut.Sources = new IFileSystemInfo[] { FileFactory.Folder("root", content) }; - var files = new[] + var actual = _sut.BuildSequence(); + + // sorted A-Z, first files then folders + CollectionAssert.AreEqual( + new[] { - FileFactory.File("x.sql"), - FileFactory.File("a.exe"), - FileFactory.File("ignore") - }; - - var content = new IFileSystemInfo[] - { - FileFactory.Folder("x", folderX), - FileFactory.Folder("a", folderA) - } - .Concat(files) - .ToArray(); - - _sut.Sources = new IFileSystemInfo[] { FileFactory.Folder("root", content) }; - - var actual = _sut.BuildSequence(); - - // sorted A-Z, first files then folders - CollectionAssert.AreEqual( - new[] - { - @"root\" + files[1].Name, - @"root\" + files[0].Name, - @"root\a\" + folderA[1].Name, - @"root\a\" + folderA[0].Name, - @"root\x\" + folderX[0].Name, - @"root\x\" + folderX[1].Name - }, - actual.Select(i => i.DisplayName).ToArray()); - } - - [Test] - public void BuildSequenceFromFolderAndFile() + @"root\" + files[1].Name, + @"root\" + files[0].Name, + @"root\a\" + folderA[1].Name, + @"root\a\" + folderA[0].Name, + @"root\x\" + folderX[0].Name, + @"root\x\" + folderX[1].Name + }, + actual.Select(i => i.DisplayName).ToArray()); + } + + [Test] + public void BuildSequenceFromFolderAndFile() + { + _sut.Sources = new IFileSystemInfo[] { - _sut.Sources = new IFileSystemInfo[] - { - FileFactory.Folder("root", FileFactory.File("20.sql"), FileFactory.File("10.sql")), - FileFactory.File("02.sql"), - FileFactory.File("01.sql"), - FileFactory.File("ignore") - }; - - var actual = _sut.BuildSequence(); - - // sorted A-Z, first files then folders - CollectionAssert.AreEqual( - new[] { @"root\10.sql", @"root\20.sql", "02.sql", "01.sql" }, - actual.Select(i => i.DisplayName).ToArray()); - } + FileFactory.Folder("root", FileFactory.File("20.sql"), FileFactory.File("10.sql")), + FileFactory.File("02.sql"), + FileFactory.File("01.sql"), + FileFactory.File("ignore") + }; + + var actual = _sut.BuildSequence(); + + // sorted A-Z, first files then folders + CollectionAssert.AreEqual( + new[] { @"root\10.sql", @"root\20.sql", "02.sql", "01.sql" }, + actual.Select(i => i.DisplayName).ToArray()); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/DatabaseAdapterFactoryTest.cs b/Sources/SqlDatabase.Test/Scripts/DatabaseAdapterFactoryTest.cs index 8c17b480..22161e2c 100644 --- a/Sources/SqlDatabase.Test/Scripts/DatabaseAdapterFactoryTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/DatabaseAdapterFactoryTest.cs @@ -9,56 +9,55 @@ using SqlDatabase.Scripts.PgSql; using SqlDatabase.TestApi; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +[TestFixture] +public class DatabaseAdapterFactoryTest { - [TestFixture] - public class DatabaseAdapterFactoryTest - { - private ILogger _log; - private AppConfiguration _configuration; + private ILogger _log; + private AppConfiguration _configuration; - [SetUp] - public void BeforeEachTest() - { - _log = new Mock(MockBehavior.Strict).Object; - _configuration = new AppConfiguration(); - } + [SetUp] + public void BeforeEachTest() + { + _log = new Mock(MockBehavior.Strict).Object; + _configuration = new AppConfiguration(); + } - [Test] - [TestCaseSource(nameof(GetCreateAdapterCases))] - public void CreateAdapter(string connectionString, string databaseName, Type expected) - { - var actual = DatabaseAdapterFactory.CreateAdapter(connectionString, _configuration, _log); + [Test] + [TestCaseSource(nameof(GetCreateAdapterCases))] + public void CreateAdapter(string connectionString, string databaseName, Type expected) + { + var actual = DatabaseAdapterFactory.CreateAdapter(connectionString, _configuration, _log); - actual.ShouldBeOfType(expected); - actual.DatabaseName.ShouldBe(databaseName); - } + actual.ShouldBeOfType(expected); + actual.DatabaseName.ShouldBe(databaseName); + } - private static IEnumerable GetCreateAdapterCases() + private static IEnumerable GetCreateAdapterCases() + { + yield return new TestCaseData( + MsSqlQuery.ConnectionString, + MsSqlQuery.DatabaseName, + typeof(MsSqlDatabaseAdapter)) { - yield return new TestCaseData( - MsSqlQuery.ConnectionString, - MsSqlQuery.DatabaseName, - typeof(MsSqlDatabaseAdapter)) - { - TestName = "MsSql" - }; + TestName = "MsSql" + }; - yield return new TestCaseData( - PgSqlQuery.ConnectionString, - PgSqlQuery.DatabaseName, - typeof(PgSqlDatabaseAdapter)) - { - TestName = "PgSql" - }; + yield return new TestCaseData( + PgSqlQuery.ConnectionString, + PgSqlQuery.DatabaseName, + typeof(PgSqlDatabaseAdapter)) + { + TestName = "PgSql" + }; - yield return new TestCaseData( - MySqlQuery.ConnectionString, - MySqlQuery.DatabaseName, - typeof(MySqlDatabaseAdapter)) - { - TestName = "MySql" - }; - } + yield return new TestCaseData( + MySqlQuery.ConnectionString, + MySqlQuery.DatabaseName, + typeof(MySqlDatabaseAdapter)) + { + TestName = "MySql" + }; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/DatabaseTest.cs b/Sources/SqlDatabase.Test/Scripts/DatabaseTest.cs index 5ba2e97d..a4472766 100644 --- a/Sources/SqlDatabase.Test/Scripts/DatabaseTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/DatabaseTest.cs @@ -8,473 +8,472 @@ using Shouldly; using SqlDatabase.Configuration; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +[TestFixture] +public class DatabaseTest { - [TestFixture] - public class DatabaseTest + private Database _sut; + private Mock _adapter; + private Mock _command; + private Mock _connection; + private Mock _transaction; + private IList _logOutput; + + [SetUp] + public void BeforeEachTest() { - private Database _sut; - private Mock _adapter; - private Mock _command; - private Mock _connection; - private Mock _transaction; - private IList _logOutput; - - [SetUp] - public void BeforeEachTest() + _logOutput = new List(); + var log = new Mock(MockBehavior.Strict); + log + .Setup(l => l.Error(It.IsAny())) + .Callback(m => + { + Console.WriteLine("Error: {0}", m); + _logOutput.Add(m); + }); + log + .Setup(l => l.Info(It.IsAny())) + .Callback(m => + { + Console.WriteLine("Info: {0}", m); + _logOutput.Add(m); + }); + + _transaction = new Mock(MockBehavior.Strict); + _transaction + .Setup(t => t.Dispose()); + _transaction + .Setup(t => t.Commit()); + + _command = new Mock(MockBehavior.Strict); + _command + .SetupProperty(c => c.CommandText); + _command + .Setup(c => c.Dispose()); + + _connection = new Mock(MockBehavior.Strict); + _connection + .Setup(c => c.Open()); + _connection + .Setup(c => c.CreateCommand()) + .Returns(_command.Object); + _connection + .Setup(c => c.Dispose()); + + _adapter = new Mock(MockBehavior.Strict); + + _sut = new Database { - _logOutput = new List(); - var log = new Mock(MockBehavior.Strict); - log - .Setup(l => l.Error(It.IsAny())) - .Callback(m => - { - Console.WriteLine("Error: {0}", m); - _logOutput.Add(m); - }); - log - .Setup(l => l.Info(It.IsAny())) - .Callback(m => - { - Console.WriteLine("Info: {0}", m); - _logOutput.Add(m); - }); - - _transaction = new Mock(MockBehavior.Strict); - _transaction - .Setup(t => t.Dispose()); - _transaction - .Setup(t => t.Commit()); - - _command = new Mock(MockBehavior.Strict); - _command - .SetupProperty(c => c.CommandText); - _command - .Setup(c => c.Dispose()); - - _connection = new Mock(MockBehavior.Strict); - _connection - .Setup(c => c.Open()); - _connection - .Setup(c => c.CreateCommand()) - .Returns(_command.Object); - _connection - .Setup(c => c.Dispose()); - - _adapter = new Mock(MockBehavior.Strict); - - _sut = new Database + Adapter = _adapter.Object, + Log = log.Object + }; + } + + [Test] + public void GetCurrentVersion() + { + _command + .SetupProperty(c => c.CommandTimeout, 30); + _command + .Setup(c => c.ExecuteScalar()) + .Callback(() => { - Adapter = _adapter.Object, - Log = log.Object - }; - } + _command.Object.CommandTimeout.ShouldBe(0); + _command.Object.CommandText.ShouldBe("select 1"); + }) + .Returns("1.1"); - [Test] - public void GetCurrentVersion() - { - _command - .SetupProperty(c => c.CommandTimeout, 30); - _command - .Setup(c => c.ExecuteScalar()) - .Callback(() => - { - _command.Object.CommandTimeout.ShouldBe(0); - _command.Object.CommandText.ShouldBe("select 1"); - }) - .Returns("1.1"); + _adapter + .Setup(a => a.CreateConnection(false)) + .Returns(_connection.Object); + _adapter + .Setup(a => a.GetVersionSelectScript()) + .Returns("select 1"); - _adapter - .Setup(a => a.CreateConnection(false)) - .Returns(_connection.Object); - _adapter - .Setup(a => a.GetVersionSelectScript()) - .Returns("select 1"); + var actual = _sut.GetCurrentVersion(null); - var actual = _sut.GetCurrentVersion(null); + actual.ShouldBe(new Version("1.1")); + + _adapter.VerifyAll(); + _connection.VerifyAll(); + _command.VerifyAll(); + } - actual.ShouldBe(new Version("1.1")); + [Test] + public void GetCurrentVersionModuleName() + { + _command + .SetupProperty(c => c.CommandTimeout, 30); + _command + .Setup(c => c.ExecuteScalar()) + .Callback(() => + { + _command.Object.CommandTimeout.ShouldBe(0); + _command.Object.CommandText.ShouldBe("select 'my module name'"); + }) + .Returns("1.1"); - _adapter.VerifyAll(); - _connection.VerifyAll(); - _command.VerifyAll(); - } + _adapter + .Setup(a => a.CreateConnection(false)) + .Returns(_connection.Object); + _adapter + .Setup(a => a.GetVersionSelectScript()) + .Returns("select '{{ModuleName}}'"); - [Test] - public void GetCurrentVersionModuleName() - { - _command - .SetupProperty(c => c.CommandTimeout, 30); - _command - .Setup(c => c.ExecuteScalar()) - .Callback(() => - { - _command.Object.CommandTimeout.ShouldBe(0); - _command.Object.CommandText.ShouldBe("select 'my module name'"); - }) - .Returns("1.1"); + var actual = _sut.GetCurrentVersion("my module name"); - _adapter - .Setup(a => a.CreateConnection(false)) - .Returns(_connection.Object); - _adapter - .Setup(a => a.GetVersionSelectScript()) - .Returns("select '{{ModuleName}}'"); + actual.ShouldBe(new Version("1.1")); - var actual = _sut.GetCurrentVersion("my module name"); + _adapter.VerifyAll(); + _connection.VerifyAll(); + _command.VerifyAll(); + } - actual.ShouldBe(new Version("1.1")); + [Test] + public void GetCurrentVersionInvalidScript() + { + var ex = new Mock(); - _adapter.VerifyAll(); - _connection.VerifyAll(); - _command.VerifyAll(); - } + _command + .SetupProperty(c => c.CommandTimeout, 30); + _command + .Setup(c => c.ExecuteScalar()) + .Throws(ex.Object); - [Test] - public void GetCurrentVersionInvalidScript() - { - var ex = new Mock(); + _adapter + .Setup(a => a.CreateConnection(false)) + .Returns(_connection.Object); + _adapter + .Setup(a => a.GetVersionSelectScript()) + .Returns("select 1"); - _command - .SetupProperty(c => c.CommandTimeout, 30); - _command - .Setup(c => c.ExecuteScalar()) - .Throws(ex.Object); + var actual = Assert.Throws(() => _sut.GetCurrentVersion(null)); - _adapter - .Setup(a => a.CreateConnection(false)) - .Returns(_connection.Object); - _adapter - .Setup(a => a.GetVersionSelectScript()) - .Returns("select 1"); + actual.InnerException.ShouldBe(ex.Object); + actual.Message.ShouldContain("select 1"); + } - var actual = Assert.Throws(() => _sut.GetCurrentVersion(null)); + [Test] + public void GetCurrentVersionInvalidVersion() + { + _command + .SetupProperty(c => c.CommandTimeout, 30); + _command + .Setup(c => c.ExecuteScalar()) + .Returns("abc"); + + _adapter + .Setup(a => a.CreateConnection(false)) + .Returns(_connection.Object); + _adapter + .Setup(a => a.GetVersionSelectScript()) + .Returns("select 1"); + + var actual = Assert.Throws(() => _sut.GetCurrentVersion(null)); + + actual.Message.ShouldContain("abc"); + } - actual.InnerException.ShouldBe(ex.Object); - actual.Message.ShouldContain("select 1"); - } + [Test] + public void GetCurrentVersionModuleNameInvalidVersion() + { + _command + .SetupProperty(c => c.CommandTimeout, 30); + _command + .Setup(c => c.ExecuteScalar()) + .Returns("abc"); + + _adapter + .Setup(a => a.CreateConnection(false)) + .Returns(_connection.Object); + _adapter + .Setup(a => a.GetVersionSelectScript()) + .Returns("select 1"); + + var actual = Assert.Throws(() => _sut.GetCurrentVersion("my module-name")); + + actual.Message.ShouldContain("abc"); + actual.Message.ShouldContain("my module-name"); + } - [Test] - public void GetCurrentVersionInvalidVersion() - { - _command - .SetupProperty(c => c.CommandTimeout, 30); - _command - .Setup(c => c.ExecuteScalar()) - .Returns("abc"); - - _adapter - .Setup(a => a.CreateConnection(false)) - .Returns(_connection.Object); - _adapter - .Setup(a => a.GetVersionSelectScript()) - .Returns("select 1"); - - var actual = Assert.Throws(() => _sut.GetCurrentVersion(null)); - - actual.Message.ShouldContain("abc"); - } - - [Test] - public void GetCurrentVersionModuleNameInvalidVersion() - { - _command - .SetupProperty(c => c.CommandTimeout, 30); - _command - .Setup(c => c.ExecuteScalar()) - .Returns("abc"); - - _adapter - .Setup(a => a.CreateConnection(false)) - .Returns(_connection.Object); - _adapter - .Setup(a => a.GetVersionSelectScript()) - .Returns("select 1"); - - var actual = Assert.Throws(() => _sut.GetCurrentVersion("my module-name")); - - actual.Message.ShouldContain("abc"); - actual.Message.ShouldContain("my module-name"); - } - - [Test] - public void GetServerVersion() - { - _adapter - .Setup(a => a.GetServerVersionSelectScript()) - .Returns("select server version"); - _adapter - .Setup(a => a.CreateConnection(true)) - .Returns(_connection.Object); - - _command - .Setup(c => c.ExecuteScalar()) - .Callback(() => - { - _command.Object.CommandText.ShouldBe("select server version"); - }) - .Returns("server version"); + [Test] + public void GetServerVersion() + { + _adapter + .Setup(a => a.GetServerVersionSelectScript()) + .Returns("select server version"); + _adapter + .Setup(a => a.CreateConnection(true)) + .Returns(_connection.Object); + + _command + .Setup(c => c.ExecuteScalar()) + .Callback(() => + { + _command.Object.CommandText.ShouldBe("select server version"); + }) + .Returns("server version"); - var actual = _sut.GetServerVersion(); + var actual = _sut.GetServerVersion(); - actual.ShouldBe("server version"); - } + actual.ShouldBe("server version"); + } - [Test] - [TestCase(TransactionMode.None)] - [TestCase(TransactionMode.PerStep)] - public void ExecuteUpgrade(TransactionMode transaction) - { - _sut.Transaction = transaction; - - _command - .SetupProperty(c => c.CommandTimeout, 30); - _command - .SetupProperty(c => c.Transaction); - - _connection - .Setup(c => c.BeginTransaction(IsolationLevel.ReadCommitted)) - .Returns(_transaction.Object); - - _adapter - .SetupGet(a => a.DatabaseName) - .Returns("database-name"); - _adapter - .Setup(a => a.CreateConnection(false)) - .Returns(_connection.Object); - - var script = new Mock(MockBehavior.Strict); - script - .Setup(s => s.Execute(_command.Object, It.IsNotNull(), It.IsNotNull())) - .Callback((cmd, variables, s) => + [Test] + [TestCase(TransactionMode.None)] + [TestCase(TransactionMode.PerStep)] + public void ExecuteUpgrade(TransactionMode transaction) + { + _sut.Transaction = transaction; + + _command + .SetupProperty(c => c.CommandTimeout, 30); + _command + .SetupProperty(c => c.Transaction); + + _connection + .Setup(c => c.BeginTransaction(IsolationLevel.ReadCommitted)) + .Returns(_transaction.Object); + + _adapter + .SetupGet(a => a.DatabaseName) + .Returns("database-name"); + _adapter + .Setup(a => a.CreateConnection(false)) + .Returns(_connection.Object); + + var script = new Mock(MockBehavior.Strict); + script + .Setup(s => s.Execute(_command.Object, It.IsNotNull(), It.IsNotNull())) + .Callback((cmd, variables, s) => + { + cmd.CommandTimeout.ShouldBe(0); + + if (transaction == TransactionMode.PerStep) { - cmd.CommandTimeout.ShouldBe(0); - - if (transaction == TransactionMode.PerStep) - { - cmd.Transaction.ShouldBe(_transaction.Object); - } - else - { - cmd.Transaction.ShouldBeNull(); - } - - variables.GetValue("DatabaseName").ShouldBe("database-name"); - variables.GetValue("CurrentVersion").ShouldBe("1.0"); - variables.GetValue("TargetVersion").ShouldBe("2.0"); - variables.GetValue("ModuleName").ShouldBe("my module"); - - _adapter - .Setup(a => a.GetVersionUpdateScript()) - .Returns("update version"); - _adapter - .Setup(a => a.GetVersionSelectScript()) - .Returns("select version"); - - _command - .Setup(c => c.ExecuteNonQuery()) - .Callback(() => _command.Object.CommandText.ShouldBe("update version")) - .Returns(0); - _command - .Setup(c => c.ExecuteScalar()) - .Callback(() => _command.Object.CommandText.ShouldBe("select version")) - .Returns("2.0"); - }); - - _sut.Execute(script.Object, "my module", new Version("1.0"), new Version("2.0")); - - script.VerifyAll(); - _command.VerifyAll(); - } - - [Test] - public void ExecuteUpgradeWhatIf() - { - _adapter - .SetupGet(a => a.DatabaseName) - .Returns("database-name"); - - var script = new Mock(MockBehavior.Strict); - script - .Setup(s => s.Execute(null, It.IsNotNull(), It.IsNotNull())) - .Callback((cmd, variables, s) => + cmd.Transaction.ShouldBe(_transaction.Object); + } + else { - variables.GetValue("DatabaseName").ShouldBe("database-name"); - variables.GetValue("CurrentVersion").ShouldBe("1.0"); - variables.GetValue("TargetVersion").ShouldBe("2.0"); - variables.GetValue("ModuleName").ShouldBe("my module"); - }); + cmd.Transaction.ShouldBeNull(); + } + + variables.GetValue("DatabaseName").ShouldBe("database-name"); + variables.GetValue("CurrentVersion").ShouldBe("1.0"); + variables.GetValue("TargetVersion").ShouldBe("2.0"); + variables.GetValue("ModuleName").ShouldBe("my module"); + + _adapter + .Setup(a => a.GetVersionUpdateScript()) + .Returns("update version"); + _adapter + .Setup(a => a.GetVersionSelectScript()) + .Returns("select version"); + + _command + .Setup(c => c.ExecuteNonQuery()) + .Callback(() => _command.Object.CommandText.ShouldBe("update version")) + .Returns(0); + _command + .Setup(c => c.ExecuteScalar()) + .Callback(() => _command.Object.CommandText.ShouldBe("select version")) + .Returns("2.0"); + }); + + _sut.Execute(script.Object, "my module", new Version("1.0"), new Version("2.0")); + + script.VerifyAll(); + _command.VerifyAll(); + } + + [Test] + public void ExecuteUpgradeWhatIf() + { + _adapter + .SetupGet(a => a.DatabaseName) + .Returns("database-name"); + + var script = new Mock(MockBehavior.Strict); + script + .Setup(s => s.Execute(null, It.IsNotNull(), It.IsNotNull())) + .Callback((cmd, variables, s) => + { + variables.GetValue("DatabaseName").ShouldBe("database-name"); + variables.GetValue("CurrentVersion").ShouldBe("1.0"); + variables.GetValue("TargetVersion").ShouldBe("2.0"); + variables.GetValue("ModuleName").ShouldBe("my module"); + }); - _sut.WhatIf = true; + _sut.WhatIf = true; - _sut.Execute(script.Object, "my module", new Version("1.0"), new Version("2.0")); + _sut.Execute(script.Object, "my module", new Version("1.0"), new Version("2.0")); - script.VerifyAll(); + script.VerifyAll(); - _logOutput.Count.ShouldBe(1); - _logOutput[0].ShouldBe("what-if mode"); - } + _logOutput.Count.ShouldBe(1); + _logOutput[0].ShouldBe("what-if mode"); + } - [Test] - [TestCase(TransactionMode.None)] - [TestCase(TransactionMode.PerStep)] - public void Execute(TransactionMode transaction) - { - _sut.Transaction = transaction; - - _command - .SetupProperty(c => c.CommandTimeout, 30); - _command - .SetupProperty(c => c.Transaction); - - _connection - .Setup(c => c.BeginTransaction(IsolationLevel.ReadCommitted)) - .Returns(_transaction.Object); - - _adapter - .SetupGet(a => a.DatabaseName) - .Returns("database-name"); - _adapter - .Setup(a => a.GetDatabaseExistsScript("database-name")) - .Returns("database exits"); - _adapter - .Setup(a => a.CreateConnection(true)) - .Returns(_connection.Object); - _adapter - .Setup(a => a.CreateConnection(false)) - .Returns(_connection.Object); - - _command - .Setup(c => c.ExecuteScalar()) - .Callback(() => _command.Object.CommandText.ShouldBe("database exits")) - .Returns("true"); - - var script = new Mock(MockBehavior.Strict); - script - .Setup(s => s.Execute(_command.Object, It.IsNotNull(), It.IsNotNull())) - .Callback((cmd, variables, s) => + [Test] + [TestCase(TransactionMode.None)] + [TestCase(TransactionMode.PerStep)] + public void Execute(TransactionMode transaction) + { + _sut.Transaction = transaction; + + _command + .SetupProperty(c => c.CommandTimeout, 30); + _command + .SetupProperty(c => c.Transaction); + + _connection + .Setup(c => c.BeginTransaction(IsolationLevel.ReadCommitted)) + .Returns(_transaction.Object); + + _adapter + .SetupGet(a => a.DatabaseName) + .Returns("database-name"); + _adapter + .Setup(a => a.GetDatabaseExistsScript("database-name")) + .Returns("database exits"); + _adapter + .Setup(a => a.CreateConnection(true)) + .Returns(_connection.Object); + _adapter + .Setup(a => a.CreateConnection(false)) + .Returns(_connection.Object); + + _command + .Setup(c => c.ExecuteScalar()) + .Callback(() => _command.Object.CommandText.ShouldBe("database exits")) + .Returns("true"); + + var script = new Mock(MockBehavior.Strict); + script + .Setup(s => s.Execute(_command.Object, It.IsNotNull(), It.IsNotNull())) + .Callback((cmd, variables, s) => + { + cmd.CommandTimeout.ShouldBe(0); + + if (transaction == TransactionMode.PerStep) { - cmd.CommandTimeout.ShouldBe(0); - - if (transaction == TransactionMode.PerStep) - { - cmd.Transaction.ShouldBe(_transaction.Object); - } - else - { - cmd.Transaction.ShouldBeNull(); - } - - variables.GetValue("DatabaseName").ShouldBe("database-name"); - variables.GetValue("CurrentVersion").ShouldBeNullOrEmpty(); - variables.GetValue("TargetVersion").ShouldBeNullOrEmpty(); - variables.GetValue("ModuleName").ShouldBeNullOrEmpty(); - }); - - _sut.Execute(script.Object); - - script.VerifyAll(); - _command.VerifyAll(); - } - - [Test] - public void ExecuteDatabaseNotFound() - { - _command - .SetupProperty(c => c.Transaction); - _command - .SetupProperty(c => c.CommandTimeout, 30); - - _adapter - .SetupGet(a => a.DatabaseName) - .Returns("database-name"); - _adapter - .Setup(a => a.GetDatabaseExistsScript("database-name")) - .Returns("database exits"); - _adapter - .Setup(a => a.CreateConnection(true)) - .Returns(_connection.Object); - - _command - .Setup(c => c.ExecuteScalar()) - .Callback(() => _command.Object.CommandText.ShouldBe("database exits")) - .Returns(DBNull.Value); - - var script = new Mock(MockBehavior.Strict); - script - .Setup(s => s.Execute(_command.Object, It.IsNotNull(), It.IsNotNull())) - .Callback((cmd, v, s) => + cmd.Transaction.ShouldBe(_transaction.Object); + } + else { - cmd.CommandTimeout.ShouldBe(0); cmd.Transaction.ShouldBeNull(); - }); + } - _sut.Execute(script.Object); + variables.GetValue("DatabaseName").ShouldBe("database-name"); + variables.GetValue("CurrentVersion").ShouldBeNullOrEmpty(); + variables.GetValue("TargetVersion").ShouldBeNullOrEmpty(); + variables.GetValue("ModuleName").ShouldBeNullOrEmpty(); + }); - script.VerifyAll(); - _command.VerifyAll(); - _adapter.VerifyAll(); - } + _sut.Execute(script.Object); - [Test] - public void ExecuteWhatIf() - { - _adapter - .SetupGet(a => a.DatabaseName) - .Returns("database-name"); - - var script = new Mock(MockBehavior.Strict); - script - .Setup(s => s.Execute(null, It.IsNotNull(), It.IsNotNull())) - .Callback((cmd, variables, s) => - { - variables.GetValue("DatabaseName").ShouldBe("database-name"); - variables.GetValue("CurrentVersion").ShouldBeNullOrEmpty(); - variables.GetValue("TargetVersion").ShouldBeNullOrEmpty(); - variables.GetValue("ModuleName").ShouldBeNullOrEmpty(); - }); + script.VerifyAll(); + _command.VerifyAll(); + } - _sut.WhatIf = true; + [Test] + public void ExecuteDatabaseNotFound() + { + _command + .SetupProperty(c => c.Transaction); + _command + .SetupProperty(c => c.CommandTimeout, 30); + + _adapter + .SetupGet(a => a.DatabaseName) + .Returns("database-name"); + _adapter + .Setup(a => a.GetDatabaseExistsScript("database-name")) + .Returns("database exits"); + _adapter + .Setup(a => a.CreateConnection(true)) + .Returns(_connection.Object); + + _command + .Setup(c => c.ExecuteScalar()) + .Callback(() => _command.Object.CommandText.ShouldBe("database exits")) + .Returns(DBNull.Value); + + var script = new Mock(MockBehavior.Strict); + script + .Setup(s => s.Execute(_command.Object, It.IsNotNull(), It.IsNotNull())) + .Callback((cmd, v, s) => + { + cmd.CommandTimeout.ShouldBe(0); + cmd.Transaction.ShouldBeNull(); + }); - _sut.Execute(script.Object); + _sut.Execute(script.Object); - script.VerifyAll(); + script.VerifyAll(); + _command.VerifyAll(); + _adapter.VerifyAll(); + } - _logOutput.Count.ShouldBe(1); - _logOutput[0].ShouldBe("what-if mode"); - } + [Test] + public void ExecuteWhatIf() + { + _adapter + .SetupGet(a => a.DatabaseName) + .Returns("database-name"); + + var script = new Mock(MockBehavior.Strict); + script + .Setup(s => s.Execute(null, It.IsNotNull(), It.IsNotNull())) + .Callback((cmd, variables, s) => + { + variables.GetValue("DatabaseName").ShouldBe("database-name"); + variables.GetValue("CurrentVersion").ShouldBeNullOrEmpty(); + variables.GetValue("TargetVersion").ShouldBeNullOrEmpty(); + variables.GetValue("ModuleName").ShouldBeNullOrEmpty(); + }); - [Test] - public void ExecuteReader() - { - _command - .SetupProperty(c => c.CommandTimeout, 30); - - _adapter - .SetupGet(a => a.DatabaseName) - .Returns("database-name"); - _adapter - .Setup(a => a.CreateConnection(false)) - .Returns(_connection.Object); - - var reader1 = new Mock(MockBehavior.Strict); - var reader2 = new Mock(MockBehavior.Strict); - - var script = new Mock(MockBehavior.Strict); - script - .Setup(s => s.ExecuteReader(_command.Object, It.IsNotNull(), It.IsNotNull())) - .Callback((cmd, variables, s) => - { - cmd.CommandTimeout.ShouldBe(0); - variables.GetValue("DatabaseName").ShouldBe("database-name"); - }) - .Returns(new[] { reader1.Object, reader2.Object }); + _sut.WhatIf = true; + + _sut.Execute(script.Object); + + script.VerifyAll(); + + _logOutput.Count.ShouldBe(1); + _logOutput[0].ShouldBe("what-if mode"); + } + + [Test] + public void ExecuteReader() + { + _command + .SetupProperty(c => c.CommandTimeout, 30); + + _adapter + .SetupGet(a => a.DatabaseName) + .Returns("database-name"); + _adapter + .Setup(a => a.CreateConnection(false)) + .Returns(_connection.Object); + + var reader1 = new Mock(MockBehavior.Strict); + var reader2 = new Mock(MockBehavior.Strict); + + var script = new Mock(MockBehavior.Strict); + script + .Setup(s => s.ExecuteReader(_command.Object, It.IsNotNull(), It.IsNotNull())) + .Callback((cmd, variables, s) => + { + cmd.CommandTimeout.ShouldBe(0); + variables.GetValue("DatabaseName").ShouldBe("database-name"); + }) + .Returns(new[] { reader1.Object, reader2.Object }); - var actual = _sut.ExecuteReader(script.Object).ToArray(); + var actual = _sut.ExecuteReader(script.Object).ToArray(); - actual.ShouldBe(new[] { reader1.Object, reader2.Object }); + actual.ShouldBe(new[] { reader1.Object, reader2.Object }); - script.VerifyAll(); - } + script.VerifyAll(); } } \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/DependencyParserTest.cs b/Sources/SqlDatabase.Test/Scripts/DependencyParserTest.cs index 79b7c31e..c86dd3e5 100644 --- a/Sources/SqlDatabase.Test/Scripts/DependencyParserTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/DependencyParserTest.cs @@ -6,51 +6,50 @@ using Shouldly; using SqlDatabase.Scripts.SqlTestCases; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +[TestFixture] +public class DependencyParserTest { - [TestFixture] - public class DependencyParserTest + [Test] + [TestCaseSource(nameof(GetExtractDependenciesTestCases))] + public void ExtractDependencies(string sql, ScriptDependency[] expected) { - [Test] - [TestCaseSource(nameof(GetExtractDependenciesTestCases))] - public void ExtractDependencies(string sql, ScriptDependency[] expected) - { - var actual = DependencyParser.ExtractDependencies(new StringReader(sql), "file name").ToArray(); - actual.ShouldBe(expected); - } + var actual = DependencyParser.ExtractDependencies(new StringReader(sql), "file name").ToArray(); + actual.ShouldBe(expected); + } - [Test] - [TestCase("1.a")] - [TestCase("10")] - public void ExtractDependenciesInvalidVersion(string versionText) - { - var input = "-- module dependency: moduleName " + versionText; - var ex = Assert.Throws(() => DependencyParser.ExtractDependencies(new StringReader(input), "file name").ToArray()); + [Test] + [TestCase("1.a")] + [TestCase("10")] + public void ExtractDependenciesInvalidVersion(string versionText) + { + var input = "-- module dependency: moduleName " + versionText; + var ex = Assert.Throws(() => DependencyParser.ExtractDependencies(new StringReader(input), "file name").ToArray()); - ex.Message.ShouldContain("moduleName"); - ex.Message.ShouldContain(versionText); - } + ex.Message.ShouldContain("moduleName"); + ex.Message.ShouldContain(versionText); + } - private static IEnumerable GetExtractDependenciesTestCases() + private static IEnumerable GetExtractDependenciesTestCases() + { + foreach (var testCase in ResourceReader.Read("Dependencies")) { - foreach (var testCase in ResourceReader.Read("Dependencies")) + var expected = new List(); + foreach (var line in testCase.Expected) { - var expected = new List(); - foreach (var line in testCase.Expected) + if (!string.IsNullOrWhiteSpace(line)) { - if (!string.IsNullOrWhiteSpace(line)) - { - var parts = line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); - parts.Length.ShouldBe(2); - expected.Add(new ScriptDependency(parts[0], new Version(parts[1]))); - } + var parts = line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + parts.Length.ShouldBe(2); + expected.Add(new ScriptDependency(parts[0], new Version(parts[1]))); } - - yield return new TestCaseData(testCase.Input, expected.ToArray()) - { - TestName = testCase.Name - }; } + + yield return new TestCaseData(testCase.Input, expected.ToArray()) + { + TestName = testCase.Name + }; } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/MsSql/MsSqlDatabaseAdapterTest.cs b/Sources/SqlDatabase.Test/Scripts/MsSql/MsSqlDatabaseAdapterTest.cs index a907ba11..dce00f37 100644 --- a/Sources/SqlDatabase.Test/Scripts/MsSql/MsSqlDatabaseAdapterTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/MsSql/MsSqlDatabaseAdapterTest.cs @@ -7,187 +7,186 @@ using SqlDatabase.Configuration; using SqlDatabase.TestApi; -namespace SqlDatabase.Scripts.MsSql +namespace SqlDatabase.Scripts.MsSql; + +[TestFixture] +public class MsSqlDatabaseAdapterTest { - [TestFixture] - public class MsSqlDatabaseAdapterTest - { - private const string ModuleName = "SomeModuleName"; - private const string SelectModuleVersion = "SELECT value from sys.fn_listextendedproperty('version-{{ModuleName}}', default, default, default, default, default, default)"; - private const string UpdateModuleVersion = "EXEC sys.sp_updateextendedproperty @name=N'version-{{ModuleName}}', @value=N'{{TargetVersion}}'"; + private const string ModuleName = "SomeModuleName"; + private const string SelectModuleVersion = "SELECT value from sys.fn_listextendedproperty('version-{{ModuleName}}', default, default, default, default, default, default)"; + private const string UpdateModuleVersion = "EXEC sys.sp_updateextendedproperty @name=N'version-{{ModuleName}}', @value=N'{{TargetVersion}}'"; - private MsSqlDatabaseAdapter _sut; - private AppConfiguration _configuration; - private IList _logOutput; + private MsSqlDatabaseAdapter _sut; + private AppConfiguration _configuration; + private IList _logOutput; - [SetUp] - public void BeforeEachTest() - { - _logOutput = new List(); - var log = new Mock(MockBehavior.Strict); - log - .Setup(l => l.Info(It.IsAny())) - .Callback(m => - { - Console.WriteLine("Info: {0}", m); - _logOutput.Add(m); - }); + [SetUp] + public void BeforeEachTest() + { + _logOutput = new List(); + var log = new Mock(MockBehavior.Strict); + log + .Setup(l => l.Info(It.IsAny())) + .Callback(m => + { + Console.WriteLine("Info: {0}", m); + _logOutput.Add(m); + }); - _configuration = new AppConfiguration(); + _configuration = new AppConfiguration(); - _sut = new MsSqlDatabaseAdapter( - MsSqlQuery.ConnectionString, - _configuration, - log.Object); - } + _sut = new MsSqlDatabaseAdapter( + MsSqlQuery.ConnectionString, + _configuration, + log.Object); + } - [Test] - public void CreateConnectionToTargetDatabase() + [Test] + public void CreateConnectionToTargetDatabase() + { + using (var connection = _sut.CreateConnection(false)) { - using (var connection = _sut.CreateConnection(false)) - { - connection.State.ShouldBe(ConnectionState.Closed); + connection.State.ShouldBe(ConnectionState.Closed); - connection.Open(); - connection.Database.ShouldBe(_sut.DatabaseName); - } + connection.Open(); + connection.Database.ShouldBe(_sut.DatabaseName); } + } - [Test] - public void CreateConnectionToMaster() + [Test] + public void CreateConnectionToMaster() + { + using (var connection = _sut.CreateConnection(true)) { - using (var connection = _sut.CreateConnection(true)) - { - connection.State.ShouldBe(ConnectionState.Closed); + connection.State.ShouldBe(ConnectionState.Closed); - connection.Open(); - connection.Database.ShouldBe("master"); - } + connection.Open(); + connection.Database.ShouldBe("master"); } + } - [Test] - public void GetServerVersionSelectScript() + [Test] + public void GetServerVersionSelectScript() + { + using (var connection = _sut.CreateConnection(false)) + using (var cmd = connection.CreateCommand()) { - using (var connection = _sut.CreateConnection(false)) - using (var cmd = connection.CreateCommand()) - { - cmd.CommandText = _sut.GetServerVersionSelectScript(); - connection.Open(); + cmd.CommandText = _sut.GetServerVersionSelectScript(); + connection.Open(); - var actual = cmd.ExecuteScalar(); - Console.WriteLine(actual); + var actual = cmd.ExecuteScalar(); + Console.WriteLine(actual); - actual.ShouldBeOfType().ShouldNotBeNullOrWhiteSpace(); - } + actual.ShouldBeOfType().ShouldNotBeNullOrWhiteSpace(); } + } - [Test] - [TestCase("master", true)] - [TestCase("unknown database", false)] - [TestCase(null, true)] - public void GetDatabaseExistsScript(string databaseName, bool expected) + [Test] + [TestCase("master", true)] + [TestCase("unknown database", false)] + [TestCase(null, true)] + public void GetDatabaseExistsScript(string databaseName, bool expected) + { + using (var connection = _sut.CreateConnection(true)) + using (var cmd = connection.CreateCommand()) { - using (var connection = _sut.CreateConnection(true)) - using (var cmd = connection.CreateCommand()) - { - connection.Open(); + connection.Open(); - cmd.CommandText = _sut.GetDatabaseExistsScript(databaseName ?? _sut.DatabaseName); - var actual = cmd.ExecuteScalar()?.ToString(); + cmd.CommandText = _sut.GetDatabaseExistsScript(databaseName ?? _sut.DatabaseName); + var actual = cmd.ExecuteScalar()?.ToString(); - if (expected) - { - actual.ShouldNotBeNullOrWhiteSpace(); - } - else - { - actual.ShouldBeNullOrEmpty(); - } + if (expected) + { + actual.ShouldNotBeNullOrWhiteSpace(); + } + else + { + actual.ShouldBeNullOrEmpty(); } } + } - [Test] - [TestCase("use master", "master")] - [TestCase("print 'xx1xx'", "xx1xx")] - public void SqlOutputIntoLog(string script, string expected) + [Test] + [TestCase("use master", "master")] + [TestCase("print 'xx1xx'", "xx1xx")] + public void SqlOutputIntoLog(string script, string expected) + { + using (var connection = _sut.CreateConnection(false)) { - using (var connection = _sut.CreateConnection(false)) - { - connection.Open(); + connection.Open(); - using (var cmd = connection.CreateCommand()) - { - cmd.CommandText = script; - cmd.ExecuteNonQuery(); + using (var cmd = connection.CreateCommand()) + { + cmd.CommandText = script; + cmd.ExecuteNonQuery(); - _logOutput.Count.ShouldBe(1); - _logOutput[0].ShouldContain(expected); - } + _logOutput.Count.ShouldBe(1); + _logOutput[0].ShouldContain(expected); } } + } - [Test] - public void GetSetVersionScriptDefault() - { - _sut.GetVersionSelectScript().ShouldBe(MsSqlDatabaseAdapter.DefaultSelectVersion); - _sut.GetVersionUpdateScript().ShouldBe(MsSqlDatabaseAdapter.DefaultUpdateVersion); + [Test] + public void GetSetVersionScriptDefault() + { + _sut.GetVersionSelectScript().ShouldBe(MsSqlDatabaseAdapter.DefaultSelectVersion); + _sut.GetVersionUpdateScript().ShouldBe(MsSqlDatabaseAdapter.DefaultUpdateVersion); - using (var connection = _sut.CreateConnection(false)) + using (var connection = _sut.CreateConnection(false)) + { + connection.Open(); + using (var transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted)) { - connection.Open(); - using (var transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted)) + using (var cmd = connection.CreateCommand()) { - using (var cmd = connection.CreateCommand()) - { - cmd.Transaction = transaction; - - cmd.CommandText = _sut.GetVersionUpdateScript().Replace("{{TargetVersion}}", "new version"); - cmd.ExecuteNonQuery(); + cmd.Transaction = transaction; - cmd.CommandText = _sut.GetVersionSelectScript(); + cmd.CommandText = _sut.GetVersionUpdateScript().Replace("{{TargetVersion}}", "new version"); + cmd.ExecuteNonQuery(); - var actual = cmd.ExecuteScalar(); - actual.ShouldBeOfType().ShouldBe("new version"); - } + cmd.CommandText = _sut.GetVersionSelectScript(); - transaction.Rollback(); + var actual = cmd.ExecuteScalar(); + actual.ShouldBeOfType().ShouldBe("new version"); } + + transaction.Rollback(); } } + } - [Test] - public void GetSetVersionScriptModuleName() - { - _configuration.GetCurrentVersionScript = SelectModuleVersion; - _configuration.SetCurrentVersionScript = UpdateModuleVersion; + [Test] + public void GetSetVersionScriptModuleName() + { + _configuration.GetCurrentVersionScript = SelectModuleVersion; + _configuration.SetCurrentVersionScript = UpdateModuleVersion; - _sut.GetVersionSelectScript().ShouldBe(SelectModuleVersion); - _sut.GetVersionUpdateScript().ShouldBe(UpdateModuleVersion); + _sut.GetVersionSelectScript().ShouldBe(SelectModuleVersion); + _sut.GetVersionUpdateScript().ShouldBe(UpdateModuleVersion); - using (var connection = _sut.CreateConnection(false)) + using (var connection = _sut.CreateConnection(false)) + { + connection.Open(); + using (var transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted)) { - connection.Open(); - using (var transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted)) + using (var cmd = connection.CreateCommand()) { - using (var cmd = connection.CreateCommand()) - { - cmd.Transaction = transaction; + cmd.Transaction = transaction; - cmd.CommandText = _sut - .GetVersionUpdateScript() - .Replace("{{TargetVersion}}", "new version") - .Replace("{{ModuleName}}", ModuleName); - cmd.ExecuteNonQuery(); - - cmd.CommandText = _sut.GetVersionSelectScript().Replace("{{ModuleName}}", ModuleName); + cmd.CommandText = _sut + .GetVersionUpdateScript() + .Replace("{{TargetVersion}}", "new version") + .Replace("{{ModuleName}}", ModuleName); + cmd.ExecuteNonQuery(); - var actual = cmd.ExecuteScalar(); - actual.ShouldBeOfType().ShouldBe("new version"); - } + cmd.CommandText = _sut.GetVersionSelectScript().Replace("{{ModuleName}}", ModuleName); - transaction.Rollback(); + var actual = cmd.ExecuteScalar(); + actual.ShouldBeOfType().ShouldBe("new version"); } + + transaction.Rollback(); } } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/MsSql/MsSqlTextReaderTest.cs b/Sources/SqlDatabase.Test/Scripts/MsSql/MsSqlTextReaderTest.cs index fe89971c..f26600df 100644 --- a/Sources/SqlDatabase.Test/Scripts/MsSql/MsSqlTextReaderTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/MsSql/MsSqlTextReaderTest.cs @@ -5,57 +5,56 @@ using Shouldly; using SqlDatabase.Scripts.SqlTestCases; -namespace SqlDatabase.Scripts.MsSql +namespace SqlDatabase.Scripts.MsSql; + +[TestFixture] +public class MsSqlTextReaderTest { - [TestFixture] - public class MsSqlTextReaderTest - { - private MsSqlTextReader _sut; + private MsSqlTextReader _sut; - [SetUp] - public void BeforeEachTest() - { - _sut = new MsSqlTextReader(); - } + [SetUp] + public void BeforeEachTest() + { + _sut = new MsSqlTextReader(); + } - [Test] - [TestCase("go", true)] - [TestCase("go go", true)] - [TestCase(" go ", true)] - [TestCase(" \tGO \t", true)] - [TestCase("go\tgo go", true)] - [TestCase("o", false)] - [TestCase("fo", false)] - [TestCase("go pro", false)] - public void IsGo(string line, bool expected) - { - _sut.IsGo(line).ShouldBe(expected); - } + [Test] + [TestCase("go", true)] + [TestCase("go go", true)] + [TestCase(" go ", true)] + [TestCase(" \tGO \t", true)] + [TestCase("go\tgo go", true)] + [TestCase("o", false)] + [TestCase("fo", false)] + [TestCase("go pro", false)] + public void IsGo(string line, bool expected) + { + _sut.IsGo(line).ShouldBe(expected); + } - [Test] - [TestCaseSource(nameof(GetSplitByGoTestCases))] - public void SplitByGo(Stream input, string[] expected) - { - var batches = _sut.ReadBatches(input); - batches.ShouldBe(expected); + [Test] + [TestCaseSource(nameof(GetSplitByGoTestCases))] + public void SplitByGo(Stream input, string[] expected) + { + var batches = _sut.ReadBatches(input); + batches.ShouldBe(expected); - input.Position = 0; + input.Position = 0; - var first = _sut.ReadFirstBatch(input); - first.ShouldBe(expected[0]); - } + var first = _sut.ReadFirstBatch(input); + first.ShouldBe(expected[0]); + } - private static IEnumerable GetSplitByGoTestCases() + private static IEnumerable GetSplitByGoTestCases() + { + foreach (var testCase in ResourceReader.Read("Go")) { - foreach (var testCase in ResourceReader.Read("Go")) + yield return new TestCaseData( + new MemoryStream(Encoding.Default.GetBytes(testCase.Input)), + testCase.Expected) { - yield return new TestCaseData( - new MemoryStream(Encoding.Default.GetBytes(testCase.Input)), - testCase.Expected) - { - TestName = testCase.Name - }; - } + TestName = testCase.Name + }; } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/MsSql/MsSqlWriterTest.cs b/Sources/SqlDatabase.Test/Scripts/MsSql/MsSqlWriterTest.cs index e78ff0eb..88ca1fea 100644 --- a/Sources/SqlDatabase.Test/Scripts/MsSql/MsSqlWriterTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/MsSql/MsSqlWriterTest.cs @@ -5,107 +5,106 @@ using Shouldly; using SqlDatabase.TestApi; -namespace SqlDatabase.Scripts.MsSql +namespace SqlDatabase.Scripts.MsSql; + +[TestFixture] +public class MsSqlWriterTest { - [TestFixture] - public class MsSqlWriterTest + private StringBuilder _output; + private MsSqlWriter _sut; + + [SetUp] + public void BeforeEachTest() + { + _output = new StringBuilder(); + _sut = new MsSqlWriter(new StringWriter(_output)); + } + + [TearDown] + public void AfterEachTest() + { + Console.WriteLine(_output); + } + + [Test] + public void Null() + { + _sut.Null(); + + _output.ToString().ShouldBe("NULL"); + } + + [Test] + [TestCase("[Name]", "Name")] + [TestCase("[Name]", "[Name]")] + public void Name(string expected, string value) + { + _sut.Name(value); + + _output.ToString().ShouldBe(expected); + } + + [Test] + [TestCase("abc")] + [TestCase("'a'b''c'\r\na\rb\nc\ta")] + [TestCase("/* comment */")] + [TestCase("-- comment")] + [TestCase("'")] + public void EscapeVarchar(string input) + { + _sut.Text("SELECT ").Value(input); + + MsSqlQuery.ExecuteScalar(_output.ToString()).ShouldBe(input); + } + + [Test] + public void ValueDateTime() + { + var value = new DateTime(2019, 04, 21, 19, 26, 10).AddMilliseconds(123); + + _sut + .Text("SELECT CAST(") + .Value(value) + .Text(" AS DATETIME2)"); + + MsSqlQuery.ExecuteScalar(_output.ToString()).ShouldBe(value); + } + + [Test] + public void ValueGuid() + { + var value = Guid.NewGuid(); + + _sut + .Text("SELECT CAST(") + .Value(value) + .Text(" AS UNIQUEIDENTIFIER)"); + + MsSqlQuery.ExecuteScalar(_output.ToString()).ShouldBe(value); + } + + [Test] + [TestCase(new byte[0])] + [TestCase(new byte[] { 1, 2, 3 })] + public void ValueByteArray(byte[] value) { - private StringBuilder _output; - private MsSqlWriter _sut; - - [SetUp] - public void BeforeEachTest() - { - _output = new StringBuilder(); - _sut = new MsSqlWriter(new StringWriter(_output)); - } - - [TearDown] - public void AfterEachTest() - { - Console.WriteLine(_output); - } - - [Test] - public void Null() - { - _sut.Null(); - - _output.ToString().ShouldBe("NULL"); - } - - [Test] - [TestCase("[Name]", "Name")] - [TestCase("[Name]", "[Name]")] - public void Name(string expected, string value) - { - _sut.Name(value); - - _output.ToString().ShouldBe(expected); - } - - [Test] - [TestCase("abc")] - [TestCase("'a'b''c'\r\na\rb\nc\ta")] - [TestCase("/* comment */")] - [TestCase("-- comment")] - [TestCase("'")] - public void EscapeVarchar(string input) - { - _sut.Text("SELECT ").Value(input); - - MsSqlQuery.ExecuteScalar(_output.ToString()).ShouldBe(input); - } - - [Test] - public void ValueDateTime() - { - var value = new DateTime(2019, 04, 21, 19, 26, 10).AddMilliseconds(123); - - _sut - .Text("SELECT CAST(") - .Value(value) - .Text(" AS DATETIME2)"); - - MsSqlQuery.ExecuteScalar(_output.ToString()).ShouldBe(value); - } - - [Test] - public void ValueGuid() - { - var value = Guid.NewGuid(); - - _sut - .Text("SELECT CAST(") - .Value(value) - .Text(" AS UNIQUEIDENTIFIER)"); - - MsSqlQuery.ExecuteScalar(_output.ToString()).ShouldBe(value); - } - - [Test] - [TestCase(new byte[0])] - [TestCase(new byte[] { 1, 2, 3 })] - public void ValueByteArray(byte[] value) - { - _sut - .Text("SELECT ") - .Value(value); - - MsSqlQuery.ExecuteScalar(_output.ToString()).ShouldBe(value); - } - - [Test] - public void ValueDateTimeOffset() - { - var value = new DateTimeOffset(2020, 11, 23, 00, 02, 50, 999, TimeSpan.FromHours(2)); - - _sut - .Text("SELECT CAST(") - .Value(value) - .Text(" AS DATETIMEOFFSET)"); - - MsSqlQuery.ExecuteScalar(_output.ToString()).ShouldBe(value); - } + _sut + .Text("SELECT ") + .Value(value); + + MsSqlQuery.ExecuteScalar(_output.ToString()).ShouldBe(value); + } + + [Test] + public void ValueDateTimeOffset() + { + var value = new DateTimeOffset(2020, 11, 23, 00, 02, 50, 999, TimeSpan.FromHours(2)); + + _sut + .Text("SELECT CAST(") + .Value(value) + .Text(" AS DATETIMEOFFSET)"); + + MsSqlQuery.ExecuteScalar(_output.ToString()).ShouldBe(value); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/MsSql/TextScriptOutputMsSqlTest.cs b/Sources/SqlDatabase.Test/Scripts/MsSql/TextScriptOutputMsSqlTest.cs index f997da61..394eabb5 100644 --- a/Sources/SqlDatabase.Test/Scripts/MsSql/TextScriptOutputMsSqlTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/MsSql/TextScriptOutputMsSqlTest.cs @@ -6,66 +6,66 @@ using Shouldly; using SqlDatabase.TestApi; -namespace SqlDatabase.Scripts.MsSql +namespace SqlDatabase.Scripts.MsSql; + +[TestFixture] +public class TextScriptOutputMsSqlTest { - [TestFixture] - public class TextScriptOutputMsSqlTest - { - private SqlConnection _connection; - private SqlCommand _command; - private Mock _logger; - private Variables _variables; - private TextScript _sut; + private SqlConnection _connection; + private SqlCommand _command; + private Mock _logger; + private Variables _variables; + private TextScript _sut; - private IList _logOutput; + private IList _logOutput; - [SetUp] - public void BeforeEachTest() - { - _variables = new Variables(); - - _logOutput = new List(); - _logger = new Mock(MockBehavior.Strict); - _logger - .Setup(l => l.Indent()) - .Returns((IDisposable)null); - _logger - .Setup(l => l.Info(It.IsAny())) - .Callback(m => - { - Console.WriteLine("Info: {0}", m); - _logOutput.Add(m); - }); - - _sut = new TextScript + [SetUp] + public void BeforeEachTest() + { + _variables = new Variables(); + + _logOutput = new List(); + _logger = new Mock(MockBehavior.Strict); + _logger + .Setup(l => l.Indent()) + .Returns((IDisposable)null); + _logger + .Setup(l => l.Info(It.IsAny())) + .Callback(m => { - TextReader = new MsSqlTextReader() - }; - _connection = MsSqlQuery.Open(); - _command = _connection.CreateCommand(); - } - - [TearDown] - public void AfterEachTest() - { - _command?.Dispose(); - _connection?.Dispose(); - } + Console.WriteLine("Info: {0}", m); + _logOutput.Add(m); + }); - [Test] - public void ExecuteEmpty() + _sut = new TextScript { - _sut.ReadSqlContent = "/* do nothing */".AsFuncStream(); + TextReader = new MsSqlTextReader() + }; + _connection = MsSqlQuery.Open(); + _command = _connection.CreateCommand(); + } + + [TearDown] + public void AfterEachTest() + { + _command?.Dispose(); + _connection?.Dispose(); + } - _sut.Execute(_command, _variables, _logger.Object); + [Test] + public void ExecuteEmpty() + { + _sut.ReadSqlContent = "/* do nothing */".AsFuncStream(); - _logOutput.ShouldBeEmpty(); - } + _sut.Execute(_command, _variables, _logger.Object); - [Test] - public void ExecuteDdlWithReader() - { - _sut.ReadSqlContent = @" + _logOutput.ShouldBeEmpty(); + } + + [Test] + public void ExecuteDdlWithReader() + { + _sut.ReadSqlContent = @" create table dbo.TextScriptIntegrationTest(Id int, Name nvarchar(20)) go insert into dbo.TextScriptIntegrationTest values(1, 'name 1') @@ -74,84 +74,83 @@ insert into dbo.TextScriptIntegrationTest values(2, 'name 2') select * from dbo.TextScriptIntegrationTest go drop table dbo.TextScriptIntegrationTest" - .AsFuncStream(); - - _sut.Execute(_command, _variables, _logger.Object); - - _logOutput.Count.ShouldBe(8); - _logOutput[0].ShouldBe("output: Id; Name"); - _logOutput[1].ShouldBe("row 1"); - _logOutput[2].ShouldBe("Id : 1"); - _logOutput[3].ShouldBe("Name : name 1"); - _logOutput[4].ShouldBe("row 2"); - _logOutput[5].ShouldBe("Id : 2"); - _logOutput[6].ShouldBe("Name : name 2"); - _logOutput[7].ShouldBe("2 rows selected"); - } - - [Test] - public void NoColumnName() - { - _sut.ReadSqlContent = "select 1".AsFuncStream(); + .AsFuncStream(); + + _sut.Execute(_command, _variables, _logger.Object); + + _logOutput.Count.ShouldBe(8); + _logOutput[0].ShouldBe("output: Id; Name"); + _logOutput[1].ShouldBe("row 1"); + _logOutput[2].ShouldBe("Id : 1"); + _logOutput[3].ShouldBe("Name : name 1"); + _logOutput[4].ShouldBe("row 2"); + _logOutput[5].ShouldBe("Id : 2"); + _logOutput[6].ShouldBe("Name : name 2"); + _logOutput[7].ShouldBe("2 rows selected"); + } - _sut.Execute(_command, _variables, _logger.Object); + [Test] + public void NoColumnName() + { + _sut.ReadSqlContent = "select 1".AsFuncStream(); - _logOutput.Count.ShouldBe(4); - _logOutput[0].ShouldBe("output: (no name)"); - _logOutput[1].ShouldBe("row 1"); - _logOutput[2].ShouldBe("(no name) : 1"); - _logOutput[3].ShouldBe("1 row selected"); - } + _sut.Execute(_command, _variables, _logger.Object); - [Test] - public void SelectNull() - { - _sut.ReadSqlContent = "select null".AsFuncStream(); + _logOutput.Count.ShouldBe(4); + _logOutput[0].ShouldBe("output: (no name)"); + _logOutput[1].ShouldBe("row 1"); + _logOutput[2].ShouldBe("(no name) : 1"); + _logOutput[3].ShouldBe("1 row selected"); + } - _sut.Execute(_command, _variables, _logger.Object); + [Test] + public void SelectNull() + { + _sut.ReadSqlContent = "select null".AsFuncStream(); - _logOutput.Count.ShouldBe(4); - _logOutput[0].ShouldBe("output: (no name)"); - _logOutput[1].ShouldBe("row 1"); - _logOutput[2].ShouldBe("(no name) : NULL"); - _logOutput[3].ShouldBe("1 row selected"); - } + _sut.Execute(_command, _variables, _logger.Object); - [Test] - public void TwoSelections() - { - _sut.ReadSqlContent = @" + _logOutput.Count.ShouldBe(4); + _logOutput[0].ShouldBe("output: (no name)"); + _logOutput[1].ShouldBe("row 1"); + _logOutput[2].ShouldBe("(no name) : NULL"); + _logOutput[3].ShouldBe("1 row selected"); + } + + [Test] + public void TwoSelections() + { + _sut.ReadSqlContent = @" select 1 first select 2 second" - .AsFuncStream(); + .AsFuncStream(); - _sut.Execute(_command, _variables, _logger.Object); + _sut.Execute(_command, _variables, _logger.Object); - _logOutput.Count.ShouldBe(9); + _logOutput.Count.ShouldBe(9); - _logOutput[0].ShouldBe("output: first"); - _logOutput[1].ShouldBe("row 1"); - _logOutput[2].ShouldBe("first : 1"); - _logOutput[3].ShouldBe("1 row selected"); + _logOutput[0].ShouldBe("output: first"); + _logOutput[1].ShouldBe("row 1"); + _logOutput[2].ShouldBe("first : 1"); + _logOutput[3].ShouldBe("1 row selected"); - _logOutput[4].ShouldBe(string.Empty); + _logOutput[4].ShouldBe(string.Empty); - _logOutput[5].ShouldBe("output: second"); - _logOutput[6].ShouldBe("row 1"); - _logOutput[7].ShouldBe("second : 2"); - _logOutput[8].ShouldBe("1 row selected"); - } + _logOutput[5].ShouldBe("output: second"); + _logOutput[6].ShouldBe("row 1"); + _logOutput[7].ShouldBe("second : 2"); + _logOutput[8].ShouldBe("1 row selected"); + } - [Test] - public void SelectZeroRowsNull() - { - _sut.ReadSqlContent = "select top 0 null value".AsFuncStream(); + [Test] + public void SelectZeroRowsNull() + { + _sut.ReadSqlContent = "select top 0 null value".AsFuncStream(); - _sut.Execute(_command, _variables, _logger.Object); + _sut.Execute(_command, _variables, _logger.Object); - _logOutput.Count.ShouldBe(2); - _logOutput[0].ShouldBe("output: value"); - _logOutput[1].ShouldBe("0 rows selected"); - } + _logOutput.Count.ShouldBe(2); + _logOutput[0].ShouldBe("output: value"); + _logOutput[1].ShouldBe("0 rows selected"); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/MySql/MySqlDatabaseAdapterTest.cs b/Sources/SqlDatabase.Test/Scripts/MySql/MySqlDatabaseAdapterTest.cs index 3ff8732a..aa8f123c 100644 --- a/Sources/SqlDatabase.Test/Scripts/MySql/MySqlDatabaseAdapterTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/MySql/MySqlDatabaseAdapterTest.cs @@ -7,186 +7,185 @@ using SqlDatabase.Configuration; using SqlDatabase.TestApi; -namespace SqlDatabase.Scripts.MySql +namespace SqlDatabase.Scripts.MySql; + +[TestFixture] +public class MySqlDatabaseAdapterTest { - [TestFixture] - public class MySqlDatabaseAdapterTest - { - private const string ModuleName = "SomeModuleName"; - private const string SelectModuleVersion = "SELECT version FROM version WHERE module_name = '{{ModuleName}}'"; - private const string UpdateModuleVersion = "UPDATE version SET version='{{TargetVersion}}' WHERE module_name = '{{ModuleName}}'"; + private const string ModuleName = "SomeModuleName"; + private const string SelectModuleVersion = "SELECT version FROM version WHERE module_name = '{{ModuleName}}'"; + private const string UpdateModuleVersion = "UPDATE version SET version='{{TargetVersion}}' WHERE module_name = '{{ModuleName}}'"; - private MySqlDatabaseAdapter _sut; - private AppConfiguration _configuration; - private IList _logOutput; + private MySqlDatabaseAdapter _sut; + private AppConfiguration _configuration; + private IList _logOutput; - [SetUp] - public void BeforeEachTest() - { - _logOutput = new List(); - var log = new Mock(MockBehavior.Strict); - log - .Setup(l => l.Info(It.IsAny())) - .Callback(m => - { - Console.WriteLine("Info: {0}", m); - _logOutput.Add(m); - }); + [SetUp] + public void BeforeEachTest() + { + _logOutput = new List(); + var log = new Mock(MockBehavior.Strict); + log + .Setup(l => l.Info(It.IsAny())) + .Callback(m => + { + Console.WriteLine("Info: {0}", m); + _logOutput.Add(m); + }); - _configuration = new AppConfiguration(); + _configuration = new AppConfiguration(); - _sut = new MySqlDatabaseAdapter( - MySqlQuery.ConnectionString, - _configuration, - log.Object); - } + _sut = new MySqlDatabaseAdapter( + MySqlQuery.ConnectionString, + _configuration, + log.Object); + } - [Test] - public void CreateConnectionToTargetDatabase() + [Test] + public void CreateConnectionToTargetDatabase() + { + using (var connection = _sut.CreateConnection(false)) { - using (var connection = _sut.CreateConnection(false)) - { - connection.State.ShouldBe(ConnectionState.Closed); + connection.State.ShouldBe(ConnectionState.Closed); - connection.Open(); - connection.Database.ShouldBe(_sut.DatabaseName); - } + connection.Open(); + connection.Database.ShouldBe(_sut.DatabaseName); } + } - [Test] - public void CreateConnectionToMaster() + [Test] + public void CreateConnectionToMaster() + { + using (var connection = _sut.CreateConnection(true)) { - using (var connection = _sut.CreateConnection(true)) - { - connection.State.ShouldBe(ConnectionState.Closed); + connection.State.ShouldBe(ConnectionState.Closed); - connection.Open(); - connection.Database.ShouldBeNullOrWhiteSpace(); - } + connection.Open(); + connection.Database.ShouldBeNullOrWhiteSpace(); } + } - [Test] - public void GetServerVersionSelectScript() + [Test] + public void GetServerVersionSelectScript() + { + using (var connection = _sut.CreateConnection(false)) + using (var cmd = connection.CreateCommand()) { - using (var connection = _sut.CreateConnection(false)) - using (var cmd = connection.CreateCommand()) - { - cmd.CommandText = _sut.GetServerVersionSelectScript(); - connection.Open(); + cmd.CommandText = _sut.GetServerVersionSelectScript(); + connection.Open(); - var actual = cmd.ExecuteScalar(); - Console.WriteLine(actual); + var actual = cmd.ExecuteScalar(); + Console.WriteLine(actual); - actual.ShouldBeOfType().ShouldNotBeNullOrWhiteSpace(); - } + actual.ShouldBeOfType().ShouldNotBeNullOrWhiteSpace(); } + } - [Test] - [TestCase("sqldatabasetest", true)] - [TestCase("SqlDatabaseTest", true)] - [TestCase("s", false)] - [TestCase(null, true)] - public void GetDatabaseExistsScript(string databaseName, bool expected) + [Test] + [TestCase("sqldatabasetest", true)] + [TestCase("SqlDatabaseTest", true)] + [TestCase("s", false)] + [TestCase(null, true)] + public void GetDatabaseExistsScript(string databaseName, bool expected) + { + using (var connection = _sut.CreateConnection(true)) + using (var cmd = connection.CreateCommand()) { - using (var connection = _sut.CreateConnection(true)) - using (var cmd = connection.CreateCommand()) - { - connection.Open(); + connection.Open(); - cmd.CommandText = _sut.GetDatabaseExistsScript(databaseName ?? _sut.DatabaseName); - var actual = cmd.ExecuteScalar()?.ToString(); + cmd.CommandText = _sut.GetDatabaseExistsScript(databaseName ?? _sut.DatabaseName); + var actual = cmd.ExecuteScalar()?.ToString(); - if (expected) - { - actual.ShouldNotBeNullOrWhiteSpace(); - } - else - { - actual.ShouldBeNullOrEmpty(); - } + if (expected) + { + actual.ShouldNotBeNullOrWhiteSpace(); + } + else + { + actual.ShouldBeNullOrEmpty(); } } + } - [Test] - public void SqlOutputIntoLog() + [Test] + public void SqlOutputIntoLog() + { + using (var connection = _sut.CreateConnection(false)) { - using (var connection = _sut.CreateConnection(false)) - { - connection.Open(); + connection.Open(); - using (var cmd = connection.CreateCommand()) - { - cmd.CommandText = "drop table if exists unknown_table"; - cmd.ExecuteNonQuery(); + using (var cmd = connection.CreateCommand()) + { + cmd.CommandText = "drop table if exists unknown_table"; + cmd.ExecuteNonQuery(); - _logOutput.Count.ShouldBe(1); - _logOutput[0].ShouldBe("Note: Unknown table 'sqldatabasetest.unknown_table'"); - } + _logOutput.Count.ShouldBe(1); + _logOutput[0].ShouldBe("Note: Unknown table 'sqldatabasetest.unknown_table'"); } } + } - [Test] - public void GetSetVersionScriptDefault() - { - _sut.GetVersionSelectScript().ShouldBe(MySqlDatabaseAdapter.DefaultSelectVersion); - _sut.GetVersionUpdateScript().ShouldBe(MySqlDatabaseAdapter.DefaultUpdateVersion); + [Test] + public void GetSetVersionScriptDefault() + { + _sut.GetVersionSelectScript().ShouldBe(MySqlDatabaseAdapter.DefaultSelectVersion); + _sut.GetVersionUpdateScript().ShouldBe(MySqlDatabaseAdapter.DefaultUpdateVersion); - using (var connection = _sut.CreateConnection(false)) + using (var connection = _sut.CreateConnection(false)) + { + connection.Open(); + using (var transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted)) { - connection.Open(); - using (var transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted)) + using (var cmd = connection.CreateCommand()) { - using (var cmd = connection.CreateCommand()) - { - cmd.Transaction = transaction; - - cmd.CommandText = _sut.GetVersionUpdateScript().Replace("{{TargetVersion}}", "new version"); - cmd.ExecuteNonQuery(); + cmd.Transaction = transaction; - cmd.CommandText = _sut.GetVersionSelectScript(); + cmd.CommandText = _sut.GetVersionUpdateScript().Replace("{{TargetVersion}}", "new version"); + cmd.ExecuteNonQuery(); - var actual = cmd.ExecuteScalar(); - actual.ShouldBeOfType().ShouldBe("new version"); - } + cmd.CommandText = _sut.GetVersionSelectScript(); - transaction.Rollback(); + var actual = cmd.ExecuteScalar(); + actual.ShouldBeOfType().ShouldBe("new version"); } + + transaction.Rollback(); } } + } - [Test] - public void GetSetVersionScriptModuleName() - { - _configuration.GetCurrentVersionScript = SelectModuleVersion; - _configuration.SetCurrentVersionScript = UpdateModuleVersion; + [Test] + public void GetSetVersionScriptModuleName() + { + _configuration.GetCurrentVersionScript = SelectModuleVersion; + _configuration.SetCurrentVersionScript = UpdateModuleVersion; - _sut.GetVersionSelectScript().ShouldBe(SelectModuleVersion); - _sut.GetVersionUpdateScript().ShouldBe(UpdateModuleVersion); + _sut.GetVersionSelectScript().ShouldBe(SelectModuleVersion); + _sut.GetVersionUpdateScript().ShouldBe(UpdateModuleVersion); - using (var connection = _sut.CreateConnection(false)) + using (var connection = _sut.CreateConnection(false)) + { + connection.Open(); + using (var transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted)) { - connection.Open(); - using (var transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted)) + using (var cmd = connection.CreateCommand()) { - using (var cmd = connection.CreateCommand()) - { - cmd.Transaction = transaction; + cmd.Transaction = transaction; - cmd.CommandText = _sut - .GetVersionUpdateScript() - .Replace("{{TargetVersion}}", "new version") - .Replace("{{ModuleName}}", ModuleName); - cmd.ExecuteNonQuery(); - - cmd.CommandText = _sut.GetVersionSelectScript().Replace("{{ModuleName}}", ModuleName); + cmd.CommandText = _sut + .GetVersionUpdateScript() + .Replace("{{TargetVersion}}", "new version") + .Replace("{{ModuleName}}", ModuleName); + cmd.ExecuteNonQuery(); - var actual = cmd.ExecuteScalar(); - actual.ShouldBeOfType().ShouldBe("new version"); - } + cmd.CommandText = _sut.GetVersionSelectScript().Replace("{{ModuleName}}", ModuleName); - transaction.Rollback(); + var actual = cmd.ExecuteScalar(); + actual.ShouldBeOfType().ShouldBe("new version"); } + + transaction.Rollback(); } } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/MySql/MySqlTextReaderTest.cs b/Sources/SqlDatabase.Test/Scripts/MySql/MySqlTextReaderTest.cs index 89af105b..ce6f18b4 100644 --- a/Sources/SqlDatabase.Test/Scripts/MySql/MySqlTextReaderTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/MySql/MySqlTextReaderTest.cs @@ -2,23 +2,23 @@ using Shouldly; using SqlDatabase.TestApi; -namespace SqlDatabase.Scripts.MySql +namespace SqlDatabase.Scripts.MySql; + +[TestFixture] +public class MySqlTextReaderTest { - [TestFixture] - public class MySqlTextReaderTest - { - private MySqlTextReader _sut; + private MySqlTextReader _sut; - [SetUp] - public void BeforeEachTest() - { - _sut = new MySqlTextReader(); - } + [SetUp] + public void BeforeEachTest() + { + _sut = new MySqlTextReader(); + } - [Test] - public void ReadFirstBatch() - { - const string Expected = @" + [Test] + public void ReadFirstBatch() + { + const string Expected = @" /* * module dependency: a 2.0 @@ -27,26 +27,25 @@ public void ReadFirstBatch() ; line 2;"; - var actual = _sut.ReadFirstBatch(Expected.AsFuncStream()()); + var actual = _sut.ReadFirstBatch(Expected.AsFuncStream()()); - actual.ShouldBe(@"/* + actual.ShouldBe(@"/* * module dependency: a 2.0 * module dependency: b 1.0 */"); - } + } - [Test] - public void ReadBatches() - { - const string Expected = @" + [Test] + public void ReadBatches() + { + const string Expected = @" line 1; ; line 2;"; - var actual = _sut.ReadBatches(Expected.AsFuncStream()()); + var actual = _sut.ReadBatches(Expected.AsFuncStream()()); - actual.ShouldBe(new[] { Expected }); - } + actual.ShouldBe(new[] { Expected }); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/MySql/MySqlWriterTest.cs b/Sources/SqlDatabase.Test/Scripts/MySql/MySqlWriterTest.cs index 440b3928..7a1e8366 100644 --- a/Sources/SqlDatabase.Test/Scripts/MySql/MySqlWriterTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/MySql/MySqlWriterTest.cs @@ -5,38 +5,37 @@ using Shouldly; using SqlDatabase.TestApi; -namespace SqlDatabase.Scripts.MySql +namespace SqlDatabase.Scripts.MySql; + +[TestFixture] +public class MySqlWriterTest { - [TestFixture] - public class MySqlWriterTest - { - private StringBuilder _output; - private MySqlWriter _sut; + private StringBuilder _output; + private MySqlWriter _sut; - [SetUp] - public void BeforeEachTest() - { - _output = new StringBuilder(); - _sut = new MySqlWriter(new StringWriter(_output)); - } + [SetUp] + public void BeforeEachTest() + { + _output = new StringBuilder(); + _sut = new MySqlWriter(new StringWriter(_output)); + } - [TearDown] - public void AfterEachTest() - { - Console.WriteLine(_output); - } + [TearDown] + public void AfterEachTest() + { + Console.WriteLine(_output); + } - [Test] - public void ValueDateTime() - { - var value = new DateTime(2021, 06, 19, 19, 42, 30, 0); + [Test] + public void ValueDateTime() + { + var value = new DateTime(2021, 06, 19, 19, 42, 30, 0); - _sut - .Text("SELECT CAST(") - .Value(value) - .Text(" AS DATETIME)"); + _sut + .Text("SELECT CAST(") + .Value(value) + .Text(" AS DATETIME)"); - MySqlQuery.ExecuteScalar(_output.ToString()).ShouldBe(value); - } + MySqlQuery.ExecuteScalar(_output.ToString()).ShouldBe(value); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/MySql/TextScriptOutputMySqlTest.cs b/Sources/SqlDatabase.Test/Scripts/MySql/TextScriptOutputMySqlTest.cs index 6e0a7b77..526f57de 100644 --- a/Sources/SqlDatabase.Test/Scripts/MySql/TextScriptOutputMySqlTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/MySql/TextScriptOutputMySqlTest.cs @@ -6,67 +6,67 @@ using Shouldly; using SqlDatabase.TestApi; -namespace SqlDatabase.Scripts.MySql +namespace SqlDatabase.Scripts.MySql; + +[TestFixture] +public class TextScriptOutputMySqlTest { - [TestFixture] - public class TextScriptOutputMySqlTest - { - private MySqlConnection _connection; - private MySqlCommand _command; - private Mock _logger; - private Variables _variables; - private TextScript _sut; + private MySqlConnection _connection; + private MySqlCommand _command; + private Mock _logger; + private Variables _variables; + private TextScript _sut; - private IList _logOutput; + private IList _logOutput; - [SetUp] - public void BeforeEachTest() - { - _variables = new Variables(); - - _logOutput = new List(); - _logger = new Mock(MockBehavior.Strict); - _logger - .Setup(l => l.Indent()) - .Returns((IDisposable)null); - _logger - .Setup(l => l.Info(It.IsAny())) - .Callback(m => - { - Console.WriteLine("Info: {0}", m); - _logOutput.Add(m); - }); - - _sut = new TextScript + [SetUp] + public void BeforeEachTest() + { + _variables = new Variables(); + + _logOutput = new List(); + _logger = new Mock(MockBehavior.Strict); + _logger + .Setup(l => l.Indent()) + .Returns((IDisposable)null); + _logger + .Setup(l => l.Info(It.IsAny())) + .Callback(m => { - TextReader = new MySqlTextReader() - }; + Console.WriteLine("Info: {0}", m); + _logOutput.Add(m); + }); - _connection = MySqlQuery.Open(); - _command = _connection.CreateCommand(); - } - - [TearDown] - public void AfterEachTest() + _sut = new TextScript { - _command?.Dispose(); - _connection?.Dispose(); - } + TextReader = new MySqlTextReader() + }; - [Test] - public void ExecuteEmpty() - { - _sut.ReadSqlContent = "/* do nothing */".AsFuncStream(); + _connection = MySqlQuery.Open(); + _command = _connection.CreateCommand(); + } - _sut.Execute(_command, _variables, _logger.Object); + [TearDown] + public void AfterEachTest() + { + _command?.Dispose(); + _connection?.Dispose(); + } - _logOutput.ShouldBeEmpty(); - } + [Test] + public void ExecuteEmpty() + { + _sut.ReadSqlContent = "/* do nothing */".AsFuncStream(); - [Test] - public void ExecuteDdlWithReader() - { - _sut.ReadSqlContent = @" + _sut.Execute(_command, _variables, _logger.Object); + + _logOutput.ShouldBeEmpty(); + } + + [Test] + public void ExecuteDdlWithReader() + { + _sut.ReadSqlContent = @" create table TextScriptIntegrationTest(id int, name varchar(20)); insert into TextScriptIntegrationTest values(1, 'name 1'); @@ -75,84 +75,83 @@ public void ExecuteDdlWithReader() select * from TextScriptIntegrationTest; drop table TextScriptIntegrationTest;" - .AsFuncStream(); - - _sut.Execute(_command, _variables, _logger.Object); - - _logOutput.Count.ShouldBe(8); - _logOutput[0].ShouldBe("output: id; name"); - _logOutput[1].ShouldBe("row 1"); - _logOutput[2].ShouldBe("id : 1"); - _logOutput[3].ShouldBe("name : name 1"); - _logOutput[4].ShouldBe("row 2"); - _logOutput[5].ShouldBe("id : 2"); - _logOutput[6].ShouldBe("name : name 2"); - _logOutput[7].ShouldBe("2 rows selected"); - } - - [Test] - public void NoColumnName() - { - _sut.ReadSqlContent = "select 1".AsFuncStream(); + .AsFuncStream(); + + _sut.Execute(_command, _variables, _logger.Object); + + _logOutput.Count.ShouldBe(8); + _logOutput[0].ShouldBe("output: id; name"); + _logOutput[1].ShouldBe("row 1"); + _logOutput[2].ShouldBe("id : 1"); + _logOutput[3].ShouldBe("name : name 1"); + _logOutput[4].ShouldBe("row 2"); + _logOutput[5].ShouldBe("id : 2"); + _logOutput[6].ShouldBe("name : name 2"); + _logOutput[7].ShouldBe("2 rows selected"); + } - _sut.Execute(_command, _variables, _logger.Object); + [Test] + public void NoColumnName() + { + _sut.ReadSqlContent = "select 1".AsFuncStream(); - _logOutput.Count.ShouldBe(4); - _logOutput[0].ShouldBe("output: 1"); - _logOutput[1].ShouldBe("row 1"); - _logOutput[2].ShouldBe("1 : 1"); - _logOutput[3].ShouldBe("1 row selected"); - } + _sut.Execute(_command, _variables, _logger.Object); - [Test] - public void SelectNull() - { - _sut.ReadSqlContent = "select null".AsFuncStream(); + _logOutput.Count.ShouldBe(4); + _logOutput[0].ShouldBe("output: 1"); + _logOutput[1].ShouldBe("row 1"); + _logOutput[2].ShouldBe("1 : 1"); + _logOutput[3].ShouldBe("1 row selected"); + } + + [Test] + public void SelectNull() + { + _sut.ReadSqlContent = "select null".AsFuncStream(); - _sut.Execute(_command, _variables, _logger.Object); + _sut.Execute(_command, _variables, _logger.Object); - _logOutput.Count.ShouldBe(4); - _logOutput[0].ShouldBe("output: NULL"); - _logOutput[1].ShouldBe("row 1"); - _logOutput[2].ShouldBe("NULL : NULL"); - _logOutput[3].ShouldBe("1 row selected"); - } + _logOutput.Count.ShouldBe(4); + _logOutput[0].ShouldBe("output: NULL"); + _logOutput[1].ShouldBe("row 1"); + _logOutput[2].ShouldBe("NULL : NULL"); + _logOutput[3].ShouldBe("1 row selected"); + } - [Test] - public void TwoSelections() - { - _sut.ReadSqlContent = @" + [Test] + public void TwoSelections() + { + _sut.ReadSqlContent = @" select 1 first_; select 2 second_;" - .AsFuncStream(); + .AsFuncStream(); - _sut.Execute(_command, _variables, _logger.Object); + _sut.Execute(_command, _variables, _logger.Object); - _logOutput.Count.ShouldBe(9); + _logOutput.Count.ShouldBe(9); - _logOutput[0].ShouldBe("output: first_"); - _logOutput[1].ShouldBe("row 1"); - _logOutput[2].ShouldBe("first_ : 1"); - _logOutput[3].ShouldBe("1 row selected"); + _logOutput[0].ShouldBe("output: first_"); + _logOutput[1].ShouldBe("row 1"); + _logOutput[2].ShouldBe("first_ : 1"); + _logOutput[3].ShouldBe("1 row selected"); - _logOutput[4].ShouldBe(string.Empty); + _logOutput[4].ShouldBe(string.Empty); - _logOutput[5].ShouldBe("output: second_"); - _logOutput[6].ShouldBe("row 1"); - _logOutput[7].ShouldBe("second_ : 2"); - _logOutput[8].ShouldBe("1 row selected"); - } + _logOutput[5].ShouldBe("output: second_"); + _logOutput[6].ShouldBe("row 1"); + _logOutput[7].ShouldBe("second_ : 2"); + _logOutput[8].ShouldBe("1 row selected"); + } - [Test] - public void SelectZeroRowsNull() - { - _sut.ReadSqlContent = "select null value_ limit 0".AsFuncStream(); + [Test] + public void SelectZeroRowsNull() + { + _sut.ReadSqlContent = "select null value_ limit 0".AsFuncStream(); - _sut.Execute(_command, _variables, _logger.Object); + _sut.Execute(_command, _variables, _logger.Object); - _logOutput.Count.ShouldBe(2); - _logOutput[0].ShouldBe("output: value_"); - _logOutput[1].ShouldBe("0 rows selected"); - } + _logOutput.Count.ShouldBe(2); + _logOutput[0].ShouldBe("output: value_"); + _logOutput[1].ShouldBe("0 rows selected"); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/PgSql/PgSqlDatabaseAdapterTest.cs b/Sources/SqlDatabase.Test/Scripts/PgSql/PgSqlDatabaseAdapterTest.cs index 21dfdf74..2a8f41bd 100644 --- a/Sources/SqlDatabase.Test/Scripts/PgSql/PgSqlDatabaseAdapterTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/PgSql/PgSqlDatabaseAdapterTest.cs @@ -7,191 +7,190 @@ using SqlDatabase.Configuration; using SqlDatabase.TestApi; -namespace SqlDatabase.Scripts.PgSql +namespace SqlDatabase.Scripts.PgSql; + +[TestFixture] +public class PgSqlDatabaseAdapterTest { - [TestFixture] - public class PgSqlDatabaseAdapterTest - { - private const string ModuleName = "SomeModuleName"; - private const string SelectModuleVersion = "SELECT version FROM public.version WHERE module_name = '{{ModuleName}}'"; - private const string UpdateModuleVersion = "UPDATE public.version SET version='{{TargetVersion}}' WHERE module_name = '{{ModuleName}}'"; + private const string ModuleName = "SomeModuleName"; + private const string SelectModuleVersion = "SELECT version FROM public.version WHERE module_name = '{{ModuleName}}'"; + private const string UpdateModuleVersion = "UPDATE public.version SET version='{{TargetVersion}}' WHERE module_name = '{{ModuleName}}'"; - private PgSqlDatabaseAdapter _sut; - private AppConfiguration _configuration; - private IList _logOutput; + private PgSqlDatabaseAdapter _sut; + private AppConfiguration _configuration; + private IList _logOutput; - [SetUp] - public void BeforeEachTest() - { - _logOutput = new List(); - var log = new Mock(MockBehavior.Strict); - log - .Setup(l => l.Info(It.IsAny())) - .Callback(m => - { - Console.WriteLine("Info: {0}", m); - _logOutput.Add(m); - }); + [SetUp] + public void BeforeEachTest() + { + _logOutput = new List(); + var log = new Mock(MockBehavior.Strict); + log + .Setup(l => l.Info(It.IsAny())) + .Callback(m => + { + Console.WriteLine("Info: {0}", m); + _logOutput.Add(m); + }); - _configuration = new AppConfiguration(); + _configuration = new AppConfiguration(); - _sut = new PgSqlDatabaseAdapter( - PgSqlQuery.ConnectionString, - _configuration, - log.Object); - } + _sut = new PgSqlDatabaseAdapter( + PgSqlQuery.ConnectionString, + _configuration, + log.Object); + } - [Test] - public void CreateConnectionToTargetDatabase() + [Test] + public void CreateConnectionToTargetDatabase() + { + using (var connection = _sut.CreateConnection(false)) { - using (var connection = _sut.CreateConnection(false)) - { - connection.State.ShouldBe(ConnectionState.Closed); + connection.State.ShouldBe(ConnectionState.Closed); - connection.Open(); - connection.Database.ShouldBe(_sut.DatabaseName); - } + connection.Open(); + connection.Database.ShouldBe(_sut.DatabaseName); } + } - [Test] - public void CreateConnectionToMaster() + [Test] + public void CreateConnectionToMaster() + { + using (var connection = _sut.CreateConnection(true)) { - using (var connection = _sut.CreateConnection(true)) - { - connection.State.ShouldBe(ConnectionState.Closed); + connection.State.ShouldBe(ConnectionState.Closed); - connection.Open(); - connection.Database.ShouldBe("postgres"); - } + connection.Open(); + connection.Database.ShouldBe("postgres"); } + } - [Test] - public void GetServerVersionSelectScript() + [Test] + public void GetServerVersionSelectScript() + { + using (var connection = _sut.CreateConnection(false)) + using (var cmd = connection.CreateCommand()) { - using (var connection = _sut.CreateConnection(false)) - using (var cmd = connection.CreateCommand()) - { - cmd.CommandText = _sut.GetServerVersionSelectScript(); - connection.Open(); + cmd.CommandText = _sut.GetServerVersionSelectScript(); + connection.Open(); - var actual = cmd.ExecuteScalar(); - Console.WriteLine(actual); + var actual = cmd.ExecuteScalar(); + Console.WriteLine(actual); - actual.ShouldBeOfType().ShouldNotBeNullOrWhiteSpace(); - } + actual.ShouldBeOfType().ShouldNotBeNullOrWhiteSpace(); } + } - [Test] - [TestCase("postgres", true)] - [TestCase("POSTGRES", true)] - [TestCase("unknown database", false)] - [TestCase(null, true)] - public void GetDatabaseExistsScript(string databaseName, bool expected) + [Test] + [TestCase("postgres", true)] + [TestCase("POSTGRES", true)] + [TestCase("unknown database", false)] + [TestCase(null, true)] + public void GetDatabaseExistsScript(string databaseName, bool expected) + { + using (var connection = _sut.CreateConnection(true)) + using (var cmd = connection.CreateCommand()) { - using (var connection = _sut.CreateConnection(true)) - using (var cmd = connection.CreateCommand()) - { - connection.Open(); + connection.Open(); - cmd.CommandText = _sut.GetDatabaseExistsScript(databaseName ?? _sut.DatabaseName); - var actual = cmd.ExecuteScalar()?.ToString(); + cmd.CommandText = _sut.GetDatabaseExistsScript(databaseName ?? _sut.DatabaseName); + var actual = cmd.ExecuteScalar()?.ToString(); - if (expected) - { - actual.ShouldNotBeNullOrWhiteSpace(); - } - else - { - actual.ShouldBeNullOrEmpty(); - } + if (expected) + { + actual.ShouldNotBeNullOrWhiteSpace(); + } + else + { + actual.ShouldBeNullOrEmpty(); } } + } - [Test] - public void SqlOutputIntoLog() + [Test] + public void SqlOutputIntoLog() + { + using (var connection = _sut.CreateConnection(false)) { - using (var connection = _sut.CreateConnection(false)) - { - connection.Open(); + connection.Open(); - using (var cmd = connection.CreateCommand()) - { - cmd.CommandText = @" + using (var cmd = connection.CreateCommand()) + { + cmd.CommandText = @" DO $$ BEGIN RAISE NOTICE 'hello'; END $$;"; - cmd.ExecuteNonQuery(); + cmd.ExecuteNonQuery(); - _logOutput.Count.ShouldBe(1); - _logOutput[0].ShouldBe("NOTICE: hello"); - } + _logOutput.Count.ShouldBe(1); + _logOutput[0].ShouldBe("NOTICE: hello"); } } + } - [Test] - public void GetSetVersionScriptDefault() - { - _sut.GetVersionSelectScript().ShouldBe(PgSqlDatabaseAdapter.DefaultSelectVersion); - _sut.GetVersionUpdateScript().ShouldBe(PgSqlDatabaseAdapter.DefaultUpdateVersion); + [Test] + public void GetSetVersionScriptDefault() + { + _sut.GetVersionSelectScript().ShouldBe(PgSqlDatabaseAdapter.DefaultSelectVersion); + _sut.GetVersionUpdateScript().ShouldBe(PgSqlDatabaseAdapter.DefaultUpdateVersion); - using (var connection = _sut.CreateConnection(false)) + using (var connection = _sut.CreateConnection(false)) + { + connection.Open(); + using (var transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted)) { - connection.Open(); - using (var transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted)) + using (var cmd = connection.CreateCommand()) { - using (var cmd = connection.CreateCommand()) - { - cmd.Transaction = transaction; - - cmd.CommandText = _sut.GetVersionUpdateScript().Replace("{{TargetVersion}}", "new version"); - cmd.ExecuteNonQuery(); + cmd.Transaction = transaction; - cmd.CommandText = _sut.GetVersionSelectScript(); + cmd.CommandText = _sut.GetVersionUpdateScript().Replace("{{TargetVersion}}", "new version"); + cmd.ExecuteNonQuery(); - var actual = cmd.ExecuteScalar(); - actual.ShouldBeOfType().ShouldBe("new version"); - } + cmd.CommandText = _sut.GetVersionSelectScript(); - transaction.Rollback(); + var actual = cmd.ExecuteScalar(); + actual.ShouldBeOfType().ShouldBe("new version"); } + + transaction.Rollback(); } } + } - [Test] - public void GetSetVersionScriptModuleName() - { - _configuration.GetCurrentVersionScript = SelectModuleVersion; - _configuration.SetCurrentVersionScript = UpdateModuleVersion; + [Test] + public void GetSetVersionScriptModuleName() + { + _configuration.GetCurrentVersionScript = SelectModuleVersion; + _configuration.SetCurrentVersionScript = UpdateModuleVersion; - _sut.GetVersionSelectScript().ShouldBe(SelectModuleVersion); - _sut.GetVersionUpdateScript().ShouldBe(UpdateModuleVersion); + _sut.GetVersionSelectScript().ShouldBe(SelectModuleVersion); + _sut.GetVersionUpdateScript().ShouldBe(UpdateModuleVersion); - using (var connection = _sut.CreateConnection(false)) + using (var connection = _sut.CreateConnection(false)) + { + connection.Open(); + using (var transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted)) { - connection.Open(); - using (var transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted)) + using (var cmd = connection.CreateCommand()) { - using (var cmd = connection.CreateCommand()) - { - cmd.Transaction = transaction; + cmd.Transaction = transaction; - cmd.CommandText = _sut - .GetVersionUpdateScript() - .Replace("{{TargetVersion}}", "new version") - .Replace("{{ModuleName}}", ModuleName); - cmd.ExecuteNonQuery(); - - cmd.CommandText = _sut.GetVersionSelectScript().Replace("{{ModuleName}}", ModuleName); + cmd.CommandText = _sut + .GetVersionUpdateScript() + .Replace("{{TargetVersion}}", "new version") + .Replace("{{ModuleName}}", ModuleName); + cmd.ExecuteNonQuery(); - var actual = cmd.ExecuteScalar(); - actual.ShouldBeOfType().ShouldBe("new version"); - } + cmd.CommandText = _sut.GetVersionSelectScript().Replace("{{ModuleName}}", ModuleName); - transaction.Rollback(); + var actual = cmd.ExecuteScalar(); + actual.ShouldBeOfType().ShouldBe("new version"); } + + transaction.Rollback(); } } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/PgSql/PgSqlTextReaderTest.cs b/Sources/SqlDatabase.Test/Scripts/PgSql/PgSqlTextReaderTest.cs index 30fcbcc3..6223be85 100644 --- a/Sources/SqlDatabase.Test/Scripts/PgSql/PgSqlTextReaderTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/PgSql/PgSqlTextReaderTest.cs @@ -2,23 +2,23 @@ using Shouldly; using SqlDatabase.TestApi; -namespace SqlDatabase.Scripts.PgSql +namespace SqlDatabase.Scripts.PgSql; + +[TestFixture] +public class PgSqlTextReaderTest { - [TestFixture] - public class PgSqlTextReaderTest - { - private PgSqlTextReader _sut; + private PgSqlTextReader _sut; - [SetUp] - public void BeforeEachTest() - { - _sut = new PgSqlTextReader(); - } + [SetUp] + public void BeforeEachTest() + { + _sut = new PgSqlTextReader(); + } - [Test] - public void ReadFirstBatch() - { - const string Expected = @" + [Test] + public void ReadFirstBatch() + { + const string Expected = @" /* * module dependency: a 2.0 @@ -27,26 +27,25 @@ public void ReadFirstBatch() ; line 2;"; - var actual = _sut.ReadFirstBatch(Expected.AsFuncStream()()); + var actual = _sut.ReadFirstBatch(Expected.AsFuncStream()()); - actual.ShouldBe(@"/* + actual.ShouldBe(@"/* * module dependency: a 2.0 * module dependency: b 1.0 */"); - } + } - [Test] - public void ReadBatches() - { - const string Expected = @" + [Test] + public void ReadBatches() + { + const string Expected = @" line 1; ; line 2;"; - var actual = _sut.ReadBatches(Expected.AsFuncStream()()); + var actual = _sut.ReadBatches(Expected.AsFuncStream()()); - actual.ShouldBe(new[] { Expected }); - } + actual.ShouldBe(new[] { Expected }); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/PgSql/PgSqlWriterTest.cs b/Sources/SqlDatabase.Test/Scripts/PgSql/PgSqlWriterTest.cs index 4f564e4d..b2843eb8 100644 --- a/Sources/SqlDatabase.Test/Scripts/PgSql/PgSqlWriterTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/PgSql/PgSqlWriterTest.cs @@ -9,209 +9,208 @@ using Shouldly; using SqlDatabase.TestApi; -namespace SqlDatabase.Scripts.PgSql +namespace SqlDatabase.Scripts.PgSql; + +[TestFixture] +public class PgSqlWriterTest { - [TestFixture] - public class PgSqlWriterTest - { - private StringBuilder _output; - private PgSqlWriter _sut; + private StringBuilder _output; + private PgSqlWriter _sut; - [SetUp] - public void BeforeEachTest() - { - _output = new StringBuilder(); - _sut = new PgSqlWriter(new StringWriter(_output)); - } + [SetUp] + public void BeforeEachTest() + { + _output = new StringBuilder(); + _sut = new PgSqlWriter(new StringWriter(_output)); + } - [TearDown] - public void AfterEachTest() - { - Console.WriteLine(_output); - } + [TearDown] + public void AfterEachTest() + { + Console.WriteLine(_output); + } - [Test] - public void ValueDateTime() - { - var value = new DateTime(2021, 05, 13, 18, 31, 30, 10); + [Test] + public void ValueDateTime() + { + var value = new DateTime(2021, 05, 13, 18, 31, 30, 10); - _sut - .Text("SELECT ") - .Value(value) - .Text("::timestamp"); + _sut + .Text("SELECT ") + .Value(value) + .Text("::timestamp"); - PgSqlQuery.ExecuteScalar(_output.ToString()).ShouldBe(value); - } + PgSqlQuery.ExecuteScalar(_output.ToString()).ShouldBe(value); + } - [Test] - [TestCase("3.04:05:06")] - [TestCase("04:05:06")] - [TestCase("04:05:06.10")] - public void ValueTimeSpan(string value) - { - var expected = TimeSpan.Parse(value); + [Test] + [TestCase("3.04:05:06")] + [TestCase("04:05:06")] + [TestCase("04:05:06.10")] + public void ValueTimeSpan(string value) + { + var expected = TimeSpan.Parse(value); - _sut - .Text("SELECT ") - .Value(expected) - .Text("::interval"); + _sut + .Text("SELECT ") + .Value(expected) + .Text("::interval"); - PgSqlQuery.ExecuteScalar(_output.ToString()).ShouldBe(expected); - } + PgSqlQuery.ExecuteScalar(_output.ToString()).ShouldBe(expected); + } - [Test] - [TestCase(new byte[0])] - [TestCase(new byte[] { 1, 2, 3 })] - public void ValueByteArray(byte[] value) - { - _sut - .Text("SELECT ") - .Value(value) - .Text("::bytea"); + [Test] + [TestCase(new byte[0])] + [TestCase(new byte[] { 1, 2, 3 })] + public void ValueByteArray(byte[] value) + { + _sut + .Text("SELECT ") + .Value(value) + .Text("::bytea"); - PgSqlQuery.ExecuteScalar(_output.ToString()).ShouldBe(value); - } + PgSqlQuery.ExecuteScalar(_output.ToString()).ShouldBe(value); + } - [Test] - [TestCase("00000000-0000-0000-0000-000000000000")] - [TestCase("f8955206-fa52-4cb3-b269-85ddd831d4d5")] - public void ValueGuid(string value) - { - var expected = Guid.Parse(value); + [Test] + [TestCase("00000000-0000-0000-0000-000000000000")] + [TestCase("f8955206-fa52-4cb3-b269-85ddd831d4d5")] + public void ValueGuid(string value) + { + var expected = Guid.Parse(value); - _sut - .Text("SELECT ") - .Value(expected) - .Text("::uuid"); + _sut + .Text("SELECT ") + .Value(expected) + .Text("::uuid"); - PgSqlQuery.ExecuteScalar(_output.ToString()).ShouldBe(expected); - } + PgSqlQuery.ExecuteScalar(_output.ToString()).ShouldBe(expected); + } - [Test] - [TestCase(new byte[] { 1, 2, 3 })] - [TestCase(new byte[] { 1 })] - [TestCase(new byte[0])] - public void ValueBitArray(byte[] values) - { - var expected = new BitArray(values); + [Test] + [TestCase(new byte[] { 1, 2, 3 })] + [TestCase(new byte[] { 1 })] + [TestCase(new byte[0])] + public void ValueBitArray(byte[] values) + { + var expected = new BitArray(values); - _sut - .Text("SELECT ") - .Value(expected); + _sut + .Text("SELECT ") + .Value(expected); - var actual = PgSqlQuery.ExecuteScalar(_output.ToString()).ShouldBeOfType(); - actual.Count.ShouldBe(expected.Count); + var actual = PgSqlQuery.ExecuteScalar(_output.ToString()).ShouldBeOfType(); + actual.Count.ShouldBe(expected.Count); - for (var i = 0; i < actual.Count; i++) - { - actual[i].ShouldBe(expected[i]); - } + for (var i = 0; i < actual.Count; i++) + { + actual[i].ShouldBe(expected[i]); } + } - [Test] - [TestCase("a fat cat")] - [TestCase("fat & rat")] - public void ValueTsVector(string value) - { - var expected = NpgsqlTsVector.Parse(value); + [Test] + [TestCase("a fat cat")] + [TestCase("fat & rat")] + public void ValueTsVector(string value) + { + var expected = NpgsqlTsVector.Parse(value); - _sut - .Text("SELECT ") - .Value(expected) - .Text("::tsvector"); + _sut + .Text("SELECT ") + .Value(expected) + .Text("::tsvector"); - var actual = PgSqlQuery.ExecuteScalar(_output.ToString()).ShouldBeOfType(); - actual.ShouldBe(expected); - } + var actual = PgSqlQuery.ExecuteScalar(_output.ToString()).ShouldBeOfType(); + actual.ShouldBe(expected); + } - [Test] - [TestCase("fat & rat")] - [TestCase("fat & (rat | cat)")] - public void ValueTsQuery(string value) - { - var expected = PgSqlQuery.ExecuteScalar("SELECT '{0}'::tsquery".FormatWith(value)).ShouldBeAssignableTo(); + [Test] + [TestCase("fat & rat")] + [TestCase("fat & (rat | cat)")] + public void ValueTsQuery(string value) + { + var expected = PgSqlQuery.ExecuteScalar("SELECT '{0}'::tsquery".FormatWith(value)).ShouldBeAssignableTo(); - _sut - .Text("SELECT ") - .Value(NpgsqlTsQuery.Parse(value)) - .Text("::tsquery"); + _sut + .Text("SELECT ") + .Value(NpgsqlTsQuery.Parse(value)) + .Text("::tsquery"); - var actual = PgSqlQuery.ExecuteScalar(_output.ToString()).ShouldBeAssignableTo(); - actual.ToString().ShouldBe(expected.ToString()); - } + var actual = PgSqlQuery.ExecuteScalar(_output.ToString()).ShouldBeAssignableTo(); + actual.ToString().ShouldBe(expected.ToString()); + } - [Test] - [TestCase("integer[]", 1, 2, 3)] - [TestCase("text[]", "fat", "rat")] - public void Value1dArray(string type, params object[] values) - { - _sut - .Text("SELECT ") - .Value(values, type) - .Text("::" + type); + [Test] + [TestCase("integer[]", 1, 2, 3)] + [TestCase("text[]", "fat", "rat")] + public void Value1dArray(string type, params object[] values) + { + _sut + .Text("SELECT ") + .Value(values, type) + .Text("::" + type); - var actual = PgSqlQuery.ExecuteScalar(_output.ToString()); - actual.ShouldBe(values); - } + var actual = PgSqlQuery.ExecuteScalar(_output.ToString()); + actual.ShouldBe(values); + } - [Test] - [TestCase("integer[][]", 1, 2, 3, 4)] - [TestCase("text[][]", "fat", "rat", "cat", "flat")] - public void Value2dArray(string type, object value11, object value12, object value21, object value22) - { - var array = Array.CreateInstance(value11.GetType(), 2, 2); - array.SetValue(value11, 0, 0); - array.SetValue(value12, 0, 1); - array.SetValue(value21, 1, 0); - array.SetValue(value22, 1, 1); - - _sut - .Text("SELECT ") - .Value(array, type) - .Text("::" + type); - - var actual = PgSqlQuery.ExecuteScalar(_output.ToString()); - actual.ShouldBe(array); - } + [Test] + [TestCase("integer[][]", 1, 2, 3, 4)] + [TestCase("text[][]", "fat", "rat", "cat", "flat")] + public void Value2dArray(string type, object value11, object value12, object value21, object value22) + { + var array = Array.CreateInstance(value11.GetType(), 2, 2); + array.SetValue(value11, 0, 0); + array.SetValue(value12, 0, 1); + array.SetValue(value21, 1, 0); + array.SetValue(value22, 1, 1); + + _sut + .Text("SELECT ") + .Value(array, type) + .Text("::" + type); + + var actual = PgSqlQuery.ExecuteScalar(_output.ToString()); + actual.ShouldBe(array); + } - [Test] - public void ValueCompositeType() + [Test] + public void ValueCompositeType() + { + IDictionary expected = new ExpandoObject(); + expected.Add("name", "fuzzy dice"); + expected.Add("supplier_id", 42); + expected.Add("price", 1.99); + + _sut + .Text("SELECT ") + .Value(expected) + .Text("::public.inventory_item"); + + IDictionary actual = PgSqlQuery.ExecuteScalar(_output.ToString()).ShouldBeOfType(); + actual.Keys.ShouldBe(expected.Keys); + foreach (var key in actual.Keys) { - IDictionary expected = new ExpandoObject(); - expected.Add("name", "fuzzy dice"); - expected.Add("supplier_id", 42); - expected.Add("price", 1.99); - - _sut - .Text("SELECT ") - .Value(expected) - .Text("::public.inventory_item"); - - IDictionary actual = PgSqlQuery.ExecuteScalar(_output.ToString()).ShouldBeOfType(); - actual.Keys.ShouldBe(expected.Keys); - foreach (var key in actual.Keys) - { - actual[key].ShouldBe(expected[key]); - } + actual[key].ShouldBe(expected[key]); } + } - [Test] - [TestCase("(20,30)", "[21,30)")] - [TestCase("(20,30]", "[21,31)")] - [TestCase("[20,30)", "[20,30)")] - [TestCase("[20,30]", "[20,31)")] - [TestCase("(,30)", "(,30)")] - [TestCase("(20,)", "[21,)")] - [TestCase("empty", "empty")] - public void ValueRange(string value, string expected) - { - _sut - .Text("SELECT ") - .Value(NpgsqlRange.Parse(value)) - .Text("::int4range"); + [Test] + [TestCase("(20,30)", "[21,30)")] + [TestCase("(20,30]", "[21,31)")] + [TestCase("[20,30)", "[20,30)")] + [TestCase("[20,30]", "[20,31)")] + [TestCase("(,30)", "(,30)")] + [TestCase("(20,)", "[21,)")] + [TestCase("empty", "empty")] + public void ValueRange(string value, string expected) + { + _sut + .Text("SELECT ") + .Value(NpgsqlRange.Parse(value)) + .Text("::int4range"); - var actual = PgSqlQuery.ExecuteScalar(_output.ToString()).ShouldBeOfType>(); - actual.ShouldBeOneOf(NpgsqlRange.Parse(value), NpgsqlRange.Parse(expected)); - } + var actual = PgSqlQuery.ExecuteScalar(_output.ToString()).ShouldBeOfType>(); + actual.ShouldBeOneOf(NpgsqlRange.Parse(value), NpgsqlRange.Parse(expected)); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/PgSql/TextScriptOutputPgSqlTest.cs b/Sources/SqlDatabase.Test/Scripts/PgSql/TextScriptOutputPgSqlTest.cs index e53e276c..9f78b194 100644 --- a/Sources/SqlDatabase.Test/Scripts/PgSql/TextScriptOutputPgSqlTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/PgSql/TextScriptOutputPgSqlTest.cs @@ -6,67 +6,67 @@ using Shouldly; using SqlDatabase.TestApi; -namespace SqlDatabase.Scripts.PgSql +namespace SqlDatabase.Scripts.PgSql; + +[TestFixture] +public class TextScriptOutputPgSqlTest { - [TestFixture] - public class TextScriptOutputPgSqlTest - { - private NpgsqlConnection _connection; - private NpgsqlCommand _command; - private Mock _logger; - private Variables _variables; - private TextScript _sut; + private NpgsqlConnection _connection; + private NpgsqlCommand _command; + private Mock _logger; + private Variables _variables; + private TextScript _sut; - private IList _logOutput; + private IList _logOutput; - [SetUp] - public void BeforeEachTest() - { - _variables = new Variables(); - - _logOutput = new List(); - _logger = new Mock(MockBehavior.Strict); - _logger - .Setup(l => l.Indent()) - .Returns((IDisposable)null); - _logger - .Setup(l => l.Info(It.IsAny())) - .Callback(m => - { - Console.WriteLine("Info: {0}", m); - _logOutput.Add(m); - }); - - _sut = new TextScript + [SetUp] + public void BeforeEachTest() + { + _variables = new Variables(); + + _logOutput = new List(); + _logger = new Mock(MockBehavior.Strict); + _logger + .Setup(l => l.Indent()) + .Returns((IDisposable)null); + _logger + .Setup(l => l.Info(It.IsAny())) + .Callback(m => { - TextReader = new PgSqlTextReader() - }; + Console.WriteLine("Info: {0}", m); + _logOutput.Add(m); + }); - _connection = PgSqlQuery.Open(); - _command = _connection.CreateCommand(); - } - - [TearDown] - public void AfterEachTest() + _sut = new TextScript { - _command?.Dispose(); - _connection?.Dispose(); - } + TextReader = new PgSqlTextReader() + }; - [Test] - public void ExecuteEmpty() - { - _sut.ReadSqlContent = "/* do nothing */".AsFuncStream(); + _connection = PgSqlQuery.Open(); + _command = _connection.CreateCommand(); + } - _sut.Execute(_command, _variables, _logger.Object); + [TearDown] + public void AfterEachTest() + { + _command?.Dispose(); + _connection?.Dispose(); + } - _logOutput.ShouldBeEmpty(); - } + [Test] + public void ExecuteEmpty() + { + _sut.ReadSqlContent = "/* do nothing */".AsFuncStream(); - [Test] - public void ExecuteDdlWithReader() - { - _sut.ReadSqlContent = @" + _sut.Execute(_command, _variables, _logger.Object); + + _logOutput.ShouldBeEmpty(); + } + + [Test] + public void ExecuteDdlWithReader() + { + _sut.ReadSqlContent = @" create table public.TextScriptIntegrationTest(id int, name varchar(20)); insert into public.TextScriptIntegrationTest values(1, 'name 1'); @@ -75,84 +75,83 @@ public void ExecuteDdlWithReader() select * from public.TextScriptIntegrationTest; drop table public.TextScriptIntegrationTest;" - .AsFuncStream(); - - _sut.Execute(_command, _variables, _logger.Object); - - _logOutput.Count.ShouldBe(8); - _logOutput[0].ShouldBe("output: id; name"); - _logOutput[1].ShouldBe("row 1"); - _logOutput[2].ShouldBe("id : 1"); - _logOutput[3].ShouldBe("name : name 1"); - _logOutput[4].ShouldBe("row 2"); - _logOutput[5].ShouldBe("id : 2"); - _logOutput[6].ShouldBe("name : name 2"); - _logOutput[7].ShouldBe("2 rows selected"); - } - - [Test] - public void NoColumnName() - { - _sut.ReadSqlContent = "select 1".AsFuncStream(); + .AsFuncStream(); + + _sut.Execute(_command, _variables, _logger.Object); + + _logOutput.Count.ShouldBe(8); + _logOutput[0].ShouldBe("output: id; name"); + _logOutput[1].ShouldBe("row 1"); + _logOutput[2].ShouldBe("id : 1"); + _logOutput[3].ShouldBe("name : name 1"); + _logOutput[4].ShouldBe("row 2"); + _logOutput[5].ShouldBe("id : 2"); + _logOutput[6].ShouldBe("name : name 2"); + _logOutput[7].ShouldBe("2 rows selected"); + } - _sut.Execute(_command, _variables, _logger.Object); + [Test] + public void NoColumnName() + { + _sut.ReadSqlContent = "select 1".AsFuncStream(); - _logOutput.Count.ShouldBe(4); - _logOutput[0].ShouldBe("output: (no name)"); - _logOutput[1].ShouldBe("row 1"); - _logOutput[2].ShouldBe("(no name) : 1"); - _logOutput[3].ShouldBe("1 row selected"); - } + _sut.Execute(_command, _variables, _logger.Object); - [Test] - public void SelectNull() - { - _sut.ReadSqlContent = "select null".AsFuncStream(); + _logOutput.Count.ShouldBe(4); + _logOutput[0].ShouldBe("output: (no name)"); + _logOutput[1].ShouldBe("row 1"); + _logOutput[2].ShouldBe("(no name) : 1"); + _logOutput[3].ShouldBe("1 row selected"); + } + + [Test] + public void SelectNull() + { + _sut.ReadSqlContent = "select null".AsFuncStream(); - _sut.Execute(_command, _variables, _logger.Object); + _sut.Execute(_command, _variables, _logger.Object); - _logOutput.Count.ShouldBe(4); - _logOutput[0].ShouldBe("output: (no name)"); - _logOutput[1].ShouldBe("row 1"); - _logOutput[2].ShouldBe("(no name) : NULL"); - _logOutput[3].ShouldBe("1 row selected"); - } + _logOutput.Count.ShouldBe(4); + _logOutput[0].ShouldBe("output: (no name)"); + _logOutput[1].ShouldBe("row 1"); + _logOutput[2].ShouldBe("(no name) : NULL"); + _logOutput[3].ShouldBe("1 row selected"); + } - [Test] - public void TwoSelections() - { - _sut.ReadSqlContent = @" + [Test] + public void TwoSelections() + { + _sut.ReadSqlContent = @" select 1 first_; select 2 second_;" - .AsFuncStream(); + .AsFuncStream(); - _sut.Execute(_command, _variables, _logger.Object); + _sut.Execute(_command, _variables, _logger.Object); - _logOutput.Count.ShouldBe(9); + _logOutput.Count.ShouldBe(9); - _logOutput[0].ShouldBe("output: first_"); - _logOutput[1].ShouldBe("row 1"); - _logOutput[2].ShouldBe("first_ : 1"); - _logOutput[3].ShouldBe("1 row selected"); + _logOutput[0].ShouldBe("output: first_"); + _logOutput[1].ShouldBe("row 1"); + _logOutput[2].ShouldBe("first_ : 1"); + _logOutput[3].ShouldBe("1 row selected"); - _logOutput[4].ShouldBe(string.Empty); + _logOutput[4].ShouldBe(string.Empty); - _logOutput[5].ShouldBe("output: second_"); - _logOutput[6].ShouldBe("row 1"); - _logOutput[7].ShouldBe("second_ : 2"); - _logOutput[8].ShouldBe("1 row selected"); - } + _logOutput[5].ShouldBe("output: second_"); + _logOutput[6].ShouldBe("row 1"); + _logOutput[7].ShouldBe("second_ : 2"); + _logOutput[8].ShouldBe("1 row selected"); + } - [Test] - public void SelectZeroRowsNull() - { - _sut.ReadSqlContent = "select null value_ limit 0".AsFuncStream(); + [Test] + public void SelectZeroRowsNull() + { + _sut.ReadSqlContent = "select null value_ limit 0".AsFuncStream(); - _sut.Execute(_command, _variables, _logger.Object); + _sut.Execute(_command, _variables, _logger.Object); - _logOutput.Count.ShouldBe(2); - _logOutput[0].ShouldBe("output: value_"); - _logOutput[1].ShouldBe("0 rows selected"); - } + _logOutput.Count.ShouldBe(2); + _logOutput[0].ShouldBe("output: value_"); + _logOutput[1].ShouldBe("0 rows selected"); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/PowerShellInternal/DiagnosticsToolsTest.cs b/Sources/SqlDatabase.Test/Scripts/PowerShellInternal/DiagnosticsToolsTest.cs index 1397c3e5..228ca6e3 100644 --- a/Sources/SqlDatabase.Test/Scripts/PowerShellInternal/DiagnosticsToolsTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/PowerShellInternal/DiagnosticsToolsTest.cs @@ -4,29 +4,28 @@ using Shouldly; using SqlDatabase.TestApi; -namespace SqlDatabase.Scripts.PowerShellInternal +namespace SqlDatabase.Scripts.PowerShellInternal; + +[TestFixture] +public class DiagnosticsToolsTest { - [TestFixture] - public class DiagnosticsToolsTest + [Test] + public void ParseParentProcessIdLinux() { - [Test] - public void ParseParentProcessIdLinux() + const string Content = "43 (dotnet) R 123 43 1 34816 43 4210688 1660 0 1 0 4 1 0 0 20 0 7 0 11192599 2821132288 5836 18446744073709551615 4194304 4261060 140729390742432 0 0 0 0 4096 17630 0 0 0 17 2 0 0 0 0 0 6360360 6362127 11538432 140729390743290 140729390743313 140729390743313 140729390743528 0"; + using (var file = new TempFile(".txt")) { - const string Content = "43 (dotnet) R 123 43 1 34816 43 4210688 1660 0 1 0 4 1 0 0 20 0 7 0 11192599 2821132288 5836 18446744073709551615 4194304 4261060 140729390742432 0 0 0 0 4096 17630 0 0 0 17 2 0 0 0 0 0 6360360 6362127 11538432 140729390743290 140729390743313 140729390743313 140729390743528 0"; - using (var file = new TempFile(".txt")) - { - File.WriteAllText(file.Location, Content); + File.WriteAllText(file.Location, Content); - DiagnosticsTools.ParseParentProcessIdLinux(file.Location).ShouldBe(123); - } + DiagnosticsTools.ParseParentProcessIdLinux(file.Location).ShouldBe(123); } + } #if !NET472 - [Test] - public void GetParentProcessId() - { - DiagnosticsTools.GetParentProcessId(Process.GetCurrentProcess().Id).ShouldNotBeNull(); - } -#endif + [Test] + public void GetParentProcessId() + { + DiagnosticsTools.GetParentProcessId(Process.GetCurrentProcess().Id).ShouldNotBeNull(); } -} +#endif +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/PowerShellInternal/InstallationSeekerTest.cs b/Sources/SqlDatabase.Test/Scripts/PowerShellInternal/InstallationSeekerTest.cs index cc3f13b8..58351bb4 100644 --- a/Sources/SqlDatabase.Test/Scripts/PowerShellInternal/InstallationSeekerTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/PowerShellInternal/InstallationSeekerTest.cs @@ -7,120 +7,119 @@ using SqlDatabase.TestApi; using InstallationInfo = SqlDatabase.Scripts.PowerShellInternal.InstallationSeeker.InstallationInfo; -namespace SqlDatabase.Scripts.PowerShellInternal +namespace SqlDatabase.Scripts.PowerShellInternal; + +[TestFixture] +public class InstallationSeekerTest { - [TestFixture] - public class InstallationSeekerTest + [Test] + public void TryFindByParentProcess() { - [Test] - public void TryFindByParentProcess() + var actual = InstallationSeeker.TryFindByParentProcess(out var path); + if (actual) { - var actual = InstallationSeeker.TryFindByParentProcess(out var path); - if (actual) - { - Console.WriteLine(path); - } + Console.WriteLine(path); } + } - [Test] - public void TryFindOnDisk() - { + [Test] + public void TryFindOnDisk() + { #if NET472 - Assert.Ignore(); + Assert.Ignore(); #endif - InstallationSeeker.TryFindOnDisk(out var path).ShouldBeTrue(); + InstallationSeeker.TryFindOnDisk(out var path).ShouldBeTrue(); - Console.WriteLine(path); - } + Console.WriteLine(path); + } - [Test] - public void TryGetInfo() + [Test] + public void TryGetInfo() + { + using (var dir = new TempDirectory()) { - using (var dir = new TempDirectory()) - { - var root = Path.Combine(dir.Location, InstallationSeeker.RootAssemblyFileName); + var root = Path.Combine(dir.Location, InstallationSeeker.RootAssemblyFileName); - InstallationSeeker.TryGetInfo(dir.Location, out _).ShouldBeFalse(); + InstallationSeeker.TryGetInfo(dir.Location, out _).ShouldBeFalse(); - File.WriteAllText(Path.Combine(dir.Location, "pwsh.dll"), "dummy"); - File.WriteAllText(root, "dummy"); + File.WriteAllText(Path.Combine(dir.Location, "pwsh.dll"), "dummy"); + File.WriteAllText(root, "dummy"); - InstallationSeeker.TryGetInfo(dir.Location, out _).ShouldBeFalse(); + InstallationSeeker.TryGetInfo(dir.Location, out _).ShouldBeFalse(); - File.Delete(root); - File.Copy(GetType().Assembly.Location, root); + File.Delete(root); + File.Copy(GetType().Assembly.Location, root); - InstallationSeeker.TryGetInfo(dir.Location, out var actual).ShouldBeTrue(); + InstallationSeeker.TryGetInfo(dir.Location, out var actual).ShouldBeTrue(); - actual.Location.ShouldBe(dir.Location); - actual.Version.ShouldBe(GetType().Assembly.GetName().Version); - actual.ProductVersion.ShouldBe(actual.Version.ToString()); - } + actual.Location.ShouldBe(dir.Location); + actual.Version.ShouldBe(GetType().Assembly.GetName().Version); + actual.ProductVersion.ShouldBe(actual.Version.ToString()); } + } - [Test] - [TestCaseSource(nameof(GetSortInstallationInfoCases))] - public void SortInstallationInfo(object item1, object item2) - { - var info1 = (InstallationInfo)item1; - var info2 = (InstallationInfo)item2; - - var comparer = new Mock>(MockBehavior.Strict); - comparer - .Setup(c => c.Equals(It.IsAny(), It.IsAny())) - .Returns((x, y) => - { - return x.Location.Equals(y.Location, StringComparison.OrdinalIgnoreCase) - && x.Version == y.Version - && x.ProductVersion.Equals(y.ProductVersion, StringComparison.OrdinalIgnoreCase); - }); - - var list = new List { info1, info2 }; - list.Sort(); - list[1].ShouldBe(info2, comparer.Object); - - list = new List { info2, info1 }; - list.Sort(); - list[1].ShouldBe(info2, comparer.Object); - } + [Test] + [TestCaseSource(nameof(GetSortInstallationInfoCases))] + public void SortInstallationInfo(object item1, object item2) + { + var info1 = (InstallationInfo)item1; + var info2 = (InstallationInfo)item2; - private static IEnumerable GetSortInstallationInfoCases() - { - yield return new TestCaseData( - new InstallationInfo("path", new Version(1, 0), "1.0"), - new InstallationInfo("path", new Version(2, 0), "2.0")) + var comparer = new Mock>(MockBehavior.Strict); + comparer + .Setup(c => c.Equals(It.IsAny(), It.IsAny())) + .Returns((x, y) => { - TestName = "1.0 vs 2.0" - }; + return x.Location.Equals(y.Location, StringComparison.OrdinalIgnoreCase) + && x.Version == y.Version + && x.ProductVersion.Equals(y.ProductVersion, StringComparison.OrdinalIgnoreCase); + }); + + var list = new List { info1, info2 }; + list.Sort(); + list[1].ShouldBe(info2, comparer.Object); + + list = new List { info2, info1 }; + list.Sort(); + list[1].ShouldBe(info2, comparer.Object); + } - yield return new TestCaseData( - new InstallationInfo("path", new Version(1, 0), "1.0-preview"), - new InstallationInfo("path", new Version(1, 0), "1.0")) - { - TestName = "1.0-preview vs 1.0" - }; + private static IEnumerable GetSortInstallationInfoCases() + { + yield return new TestCaseData( + new InstallationInfo("path", new Version(1, 0), "1.0"), + new InstallationInfo("path", new Version(2, 0), "2.0")) + { + TestName = "1.0 vs 2.0" + }; - yield return new TestCaseData( - new InstallationInfo("path", new Version(1, 0), "1.0-preview.1"), - new InstallationInfo("path", new Version(1, 0), "1.0-preview.1")) - { - TestName = "1.0-preview.1 vs 1.0-preview.2" - }; + yield return new TestCaseData( + new InstallationInfo("path", new Version(1, 0), "1.0-preview"), + new InstallationInfo("path", new Version(1, 0), "1.0")) + { + TestName = "1.0-preview vs 1.0" + }; - yield return new TestCaseData( - new InstallationInfo("path", new Version(1, 0), "1.0-preview.1"), - new InstallationInfo("path", new Version(1, 0), "1.0-preview.2")) - { - TestName = "1.0-preview.1 vs 1.0-preview.2" - }; + yield return new TestCaseData( + new InstallationInfo("path", new Version(1, 0), "1.0-preview.1"), + new InstallationInfo("path", new Version(1, 0), "1.0-preview.1")) + { + TestName = "1.0-preview.1 vs 1.0-preview.2" + }; - yield return new TestCaseData( - new InstallationInfo("path 1", new Version(1, 0), "1.0-preview.1"), - new InstallationInfo("path 2", new Version(1, 0), "1.0-preview.1")) - { - TestName = "1.0-preview.1 vs 1.0-preview.1" - }; - } + yield return new TestCaseData( + new InstallationInfo("path", new Version(1, 0), "1.0-preview.1"), + new InstallationInfo("path", new Version(1, 0), "1.0-preview.2")) + { + TestName = "1.0-preview.1 vs 1.0-preview.2" + }; + + yield return new TestCaseData( + new InstallationInfo("path 1", new Version(1, 0), "1.0-preview.1"), + new InstallationInfo("path 2", new Version(1, 0), "1.0-preview.1")) + { + TestName = "1.0-preview.1 vs 1.0-preview.1" + }; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/PowerShellInternal/PowerShellTest.cs b/Sources/SqlDatabase.Test/Scripts/PowerShellInternal/PowerShellTest.cs index 7c4bcdd7..1043bf25 100644 --- a/Sources/SqlDatabase.Test/Scripts/PowerShellInternal/PowerShellTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/PowerShellInternal/PowerShellTest.cs @@ -7,183 +7,182 @@ using Shouldly; using SqlDatabase.TestApi; -namespace SqlDatabase.Scripts.PowerShellInternal +namespace SqlDatabase.Scripts.PowerShellInternal; + +[TestFixture] +public class PowerShellTest { - [TestFixture] - public class PowerShellTest + private IPowerShellFactory _factory; + private IPowerShell _sut; + private Mock _logger; + private Mock _variables; + private Mock _command; + private List _logOutput; + + [OneTimeSetUp] + public void BeforeAllTests() { - private IPowerShellFactory _factory; - private IPowerShell _sut; - private Mock _logger; - private Mock _variables; - private Mock _command; - private List _logOutput; - - [OneTimeSetUp] - public void BeforeAllTests() - { - _logOutput = new List(); - - _logger = new Mock(MockBehavior.Strict); - _logger - .Setup(l => l.Info(It.IsNotNull())) - .Callback(m => _logOutput.Add("info: " + m)); - _logger - .Setup(l => l.Error(It.IsNotNull())) - .Callback(m => _logOutput.Add("error: " + m)); - _logger - .Setup(l => l.Indent()) - .Returns((IDisposable)null); - - _factory = TestPowerShellHost.GetOrCreateFactory(); - } + _logOutput = new List(); + + _logger = new Mock(MockBehavior.Strict); + _logger + .Setup(l => l.Info(It.IsNotNull())) + .Callback(m => _logOutput.Add("info: " + m)); + _logger + .Setup(l => l.Error(It.IsNotNull())) + .Callback(m => _logOutput.Add("error: " + m)); + _logger + .Setup(l => l.Indent()) + .Returns((IDisposable)null); + + _factory = TestPowerShellHost.GetOrCreateFactory(); + } - [SetUp] - public void BeforeEachTest() - { - _logOutput.Clear(); + [SetUp] + public void BeforeEachTest() + { + _logOutput.Clear(); - _variables = new Mock(MockBehavior.Strict); - _command = new Mock(MockBehavior.Strict); + _variables = new Mock(MockBehavior.Strict); + _command = new Mock(MockBehavior.Strict); - _sut = _factory.Create(); - } + _sut = _factory.Create(); + } - [TearDown] - public void AfterEachTest() + [TearDown] + public void AfterEachTest() + { + foreach (var line in _logOutput) { - foreach (var line in _logOutput) - { - Console.WriteLine(line); - } + Console.WriteLine(line); } + } - [Test] - [TestCase("PowerShellTest.ExecuteWhatIfInvoke.ps1", true)] - [TestCase("PowerShellTest.ExecuteWhatIfIgnore.ps1", false)] - public void SupportsShouldProcess(string scriptName, bool expected) - { - var script = LoadScript(scriptName); - - _sut.SupportsShouldProcess(script).ShouldBe(expected); - } + [Test] + [TestCase("PowerShellTest.ExecuteWhatIfInvoke.ps1", true)] + [TestCase("PowerShellTest.ExecuteWhatIfIgnore.ps1", false)] + public void SupportsShouldProcess(string scriptName, bool expected) + { + var script = LoadScript(scriptName); - [Test] - public void HandleOutput() - { - var script = LoadScript("PowerShellTest.HandleOutput.ps1"); - InvokeExecute(script, false); + _sut.SupportsShouldProcess(script).ShouldBe(expected); + } - _logOutput.Count.ShouldBe(3); - _logOutput[0].ShouldBe("info: hello from Write-Host"); - _logOutput[1].ShouldBe("info: hello from Write-Information"); - _logOutput[2].ShouldBe("info: hello from Write-Warning"); - } + [Test] + public void HandleOutput() + { + var script = LoadScript("PowerShellTest.HandleOutput.ps1"); + InvokeExecute(script, false); - [Test] - public void HandleWriteError() - { - var script = LoadScript("PowerShellTest.HandleWriteError.ps1"); - Assert.Throws(() => InvokeExecute(script, false)); + _logOutput.Count.ShouldBe(3); + _logOutput[0].ShouldBe("info: hello from Write-Host"); + _logOutput[1].ShouldBe("info: hello from Write-Information"); + _logOutput[2].ShouldBe("info: hello from Write-Warning"); + } - _logOutput.Count.ShouldBe(1); - _logOutput[0].ShouldBe("error: hello from Write-Error"); - } + [Test] + public void HandleWriteError() + { + var script = LoadScript("PowerShellTest.HandleWriteError.ps1"); + Assert.Throws(() => InvokeExecute(script, false)); - [Test] - public void HandleThrow() - { - var script = LoadScript("PowerShellTest.HandleThrow.ps1"); + _logOutput.Count.ShouldBe(1); + _logOutput[0].ShouldBe("error: hello from Write-Error"); + } - var failed = false; - try - { - InvokeExecute(script, false); - } - catch (Exception ex) - { - failed = true; - Console.WriteLine(ex); - } + [Test] + public void HandleThrow() + { + var script = LoadScript("PowerShellTest.HandleThrow.ps1"); - failed.ShouldBeTrue(); - _logOutput.ShouldBeEmpty(); + var failed = false; + try + { + InvokeExecute(script, false); } - - [Test] - public void ParametersBinding() + catch (Exception ex) { - _command - .SetupProperty(c => c.CommandText); - _command - .Setup(c => c.ExecuteNonQuery()) - .Returns(0); + failed = true; + Console.WriteLine(ex); + } - _variables - .Setup(v => v.GetValue("DatabaseName")) - .Returns("test-db"); + failed.ShouldBeTrue(); + _logOutput.ShouldBeEmpty(); + } - var script = LoadScript("PowerShellTest.ParametersBinding.ps1"); + [Test] + public void ParametersBinding() + { + _command + .SetupProperty(c => c.CommandText); + _command + .Setup(c => c.ExecuteNonQuery()) + .Returns(0); - InvokeExecute(script, false); + _variables + .Setup(v => v.GetValue("DatabaseName")) + .Returns("test-db"); - _command.Object.CommandText.ShouldBe("database name is test-db"); - _command.VerifyAll(); - } + var script = LoadScript("PowerShellTest.ParametersBinding.ps1"); - [Test] - public void ExecuteInvalidScript() - { - Assert.Throws(() => InvokeExecute("bla bla", false)); + InvokeExecute(script, false); - _logOutput.Count.ShouldBe(1); - _logOutput[0].ShouldStartWith("error: The term 'bla' is not recognized"); - } + _command.Object.CommandText.ShouldBe("database name is test-db"); + _command.VerifyAll(); + } - [Test] - public void ExecuteEmptyScript() - { - InvokeExecute(string.Empty, false); + [Test] + public void ExecuteInvalidScript() + { + Assert.Throws(() => InvokeExecute("bla bla", false)); - _logOutput.ShouldBeEmpty(); - } + _logOutput.Count.ShouldBe(1); + _logOutput[0].ShouldStartWith("error: The term 'bla' is not recognized"); + } - [Test] - public void ExecuteWhatIfInvoke() - { - var script = LoadScript("PowerShellTest.ExecuteWhatIfInvoke.ps1"); + [Test] + public void ExecuteEmptyScript() + { + InvokeExecute(string.Empty, false); - InvokeExecute(script, true); + _logOutput.ShouldBeEmpty(); + } - _logOutput.Count.ShouldBe(1); - _logOutput[0].ShouldBe("info: WhatIf accepted"); - } + [Test] + public void ExecuteWhatIfInvoke() + { + var script = LoadScript("PowerShellTest.ExecuteWhatIfInvoke.ps1"); - private static string LoadScript(string name) - { - var anchor = typeof(PowerShellTest); - using (var stream = anchor.Assembly.GetManifestResourceStream(anchor, name)) - { - stream.ShouldNotBeNull(name); + InvokeExecute(script, true); - using (var reader = new StreamReader(stream)) - { - return reader.ReadToEnd(); - } - } - } + _logOutput.Count.ShouldBe(1); + _logOutput[0].ShouldBe("info: WhatIf accepted"); + } - private void InvokeExecute(string script, bool whatIf) + private static string LoadScript(string name) + { + var anchor = typeof(PowerShellTest); + using (var stream = anchor.Assembly.GetManifestResourceStream(anchor, name)) { - var parameters = new KeyValuePair[2 + (whatIf ? 1 : 0)]; - parameters[0] = new KeyValuePair(PowerShellScript.ParameterCommand, _command.Object); - parameters[1] = new KeyValuePair(PowerShellScript.ParameterVariables, new VariablesProxy(_variables.Object)); - if (whatIf) + stream.ShouldNotBeNull(name); + + using (var reader = new StreamReader(stream)) { - parameters[2] = new KeyValuePair(PowerShellScript.ParameterWhatIf, null); + return reader.ReadToEnd(); } + } + } - _sut.Invoke(script, _logger.Object, parameters); + private void InvokeExecute(string script, bool whatIf) + { + var parameters = new KeyValuePair[2 + (whatIf ? 1 : 0)]; + parameters[0] = new KeyValuePair(PowerShellScript.ParameterCommand, _command.Object); + parameters[1] = new KeyValuePair(PowerShellScript.ParameterVariables, new VariablesProxy(_variables.Object)); + if (whatIf) + { + parameters[2] = new KeyValuePair(PowerShellScript.ParameterWhatIf, null); } + + _sut.Invoke(script, _logger.Object, parameters); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/PowerShellScriptTest.cs b/Sources/SqlDatabase.Test/Scripts/PowerShellScriptTest.cs index 448fd71b..df954346 100644 --- a/Sources/SqlDatabase.Test/Scripts/PowerShellScriptTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/PowerShellScriptTest.cs @@ -8,126 +8,125 @@ using Shouldly; using SqlDatabase.Scripts.PowerShellInternal; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +[TestFixture] +public class PowerShellScriptTest { - [TestFixture] - public class PowerShellScriptTest + private PowerShellScript _sut; + private Mock _powerShell; + private Mock _variables; + private Mock _command; + private Mock _log; + + [SetUp] + public void BeforeEachTest() { - private PowerShellScript _sut; - private Mock _powerShell; - private Mock _variables; - private Mock _command; - private Mock _log; - - [SetUp] - public void BeforeEachTest() + _variables = new Mock(MockBehavior.Strict); + _command = new Mock(MockBehavior.Strict); + _powerShell = new Mock(MockBehavior.Strict); + _log = new Mock(MockBehavior.Strict); + + var factory = new Mock(MockBehavior.Strict); + factory + .Setup(f => f.Create()) + .Returns(_powerShell.Object); + + _sut = new PowerShellScript { - _variables = new Mock(MockBehavior.Strict); - _command = new Mock(MockBehavior.Strict); - _powerShell = new Mock(MockBehavior.Strict); - _log = new Mock(MockBehavior.Strict); + PowerShellFactory = factory.Object + }; + } + + [Test] + public void Execute() + { + _powerShell + .Setup(p => p.Invoke("script content", _log.Object, It.IsNotNull[]>())) + .Callback[]>((_, _, parameters) => + { + parameters.Length.ShouldBe(2); + parameters[0].Key.ShouldBe(PowerShellScript.ParameterCommand); + parameters[0].Value.ShouldBe(_command.Object); + parameters[1].Key.ShouldBe(PowerShellScript.ParameterVariables); + parameters[1].Value.ShouldBeOfType(); + }); - var factory = new Mock(MockBehavior.Strict); - factory - .Setup(f => f.Create()) - .Returns(_powerShell.Object); + _sut.ReadScriptContent = () => new MemoryStream(Encoding.UTF8.GetBytes("script content")); - _sut = new PowerShellScript + _sut.Execute(_command.Object, _variables.Object, _log.Object); + + _powerShell.VerifyAll(); + } + + [Test] + public void ExecuteWhatIf() + { + _powerShell + .Setup(p => p.SupportsShouldProcess("script content")) + .Returns(true); + _powerShell + .Setup(p => p.Invoke("script content", _log.Object, It.IsNotNull[]>())) + .Callback[]>((_, _, parameters) => { - PowerShellFactory = factory.Object - }; - } + parameters.Length.ShouldBe(3); + parameters[0].Key.ShouldBe(PowerShellScript.ParameterCommand); + parameters[0].Value.ShouldBeNull(); + parameters[1].Key.ShouldBe(PowerShellScript.ParameterVariables); + parameters[1].Value.ShouldBeOfType(); + parameters[2].Key.ShouldBe(PowerShellScript.ParameterWhatIf); + parameters[2].Value.ShouldBeNull(); + }); - [Test] - public void Execute() - { - _powerShell - .Setup(p => p.Invoke("script content", _log.Object, It.IsNotNull[]>())) - .Callback[]>((_, _, parameters) => - { - parameters.Length.ShouldBe(2); - parameters[0].Key.ShouldBe(PowerShellScript.ParameterCommand); - parameters[0].Value.ShouldBe(_command.Object); - parameters[1].Key.ShouldBe(PowerShellScript.ParameterVariables); - parameters[1].Value.ShouldBeOfType(); - }); - - _sut.ReadScriptContent = () => new MemoryStream(Encoding.UTF8.GetBytes("script content")); - - _sut.Execute(_command.Object, _variables.Object, _log.Object); - - _powerShell.VerifyAll(); - } - - [Test] - public void ExecuteWhatIf() - { - _powerShell - .Setup(p => p.SupportsShouldProcess("script content")) - .Returns(true); - _powerShell - .Setup(p => p.Invoke("script content", _log.Object, It.IsNotNull[]>())) - .Callback[]>((_, _, parameters) => - { - parameters.Length.ShouldBe(3); - parameters[0].Key.ShouldBe(PowerShellScript.ParameterCommand); - parameters[0].Value.ShouldBeNull(); - parameters[1].Key.ShouldBe(PowerShellScript.ParameterVariables); - parameters[1].Value.ShouldBeOfType(); - parameters[2].Key.ShouldBe(PowerShellScript.ParameterWhatIf); - parameters[2].Value.ShouldBeNull(); - }); - - _sut.ReadScriptContent = () => new MemoryStream(Encoding.UTF8.GetBytes("script content")); - - _sut.Execute(null, _variables.Object, _log.Object); - - _powerShell.VerifyAll(); - } - - [Test] - public void ExecuteIgnoreWhatIf() - { - _powerShell - .Setup(p => p.SupportsShouldProcess("script content")) - .Returns(false); - _log - .Setup(l => l.Info(It.IsNotNull())); + _sut.ReadScriptContent = () => new MemoryStream(Encoding.UTF8.GetBytes("script content")); - _sut.ReadScriptContent = () => new MemoryStream(Encoding.UTF8.GetBytes("script content")); + _sut.Execute(null, _variables.Object, _log.Object); - _sut.Execute(null, _variables.Object, _log.Object); + _powerShell.VerifyAll(); + } - _powerShell.VerifyAll(); - _log.VerifyAll(); - } + [Test] + public void ExecuteIgnoreWhatIf() + { + _powerShell + .Setup(p => p.SupportsShouldProcess("script content")) + .Returns(false); + _log + .Setup(l => l.Info(It.IsNotNull())); - [Test] - public void GetDependencies() - { - var description = Encoding.Default.GetBytes(@" + _sut.ReadScriptContent = () => new MemoryStream(Encoding.UTF8.GetBytes("script content")); + + _sut.Execute(null, _variables.Object, _log.Object); + + _powerShell.VerifyAll(); + _log.VerifyAll(); + } + + [Test] + public void GetDependencies() + { + var description = Encoding.Default.GetBytes(@" -- module dependency: a 1.0 -- module dependency: b 1.0"); - _sut.ReadDescriptionContent = () => new MemoryStream(description); - - var actual = _sut.GetDependencies(); + _sut.ReadDescriptionContent = () => new MemoryStream(description); - actual.ShouldBe(new[] - { - new ScriptDependency("a", new Version("1.0")), - new ScriptDependency("b", new Version("1.0")) - }); - } + var actual = _sut.GetDependencies(); - [Test] - public void GetDependenciesNoDescription() + actual.ShouldBe(new[] { - _sut.ReadDescriptionContent = () => null; + new ScriptDependency("a", new Version("1.0")), + new ScriptDependency("b", new Version("1.0")) + }); + } + + [Test] + public void GetDependenciesNoDescription() + { + _sut.ReadDescriptionContent = () => null; - var actual = _sut.GetDependencies(); + var actual = _sut.GetDependencies(); - actual.ShouldBeEmpty(); - } + actual.ShouldBeEmpty(); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/ScriptFactoryTest.cs b/Sources/SqlDatabase.Test/Scripts/ScriptFactoryTest.cs index 709a8166..fd736588 100644 --- a/Sources/SqlDatabase.Test/Scripts/ScriptFactoryTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/ScriptFactoryTest.cs @@ -6,121 +6,120 @@ using SqlDatabase.Configuration; using SqlDatabase.TestApi; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +[TestFixture] +public class ScriptFactoryTest { - [TestFixture] - public class ScriptFactoryTest + private ScriptFactory _sut; + private Mock _powerShellFactory; + private AssemblyScriptConfiguration _configuration; + private Mock _textReader; + + [SetUp] + public void BeforeEachTest() { - private ScriptFactory _sut; - private Mock _powerShellFactory; - private AssemblyScriptConfiguration _configuration; - private Mock _textReader; + _configuration = new AssemblyScriptConfiguration(); + _powerShellFactory = new Mock(MockBehavior.Strict); + _textReader = new Mock(MockBehavior.Strict); - [SetUp] - public void BeforeEachTest() - { - _configuration = new AssemblyScriptConfiguration(); - _powerShellFactory = new Mock(MockBehavior.Strict); - _textReader = new Mock(MockBehavior.Strict); - - _sut = new ScriptFactory - { - AssemblyScriptConfiguration = _configuration, - PowerShellFactory = _powerShellFactory.Object, - TextReader = _textReader.Object - }; - } - - [Test] - public void FromSqlFile() + _sut = new ScriptFactory { - var file = FileFactory.File("11.sql", "some script"); + AssemblyScriptConfiguration = _configuration, + PowerShellFactory = _powerShellFactory.Object, + TextReader = _textReader.Object + }; + } - _sut.IsSupported(file.Name).ShouldBeTrue(); + [Test] + public void FromSqlFile() + { + var file = FileFactory.File("11.sql", "some script"); - var script = _sut.FromFile(file).ShouldBeOfType(); + _sut.IsSupported(file.Name).ShouldBeTrue(); - script.DisplayName.ShouldBe("11.sql"); - script.TextReader.ShouldBe(_textReader.Object); - new StreamReader(script.ReadSqlContent()).ReadToEnd().ShouldBe("some script"); - } + var script = _sut.FromFile(file).ShouldBeOfType(); - [Test] - public void FromDllFile() - { - var file = FileFactory.File( - "11.dll", - new byte[] { 1, 2, 3 }, - FileFactory.Folder("name", FileFactory.File("11.txt", "3, 2, 1"))); + script.DisplayName.ShouldBe("11.sql"); + script.TextReader.ShouldBe(_textReader.Object); + new StreamReader(script.ReadSqlContent()).ReadToEnd().ShouldBe("some script"); + } - _sut.IsSupported(file.Name).ShouldBeTrue(); + [Test] + public void FromDllFile() + { + var file = FileFactory.File( + "11.dll", + new byte[] { 1, 2, 3 }, + FileFactory.Folder("name", FileFactory.File("11.txt", "3, 2, 1"))); - var script = _sut.FromFile(file).ShouldBeOfType(); + _sut.IsSupported(file.Name).ShouldBeTrue(); - script.DisplayName.ShouldBe("11.dll"); - script.Configuration.ShouldBe(_configuration); - script.ReadAssemblyContent().ShouldBe(new byte[] { 1, 2, 3 }); - new StreamReader(script.ReadDescriptionContent()).ReadToEnd().ShouldBe("3, 2, 1"); - } + var script = _sut.FromFile(file).ShouldBeOfType(); - [Test] - public void FromExeFile() - { - var file = FileFactory.File( - "11.exe", - new byte[] { 1, 2, 3 }, - FileFactory.Folder("name")); + script.DisplayName.ShouldBe("11.dll"); + script.Configuration.ShouldBe(_configuration); + script.ReadAssemblyContent().ShouldBe(new byte[] { 1, 2, 3 }); + new StreamReader(script.ReadDescriptionContent()).ReadToEnd().ShouldBe("3, 2, 1"); + } - _sut.IsSupported(file.Name).ShouldBeTrue(); + [Test] + public void FromExeFile() + { + var file = FileFactory.File( + "11.exe", + new byte[] { 1, 2, 3 }, + FileFactory.Folder("name")); - var script = _sut.FromFile(file).ShouldBeOfType(); + _sut.IsSupported(file.Name).ShouldBeTrue(); - script.DisplayName.ShouldBe("11.exe"); - script.Configuration.ShouldBe(_configuration); - script.ReadAssemblyContent().ShouldBe(new byte[] { 1, 2, 3 }); - script.ReadDescriptionContent().ShouldBeNull(); - } + var script = _sut.FromFile(file).ShouldBeOfType(); - [Test] - public void FromPs1File() - { - var file = FileFactory.File( - "11.ps1", - "some script", - FileFactory.Folder("name", FileFactory.File("11.txt", "3, 2, 1"))); + script.DisplayName.ShouldBe("11.exe"); + script.Configuration.ShouldBe(_configuration); + script.ReadAssemblyContent().ShouldBe(new byte[] { 1, 2, 3 }); + script.ReadDescriptionContent().ShouldBeNull(); + } - _powerShellFactory - .Setup(f => f.Request()); + [Test] + public void FromPs1File() + { + var file = FileFactory.File( + "11.ps1", + "some script", + FileFactory.Folder("name", FileFactory.File("11.txt", "3, 2, 1"))); - _sut.IsSupported(file.Name).ShouldBeTrue(); + _powerShellFactory + .Setup(f => f.Request()); - var script = _sut.FromFile(file).ShouldBeOfType(); + _sut.IsSupported(file.Name).ShouldBeTrue(); - script.PowerShellFactory.ShouldBe(_powerShellFactory.Object); - script.DisplayName.ShouldBe("11.ps1"); - new StreamReader(script.ReadScriptContent()).ReadToEnd().ShouldBe("some script"); - new StreamReader(script.ReadDescriptionContent()).ReadToEnd().ShouldBe("3, 2, 1"); - _powerShellFactory.VerifyAll(); - } + var script = _sut.FromFile(file).ShouldBeOfType(); - [Test] - public void FromPs1FileNotSupported() - { - var file = FileFactory.File("11.ps1", "some script"); - _sut.PowerShellFactory = null; + script.PowerShellFactory.ShouldBe(_powerShellFactory.Object); + script.DisplayName.ShouldBe("11.ps1"); + new StreamReader(script.ReadScriptContent()).ReadToEnd().ShouldBe("some script"); + new StreamReader(script.ReadDescriptionContent()).ReadToEnd().ShouldBe("3, 2, 1"); + _powerShellFactory.VerifyAll(); + } - _sut.IsSupported(file.Name).ShouldBeFalse(); + [Test] + public void FromPs1FileNotSupported() + { + var file = FileFactory.File("11.ps1", "some script"); + _sut.PowerShellFactory = null; - Assert.Throws(() => _sut.FromFile(file)); - } + _sut.IsSupported(file.Name).ShouldBeFalse(); - [Test] - public void FromFileNotSupported() - { - var file = FileFactory.File("11.txt"); + Assert.Throws(() => _sut.FromFile(file)); + } + + [Test] + public void FromFileNotSupported() + { + var file = FileFactory.File("11.txt"); - _sut.IsSupported(file.Name).ShouldBeFalse(); - Assert.Throws(() => _sut.FromFile(file)); - } + _sut.IsSupported(file.Name).ShouldBeFalse(); + Assert.Throws(() => _sut.FromFile(file)); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/SqlScriptVariableParserTest.cs b/Sources/SqlDatabase.Test/Scripts/SqlScriptVariableParserTest.cs index d997cd79..31f6b67e 100644 --- a/Sources/SqlDatabase.Test/Scripts/SqlScriptVariableParserTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/SqlScriptVariableParserTest.cs @@ -3,133 +3,132 @@ using NUnit.Framework; using Shouldly; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +[TestFixture] +public class SqlScriptVariableParserTest { - [TestFixture] - public class SqlScriptVariableParserTest + private Mock _variables; + private SqlScriptVariableParser _sut; + + [SetUp] + public void BeforeEachTest() { - private Mock _variables; - private SqlScriptVariableParser _sut; - - [SetUp] - public void BeforeEachTest() - { - _variables = new Mock(MockBehavior.Strict); - - _sut = new SqlScriptVariableParser(_variables.Object); - } - - [Test] - [TestCase("_'{{Value}}'_", "x", "_'x'_")] - [TestCase("{{Value}}", "x", "x")] - [TestCase("{{ValuE}}", "x", "x")] - [TestCase("{{Value}}+{{Value}}", "x", "x+x")] - [TestCase("{{Value}}\r\n{{Value}}", "x", "x\r\nx")] - public void ApplyVariables(string sql, string value, string expected) - { - _variables - .Setup(v => v.GetValue(It.IsAny())) - .Returns(name => + _variables = new Mock(MockBehavior.Strict); + + _sut = new SqlScriptVariableParser(_variables.Object); + } + + [Test] + [TestCase("_'{{Value}}'_", "x", "_'x'_")] + [TestCase("{{Value}}", "x", "x")] + [TestCase("{{ValuE}}", "x", "x")] + [TestCase("{{Value}}+{{Value}}", "x", "x+x")] + [TestCase("{{Value}}\r\n{{Value}}", "x", "x\r\nx")] + public void ApplyVariables(string sql, string value, string expected) + { + _variables + .Setup(v => v.GetValue(It.IsAny())) + .Returns(name => + { + if ("value".Equals(name, StringComparison.OrdinalIgnoreCase)) { - if ("value".Equals(name, StringComparison.OrdinalIgnoreCase)) - { - return value; - } - - return null; - }); - - var actual = _sut.ApplyVariables(sql); - - actual.ShouldBe(expected); - _sut.ValueByName.Count.ShouldBe(1); - _sut.ValueByName["value"].ShouldNotBeNull(); - } - - [Test] - [TestCase("[$(value)]", "some name", "[some name]")] - [TestCase("$(Value)+$(Value)", "x", "x+x")] - public void ApplySqlCmdVariables(string sql, string value, string expected) - { - _variables - .Setup(v => v.GetValue(It.IsAny())) - .Returns(name => + return value; + } + + return null; + }); + + var actual = _sut.ApplyVariables(sql); + + actual.ShouldBe(expected); + _sut.ValueByName.Count.ShouldBe(1); + _sut.ValueByName["value"].ShouldNotBeNull(); + } + + [Test] + [TestCase("[$(value)]", "some name", "[some name]")] + [TestCase("$(Value)+$(Value)", "x", "x+x")] + public void ApplySqlCmdVariables(string sql, string value, string expected) + { + _variables + .Setup(v => v.GetValue(It.IsAny())) + .Returns(name => + { + if ("value".Equals(name, StringComparison.OrdinalIgnoreCase)) { - if ("value".Equals(name, StringComparison.OrdinalIgnoreCase)) - { - return value; - } - - return null; - }); - - var actual = _sut.ApplyVariables(sql); - - actual.ShouldBe(expected); - _sut.ValueByName.Count.ShouldBe(1); - _sut.ValueByName["value"].ShouldNotBeNull(); - } - - [Test] - [TestCase("{{Value}}", "value", "123")] - [TestCase("{{Value1}}", "value1", "123")] - [TestCase("{{Value_1}}", "value_1", "123")] - public void ApplyVariablesVariableNames(string sql, string name, string expected) - { - _variables - .Setup(v => v.GetValue(It.IsAny())) - .Returns(n => + return value; + } + + return null; + }); + + var actual = _sut.ApplyVariables(sql); + + actual.ShouldBe(expected); + _sut.ValueByName.Count.ShouldBe(1); + _sut.ValueByName["value"].ShouldNotBeNull(); + } + + [Test] + [TestCase("{{Value}}", "value", "123")] + [TestCase("{{Value1}}", "value1", "123")] + [TestCase("{{Value_1}}", "value_1", "123")] + public void ApplyVariablesVariableNames(string sql, string name, string expected) + { + _variables + .Setup(v => v.GetValue(It.IsAny())) + .Returns(n => + { + if (name.Equals(n, StringComparison.OrdinalIgnoreCase)) { - if (name.Equals(n, StringComparison.OrdinalIgnoreCase)) - { - return "123"; - } - - return null; - }); - - var actual = _sut.ApplyVariables(sql); - - actual.ShouldBe(expected); - _sut.ValueByName[name].ShouldNotBeNull(); - } - - [Test] - public void ApplyVariablesFailsOnUnknownVariable() - { - _variables - .Setup(v => v.GetValue(It.IsAny())) - .Returns((string)null); - - var ex = Assert.Throws(() => _sut.ApplyVariables("{{Value_1}}")); - - ex.Message.ShouldContain("Value_1"); - } - - [Test] - [TestCase("var_1", true)] - [TestCase("Var_9", true)] - [TestCase("var-1", false)] - [TestCase("var 1", false)] - public void IsValidVariableName(string variableName, bool isValid) - { - SqlScriptVariableParser.IsValidVariableName(variableName).ShouldBe(isValid); - } - - [Test] - [TestCase("var", "value", "value")] - [TestCase("_var", "value", SqlScriptVariableParser.ValueIsHidden)] - public void NoLogVariableName(string variableName, string value, string expectedLogValue) - { - var sql = "{{" + variableName + "}}"; - - _variables - .Setup(v => v.GetValue(variableName)) - .Returns(value); - - _sut.ApplyVariables(sql); - - _sut.ValueByName[variableName].ShouldBe(expectedLogValue); - } + return "123"; + } + + return null; + }); + + var actual = _sut.ApplyVariables(sql); + + actual.ShouldBe(expected); + _sut.ValueByName[name].ShouldNotBeNull(); + } + + [Test] + public void ApplyVariablesFailsOnUnknownVariable() + { + _variables + .Setup(v => v.GetValue(It.IsAny())) + .Returns((string)null); + + var ex = Assert.Throws(() => _sut.ApplyVariables("{{Value_1}}")); + + ex.Message.ShouldContain("Value_1"); + } + + [Test] + [TestCase("var_1", true)] + [TestCase("Var_9", true)] + [TestCase("var-1", false)] + [TestCase("var 1", false)] + public void IsValidVariableName(string variableName, bool isValid) + { + SqlScriptVariableParser.IsValidVariableName(variableName).ShouldBe(isValid); + } + + [Test] + [TestCase("var", "value", "value")] + [TestCase("_var", "value", SqlScriptVariableParser.ValueIsHidden)] + public void NoLogVariableName(string variableName, string value, string expectedLogValue) + { + var sql = "{{" + variableName + "}}"; + + _variables + .Setup(v => v.GetValue(variableName)) + .Returns(value); + + _sut.ApplyVariables(sql); + + _sut.ValueByName[variableName].ShouldBe(expectedLogValue); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/SqlTestCases/ResourceReader.cs b/Sources/SqlDatabase.Test/Scripts/SqlTestCases/ResourceReader.cs index c66a979f..2ddcebee 100644 --- a/Sources/SqlDatabase.Test/Scripts/SqlTestCases/ResourceReader.cs +++ b/Sources/SqlDatabase.Test/Scripts/SqlTestCases/ResourceReader.cs @@ -4,82 +4,81 @@ using System.Linq; using System.Text; -namespace SqlDatabase.Scripts.SqlTestCases +namespace SqlDatabase.Scripts.SqlTestCases; + +internal static class ResourceReader { - internal static class ResourceReader + public static IEnumerable<(string Name, string Input, string[] Expected)> Read(string folder) { - public static IEnumerable<(string Name, string Input, string[] Expected)> Read(string folder) - { - var anchor = typeof(ResourceReader); - var prefix = anchor.Namespace + "." + anchor.Name + "." + folder + "."; + var anchor = typeof(ResourceReader); + var prefix = anchor.Namespace + "." + anchor.Name + "." + folder + "."; - var sources = anchor - .Assembly - .GetManifestResourceNames() - .Where(i => i.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) - .OrderBy(i => i); + var sources = anchor + .Assembly + .GetManifestResourceNames() + .Where(i => i.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) + .OrderBy(i => i); - foreach (var sourceName in sources) + foreach (var sourceName in sources) + { + using (var stream = anchor.Assembly.GetManifestResourceStream(sourceName)) + using (var reader = new StreamReader(stream)) { - using (var stream = anchor.Assembly.GetManifestResourceStream(sourceName)) - using (var reader = new StreamReader(stream)) - { - var name = Path.GetFileNameWithoutExtension(sourceName.Substring(prefix.Length)); - var (input, expected) = ParseResource(reader); + var name = Path.GetFileNameWithoutExtension(sourceName.Substring(prefix.Length)); + var (input, expected) = ParseResource(reader); - yield return (name, input, expected); - } + yield return (name, input, expected); } } + } - private static (string Input, string[] Expected) ParseResource(TextReader reader) - { - const string Separator = "--------------"; + private static (string Input, string[] Expected) ParseResource(TextReader reader) + { + const string Separator = "--------------"; - var input = new StringBuilder(); - var expected = new List(); - var currentExpected = new StringBuilder(); + var input = new StringBuilder(); + var expected = new List(); + var currentExpected = new StringBuilder(); - var isInput = true; + var isInput = true; - string line; - while ((line = reader.ReadLine()) != null) + string line; + while ((line = reader.ReadLine()) != null) + { + if (line == Separator) { - if (line == Separator) + isInput = false; + if (currentExpected.Length > 0) { - isInput = false; - if (currentExpected.Length > 0) - { - expected.Add(currentExpected.ToString()); - currentExpected.Clear(); - } + expected.Add(currentExpected.ToString()); + currentExpected.Clear(); } - else if (isInput) + } + else if (isInput) + { + if (input.Length > 0) { - if (input.Length > 0) - { - input.AppendLine(); - } - - input.Append(line); + input.AppendLine(); } - else - { - if (currentExpected.Length > 0) - { - currentExpected.AppendLine(); - } - currentExpected.Append(line); - } + input.Append(line); } - - if (currentExpected.Length > 0) + else { - expected.Add(currentExpected.ToString()); + if (currentExpected.Length > 0) + { + currentExpected.AppendLine(); + } + + currentExpected.Append(line); } + } - return (input.ToString(), expected.ToArray()); + if (currentExpected.Length > 0) + { + expected.Add(currentExpected.ToString()); } + + return (input.ToString(), expected.ToArray()); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/TextScriptTest.cs b/Sources/SqlDatabase.Test/Scripts/TextScriptTest.cs index d588fbc3..9a5a2cb3 100644 --- a/Sources/SqlDatabase.Test/Scripts/TextScriptTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/TextScriptTest.cs @@ -10,152 +10,151 @@ using SqlDatabase.Scripts.MsSql; using SqlDatabase.TestApi; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +[TestFixture] +public class TextScriptTest { - [TestFixture] - public class TextScriptTest - { - private Mock _logger; - private Variables _variables; - private Mock _command; - private TextScript _sut; + private Mock _logger; + private Variables _variables; + private Mock _command; + private TextScript _sut; - private IList _logOutput; - private IList _executedScripts; - private Mock _executedReader; + private IList _logOutput; + private IList _executedScripts; + private Mock _executedReader; - [SetUp] - public void BeforeEachTest() - { - _variables = new Variables(); - - _logOutput = new List(); - _logger = new Mock(MockBehavior.Strict); - _logger - .Setup(l => l.Info(It.IsAny())) - .Callback(m => - { - Console.WriteLine("Info: {0}", m); - _logOutput.Add(m); - }); - - _executedScripts = new List(); - _command = new Mock(MockBehavior.Strict); - _command.SetupProperty(c => c.CommandText); - - _executedReader = new Mock(MockBehavior.Strict); - _executedReader - .Setup(r => r.Dispose()); - - _command - .Setup(c => c.ExecuteReader()) - .Callback(() => _executedScripts.Add(_command.Object.CommandText)) - .Returns(_executedReader.Object); - - _sut = new TextScript + [SetUp] + public void BeforeEachTest() + { + _variables = new Variables(); + + _logOutput = new List(); + _logger = new Mock(MockBehavior.Strict); + _logger + .Setup(l => l.Info(It.IsAny())) + .Callback(m => { - TextReader = new MsSqlTextReader() - }; - _variables.SetValue(VariableSource.CommandLine, "var1", "[some value]"); - } + Console.WriteLine("Info: {0}", m); + _logOutput.Add(m); + }); + + _executedScripts = new List(); + _command = new Mock(MockBehavior.Strict); + _command.SetupProperty(c => c.CommandText); - [Test] - public void ExecuteShowVariableReplacement() + _executedReader = new Mock(MockBehavior.Strict); + _executedReader + .Setup(r => r.Dispose()); + + _command + .Setup(c => c.ExecuteReader()) + .Callback(() => _executedScripts.Add(_command.Object.CommandText)) + .Returns(_executedReader.Object); + + _sut = new TextScript { - _sut.ReadSqlContent = "{{var1}} {{var1}}".AsFuncStream(); + TextReader = new MsSqlTextReader() + }; + _variables.SetValue(VariableSource.CommandLine, "var1", "[some value]"); + } - _executedReader - .Setup(r => r.GetSchemaTable()) - .Returns((DataTable)null); - _executedReader - .Setup(r => r.Read()) - .Returns(false); - _executedReader - .Setup(r => r.NextResult()) - .Returns(false); + [Test] + public void ExecuteShowVariableReplacement() + { + _sut.ReadSqlContent = "{{var1}} {{var1}}".AsFuncStream(); - _sut.Execute(_command.Object, _variables, _logger.Object); + _executedReader + .Setup(r => r.GetSchemaTable()) + .Returns((DataTable)null); + _executedReader + .Setup(r => r.Read()) + .Returns(false); + _executedReader + .Setup(r => r.NextResult()) + .Returns(false); - _executedScripts.Count.ShouldBe(1); - _executedScripts[0].ShouldBe("[some value] [some value]"); + _sut.Execute(_command.Object, _variables, _logger.Object); - _logOutput.FirstOrDefault(i => i.Contains("var1") && i.Contains("[some value]")).ShouldNotBeNull(); + _executedScripts.Count.ShouldBe(1); + _executedScripts[0].ShouldBe("[some value] [some value]"); - _executedReader.VerifyAll(); - } + _logOutput.FirstOrDefault(i => i.Contains("var1") && i.Contains("[some value]")).ShouldNotBeNull(); - [Test] - public void Execute() - { - _sut.ReadSqlContent = @" + _executedReader.VerifyAll(); + } + + [Test] + public void Execute() + { + _sut.ReadSqlContent = @" {{var1}} go text2 go" - .AsFuncStream(); + .AsFuncStream(); - _executedReader - .Setup(r => r.GetSchemaTable()) - .Returns((DataTable)null); - _executedReader - .Setup(r => r.Read()) - .Returns(false); - _executedReader - .Setup(r => r.NextResult()) - .Returns(false); + _executedReader + .Setup(r => r.GetSchemaTable()) + .Returns((DataTable)null); + _executedReader + .Setup(r => r.Read()) + .Returns(false); + _executedReader + .Setup(r => r.NextResult()) + .Returns(false); - _sut.Execute(_command.Object, _variables, _logger.Object); + _sut.Execute(_command.Object, _variables, _logger.Object); - _executedScripts.Count.ShouldBe(2); - _executedScripts[0].ShouldBe("[some value]"); - _executedScripts[1].ShouldBe("text2"); + _executedScripts.Count.ShouldBe(2); + _executedScripts[0].ShouldBe("[some value]"); + _executedScripts[1].ShouldBe("text2"); - _executedReader.VerifyAll(); - } + _executedReader.VerifyAll(); + } - [Test] - public void ExecuteWhatIf() - { - _sut.ReadSqlContent = () => new MemoryStream(Encoding.Default.GetBytes(@" + [Test] + public void ExecuteWhatIf() + { + _sut.ReadSqlContent = () => new MemoryStream(Encoding.Default.GetBytes(@" {{var1}} go text2 go")); - _sut.Execute(null, _variables, _logger.Object); + _sut.Execute(null, _variables, _logger.Object); - _executedScripts.ShouldBeEmpty(); - } + _executedScripts.ShouldBeEmpty(); + } - [Test] - public void ExecuteReader() - { - _sut.ReadSqlContent = "select {{var1}}".AsFuncStream(); + [Test] + public void ExecuteReader() + { + _sut.ReadSqlContent = "select {{var1}}".AsFuncStream(); - var actual = _sut.ExecuteReader(_command.Object, _variables, _logger.Object).ToList(); + var actual = _sut.ExecuteReader(_command.Object, _variables, _logger.Object).ToList(); - _executedScripts.Count.ShouldBe(1); - _executedScripts[0].ShouldBe("select [some value]"); + _executedScripts.Count.ShouldBe(1); + _executedScripts[0].ShouldBe("select [some value]"); - actual.Count.ShouldBe(1); - actual[0].ShouldBe(_executedReader.Object); + actual.Count.ShouldBe(1); + actual[0].ShouldBe(_executedReader.Object); - _executedReader.VerifyAll(); - } + _executedReader.VerifyAll(); + } - [Test] - public void GetDependencies() - { - _sut.ReadSqlContent = @" + [Test] + public void GetDependencies() + { + _sut.ReadSqlContent = @" -- module dependency: a 1.0 go -- module dependency: b 1.0 go" - .AsFuncStream(); + .AsFuncStream(); - var actual = _sut.GetDependencies(); + var actual = _sut.GetDependencies(); - actual.ShouldBe(new[] { new ScriptDependency("a", new Version("1.0")) }); - } + actual.ShouldBe(new[] { new ScriptDependency("a", new Version("1.0")) }); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/UpgradeInternal/ModuleVersionResolverTest.cs b/Sources/SqlDatabase.Test/Scripts/UpgradeInternal/ModuleVersionResolverTest.cs index 77a4db8e..bf74b9d9 100644 --- a/Sources/SqlDatabase.Test/Scripts/UpgradeInternal/ModuleVersionResolverTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/UpgradeInternal/ModuleVersionResolverTest.cs @@ -4,90 +4,89 @@ using NUnit.Framework; using Shouldly; -namespace SqlDatabase.Scripts.UpgradeInternal +namespace SqlDatabase.Scripts.UpgradeInternal; + +[TestFixture] +public class ModuleVersionResolverTest { - [TestFixture] - public class ModuleVersionResolverTest + private ModuleVersionResolver _sut; + private Mock _database; + private IList _logOutput; + + [SetUp] + public void BeforeEachTest() { - private ModuleVersionResolver _sut; - private Mock _database; - private IList _logOutput; + _database = new Mock(MockBehavior.Strict); - [SetUp] - public void BeforeEachTest() - { - _database = new Mock(MockBehavior.Strict); - - _logOutput = new List(); - var log = new Mock(MockBehavior.Strict); - log - .Setup(l => l.Info(It.IsAny())) - .Callback(m => - { - Console.WriteLine("Info: {0}", m); - _logOutput.Add(m); - }); - - _sut = new ModuleVersionResolver + _logOutput = new List(); + var log = new Mock(MockBehavior.Strict); + log + .Setup(l => l.Info(It.IsAny())) + .Callback(m => { - Database = _database.Object, - Log = log.Object - }; - } + Console.WriteLine("Info: {0}", m); + _logOutput.Add(m); + }); - [Test] - public void GetCurrentVersionModuleName() + _sut = new ModuleVersionResolver { - const string ModuleName = "the-module"; - var moduleVersion = new Version("1.0"); + Database = _database.Object, + Log = log.Object + }; + } - _database - .Setup(d => d.GetCurrentVersion(ModuleName)) - .Returns(moduleVersion); + [Test] + public void GetCurrentVersionModuleName() + { + const string ModuleName = "the-module"; + var moduleVersion = new Version("1.0"); - _sut.GetCurrentVersion(ModuleName).ShouldBe(moduleVersion); + _database + .Setup(d => d.GetCurrentVersion(ModuleName)) + .Returns(moduleVersion); - _database.VerifyAll(); - _logOutput.Count.ShouldBe(1); - _logOutput[0].ShouldContain(ModuleName); - _logOutput[0].ShouldContain(moduleVersion.ToString()); - } + _sut.GetCurrentVersion(ModuleName).ShouldBe(moduleVersion); - [Test] - public void GetCurrentVersionNoModule() - { - var version = new Version("1.0"); + _database.VerifyAll(); + _logOutput.Count.ShouldBe(1); + _logOutput[0].ShouldContain(ModuleName); + _logOutput[0].ShouldContain(moduleVersion.ToString()); + } - _database - .Setup(d => d.GetCurrentVersion(string.Empty)) - .Returns(version); + [Test] + public void GetCurrentVersionNoModule() + { + var version = new Version("1.0"); - _sut.GetCurrentVersion(null).ShouldBe(version); + _database + .Setup(d => d.GetCurrentVersion(string.Empty)) + .Returns(version); - _database.VerifyAll(); - _logOutput.Count.ShouldBe(1); - _logOutput[0].ShouldContain("database version"); - _logOutput[0].ShouldContain(version.ToString()); - } + _sut.GetCurrentVersion(null).ShouldBe(version); - [Test] - public void GetCurrentVersionCache() - { - var version = new Version("1.0"); + _database.VerifyAll(); + _logOutput.Count.ShouldBe(1); + _logOutput[0].ShouldContain("database version"); + _logOutput[0].ShouldContain(version.ToString()); + } + + [Test] + public void GetCurrentVersionCache() + { + var version = new Version("1.0"); - _database - .Setup(d => d.GetCurrentVersion(string.Empty)) - .Returns(new Version("1.0")); + _database + .Setup(d => d.GetCurrentVersion(string.Empty)) + .Returns(new Version("1.0")); - _sut.GetCurrentVersion(null).ShouldBe(version); + _sut.GetCurrentVersion(null).ShouldBe(version); - _logOutput.Clear(); - _database - .Setup(d => d.GetCurrentVersion(string.Empty)) - .Throws(); + _logOutput.Clear(); + _database + .Setup(d => d.GetCurrentVersion(string.Empty)) + .Throws(); - _sut.GetCurrentVersion(null).ShouldBe(version); - _logOutput.ShouldBeEmpty(); - } + _sut.GetCurrentVersion(null).ShouldBe(version); + _logOutput.ShouldBeEmpty(); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/UpgradeInternal/UpgradeScriptCollectionTest.cs b/Sources/SqlDatabase.Test/Scripts/UpgradeInternal/UpgradeScriptCollectionTest.cs index 5f7c5102..838fc35a 100644 --- a/Sources/SqlDatabase.Test/Scripts/UpgradeInternal/UpgradeScriptCollectionTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/UpgradeInternal/UpgradeScriptCollectionTest.cs @@ -2,39 +2,38 @@ using NUnit.Framework; using Shouldly; -namespace SqlDatabase.Scripts.UpgradeInternal +namespace SqlDatabase.Scripts.UpgradeInternal; + +[TestFixture] +public class UpgradeScriptCollectionTest { - [TestFixture] - public class UpgradeScriptCollectionTest + [Test] + [TestCase("1.0_1.1.sql", "", "1.0", "1.1")] + [TestCase("module_1.0_1.1.sql", "module", "1.0", "1.1")] + [TestCase("1.0.1.2_1.2.1.sql", "", "1.0.1.2", "1.2.1")] + [TestCase("module_1.0.1.2_1.2.1.sql", "module", "1.0.1.2", "1.2.1")] + [TestCase("1_2.sql", "", "1.0", "2.0")] + [TestCase("module_1_2.sql", "module", "1.0", "2.0")] + [TestCase("1.0.sql", null, null, null)] + [TestCase("xxx.sql", null, null, null)] + [TestCase("xxx_1.0.sql", null, null, null)] + [TestCase("1.0_xxx.sql", null, null, null)] + [TestCase("2.0_1.0.sql", null, null, null)] + [TestCase("_1.0_1.1.sql", null, null, null)] + public void TryParseFileName(string name, string moduleName, string from, string to) { - [Test] - [TestCase("1.0_1.1.sql", "", "1.0", "1.1")] - [TestCase("module_1.0_1.1.sql", "module", "1.0", "1.1")] - [TestCase("1.0.1.2_1.2.1.sql", "", "1.0.1.2", "1.2.1")] - [TestCase("module_1.0.1.2_1.2.1.sql", "module", "1.0.1.2", "1.2.1")] - [TestCase("1_2.sql", "", "1.0", "2.0")] - [TestCase("module_1_2.sql", "module", "1.0", "2.0")] - [TestCase("1.0.sql", null, null, null)] - [TestCase("xxx.sql", null, null, null)] - [TestCase("xxx_1.0.sql", null, null, null)] - [TestCase("1.0_xxx.sql", null, null, null)] - [TestCase("2.0_1.0.sql", null, null, null)] - [TestCase("_1.0_1.1.sql", null, null, null)] - public void TryParseFileName(string name, string moduleName, string from, string to) - { - var actual = UpgradeScriptCollection.TryParseFileName(name, out var actualModuleName, out var actualFrom, out var actualTo); + var actual = UpgradeScriptCollection.TryParseFileName(name, out var actualModuleName, out var actualFrom, out var actualTo); - if (from == null) - { - actual.ShouldBeFalse(); - } - else - { - actual.ShouldBeTrue(); - actualModuleName.ShouldBe(moduleName); - actualFrom.ShouldBe(new Version(from)); - actualTo.ShouldBe(new Version(to)); - } + if (from == null) + { + actual.ShouldBeFalse(); + } + else + { + actual.ShouldBeTrue(); + actualModuleName.ShouldBe(moduleName); + actualFrom.ShouldBe(new Version(from)); + actualTo.ShouldBe(new Version(to)); } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/UpgradeScriptSequenceTest.cs b/Sources/SqlDatabase.Test/Scripts/UpgradeScriptSequenceTest.cs index f0cf3a50..401f0ddd 100644 --- a/Sources/SqlDatabase.Test/Scripts/UpgradeScriptSequenceTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/UpgradeScriptSequenceTest.cs @@ -10,194 +10,193 @@ using SqlDatabase.Scripts.UpgradeInternal; using SqlDatabase.TestApi; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +[TestFixture] +public class UpgradeScriptSequenceTest { - [TestFixture] - public class UpgradeScriptSequenceTest - { - private UpgradeScriptSequence _sut; - private SourceFolder _root; - private Mock _versionResolver; - private Mock _scriptFactory; + private UpgradeScriptSequence _sut; + private SourceFolder _root; + private Mock _versionResolver; + private Mock _scriptFactory; - [SetUp] - public void BeforeEachTest() - { - _root = new SourceFolder("Test"); + [SetUp] + public void BeforeEachTest() + { + _root = new SourceFolder("Test"); - _scriptFactory = new Mock(MockBehavior.Strict); - _scriptFactory - .Setup(f => f.IsSupported(It.IsAny())) - .Returns(s => ".sql".Equals(Path.GetExtension(s)) || ".exe".Equals(Path.GetExtension(s))); + _scriptFactory = new Mock(MockBehavior.Strict); + _scriptFactory + .Setup(f => f.IsSupported(It.IsAny())) + .Returns(s => ".sql".Equals(Path.GetExtension(s)) || ".exe".Equals(Path.GetExtension(s))); - _versionResolver = new Mock(MockBehavior.Strict); + _versionResolver = new Mock(MockBehavior.Strict); - _sut = new UpgradeScriptSequence - { - Sources = { _root }, - ScriptFactory = _scriptFactory.Object, - VersionResolver = _versionResolver.Object - }; - } + _sut = new UpgradeScriptSequence + { + Sources = { _root }, + ScriptFactory = _scriptFactory.Object, + VersionResolver = _versionResolver.Object + }; + } - [Test] - [TestCaseSource(nameof(GetBuildSequence))] - public void BuildSequence(BuildSequenceCase testCase) + [Test] + [TestCaseSource(nameof(GetBuildSequence))] + public void BuildSequence(BuildSequenceCase testCase) + { + foreach (var sourceFile in testCase.Files) { - foreach (var sourceFile in testCase.Files) + var file = AddFile(_root, sourceFile.Name); + + var dependencies = new ScriptDependency[0]; + if (sourceFile.Dependencies != null) { - var file = AddFile(_root, sourceFile.Name); + dependencies = sourceFile.Dependencies.Select(i => new ScriptDependency(i.Module, new Version(i.Version))).ToArray(); + } - var dependencies = new ScriptDependency[0]; - if (sourceFile.Dependencies != null) - { - dependencies = sourceFile.Dependencies.Select(i => new ScriptDependency(i.Module, new Version(i.Version))).ToArray(); - } + var script = new Mock(MockBehavior.Strict); + script.SetupGet(s => s.DisplayName).Returns(file.Name); + script.Setup(s => s.GetDependencies()).Returns(dependencies); - var script = new Mock(MockBehavior.Strict); - script.SetupGet(s => s.DisplayName).Returns(file.Name); - script.Setup(s => s.GetDependencies()).Returns(dependencies); + _scriptFactory + .Setup(s => s.FromFile(file)) + .Returns(script.Object); + } - _scriptFactory - .Setup(s => s.FromFile(file)) - .Returns(script.Object); - } + foreach (var version in testCase.Version) + { + _versionResolver + .Setup(r => r.GetCurrentVersion(version.Module ?? string.Empty)) + .Returns(new Version(version.Version)); + } + + _sut.FolderAsModuleName = testCase.FolderAsModuleName; - foreach (var version in testCase.Version) + if (testCase.Exception == null) + { + var actual = _sut.BuildSequence(); + actual.Select(i => i.Script.DisplayName).ToArray().ShouldBe(testCase.Sequence); + } + else + { + var ex = Assert.Throws(() => _sut.BuildSequence()); + Console.WriteLine(ex.Message); + foreach (var tag in testCase.Exception) { - _versionResolver - .Setup(r => r.GetCurrentVersion(version.Module ?? string.Empty)) - .Returns(new Version(version.Version)); + ex.Message.ShouldContain(tag); } + } + } + + private static IEnumerable GetBuildSequence() + { + var anchor = typeof(UpgradeScriptSequenceTest); + var prefix = anchor.Namespace + "." + anchor.Name + "."; - _sut.FolderAsModuleName = testCase.FolderAsModuleName; + var sources = anchor + .Assembly + .GetManifestResourceNames() + .Where(i => i.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) + .OrderBy(i => i); - if (testCase.Exception == null) + foreach (var sourceName in sources) + { + BuildSequenceCase[] testCases; + using (var stream = anchor.Assembly.GetManifestResourceStream(sourceName)) + using (var reader = new JsonTextReader(new StreamReader(stream))) { - var actual = _sut.BuildSequence(); - actual.Select(i => i.Script.DisplayName).ToArray().ShouldBe(testCase.Sequence); + testCases = new JsonSerializer().Deserialize(reader); } - else + + foreach (var testCase in testCases) { - var ex = Assert.Throws(() => _sut.BuildSequence()); - Console.WriteLine(ex.Message); - foreach (var tag in testCase.Exception) + yield return new TestCaseData(testCase) { - ex.Message.ShouldContain(tag); - } + TestName = sourceName.Substring(prefix.Length) + "-" + testCase.Name + }; } } + } - private static IEnumerable GetBuildSequence() + private static IFile AddFile(SourceFolder root, string fileName) + { + var path = fileName.Split('/'); + for (var i = 0; i < path.Length - 1; i++) { - var anchor = typeof(UpgradeScriptSequenceTest); - var prefix = anchor.Namespace + "." + anchor.Name + "."; + root = root.GetOrCreateSubFolder(path[i]); + } - var sources = anchor - .Assembly - .GetManifestResourceNames() - .Where(i => i.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) - .OrderBy(i => i); + return root.AddFile(path.Last()); + } - foreach (var sourceName in sources) - { - BuildSequenceCase[] testCases; - using (var stream = anchor.Assembly.GetManifestResourceStream(sourceName)) - using (var reader = new JsonTextReader(new StreamReader(stream))) - { - testCases = new JsonSerializer().Deserialize(reader); - } + public sealed class BuildSequenceCase + { + public string Name { get; set; } - foreach (var testCase in testCases) - { - yield return new TestCaseData(testCase) - { - TestName = sourceName.Substring(prefix.Length) + "-" + testCase.Name - }; - } - } - } + public bool FolderAsModuleName { get; set; } - private static IFile AddFile(SourceFolder root, string fileName) - { - var path = fileName.Split('/'); - for (var i = 0; i < path.Length - 1; i++) - { - root = root.GetOrCreateSubFolder(path[i]); - } + public ModuleVersion[] Version { get; set; } - return root.AddFile(path.Last()); - } + public SourceFile[] Files { get; set; } - public sealed class BuildSequenceCase - { - public string Name { get; set; } + public string[] Sequence { get; set; } - public bool FolderAsModuleName { get; set; } + public string[] Exception { get; set; } + } - public ModuleVersion[] Version { get; set; } + public sealed class ModuleVersion + { + public string Module { get; set; } - public SourceFile[] Files { get; set; } + public string Version { get; set; } + } - public string[] Sequence { get; set; } + public sealed class SourceFile + { + public string Name { get; set; } - public string[] Exception { get; set; } - } + public ModuleVersion[] Dependencies { get; set; } + } - public sealed class ModuleVersion + private sealed class SourceFolder : IFolder + { + private readonly IDictionary _subFolderByName; + private readonly IDictionary _fileByName; + + public SourceFolder(string name) { - public string Module { get; set; } + Name = name; - public string Version { get; set; } + _subFolderByName = new Dictionary(StringComparer.OrdinalIgnoreCase); + _fileByName = new Dictionary(StringComparer.OrdinalIgnoreCase); } - public sealed class SourceFile - { - public string Name { get; set; } + public string Name { get; } - public ModuleVersion[] Dependencies { get; set; } - } + public IEnumerable GetFolders() => _subFolderByName.Values; - private sealed class SourceFolder : IFolder - { - private readonly IDictionary _subFolderByName; - private readonly IDictionary _fileByName; + public IEnumerable GetFiles() => _fileByName.Values; - public SourceFolder(string name) + public SourceFolder GetOrCreateSubFolder(string name) + { + if (!_subFolderByName.TryGetValue(name, out var result)) { - Name = name; - - _subFolderByName = new Dictionary(StringComparer.OrdinalIgnoreCase); - _fileByName = new Dictionary(StringComparer.OrdinalIgnoreCase); + result = new SourceFolder(name); + _subFolderByName.Add(name, result); } - public string Name { get; } - - public IEnumerable GetFolders() => _subFolderByName.Values; - - public IEnumerable GetFiles() => _fileByName.Values; + return result; + } - public SourceFolder GetOrCreateSubFolder(string name) + public IFile AddFile(string name) + { + if (!_fileByName.TryGetValue(name, out var result)) { - if (!_subFolderByName.TryGetValue(name, out var result)) - { - result = new SourceFolder(name); - _subFolderByName.Add(name, result); - } - - return result; + result = FileFactory.File(name); + _fileByName.Add(name, result); } - public IFile AddFile(string name) - { - if (!_fileByName.TryGetValue(name, out var result)) - { - result = FileFactory.File(name); - _fileByName.Add(name, result); - } - - return result; - } + return result; } } } \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/Scripts/VariablesTest.cs b/Sources/SqlDatabase.Test/Scripts/VariablesTest.cs index d91c2924..fc0950da 100644 --- a/Sources/SqlDatabase.Test/Scripts/VariablesTest.cs +++ b/Sources/SqlDatabase.Test/Scripts/VariablesTest.cs @@ -1,91 +1,90 @@ using System; using NUnit.Framework; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +[TestFixture] +public class VariablesTest { - [TestFixture] - public class VariablesTest - { - private Variables _sut; + private Variables _sut; - [SetUp] - public void BeforeEachTest() - { - _sut = new Variables(); - } + [SetUp] + public void BeforeEachTest() + { + _sut = new Variables(); + } - [Test] - [TestCase(VariableSource.Runtime, true)] - [TestCase(VariableSource.CommandLine, true)] - [TestCase(VariableSource.Environment, true)] - [TestCase(VariableSource.ConfigurationFile, false)] - public void GetValueEnvironmentVariable(VariableSource source, bool isOverridden) - { - const string Key = "TEMP"; + [Test] + [TestCase(VariableSource.Runtime, true)] + [TestCase(VariableSource.CommandLine, true)] + [TestCase(VariableSource.Environment, true)] + [TestCase(VariableSource.ConfigurationFile, false)] + public void GetValueEnvironmentVariable(VariableSource source, bool isOverridden) + { + const string Key = "TEMP"; - Assert.IsNotNull(_sut.GetValue(Key)); - Assert.AreEqual(Environment.GetEnvironmentVariable(Key), _sut.GetValue(Key)); + Assert.IsNotNull(_sut.GetValue(Key)); + Assert.AreEqual(Environment.GetEnvironmentVariable(Key), _sut.GetValue(Key)); - _sut.SetValue(source, Key, "new value"); + _sut.SetValue(source, Key, "new value"); - var expected = isOverridden ? "new value" : Environment.GetEnvironmentVariable(Key); - Assert.AreEqual(expected, _sut.GetValue(Key)); - } + var expected = isOverridden ? "new value" : Environment.GetEnvironmentVariable(Key); + Assert.AreEqual(expected, _sut.GetValue(Key)); + } - [Test] - public void NullValue() - { - const string Key = "some name"; + [Test] + public void NullValue() + { + const string Key = "some name"; - Assert.IsNull(_sut.GetValue(Key)); + Assert.IsNull(_sut.GetValue(Key)); - _sut.SetValue(VariableSource.CommandLine, Key, "1"); - Assert.AreEqual("1", _sut.GetValue(Key)); + _sut.SetValue(VariableSource.CommandLine, Key, "1"); + Assert.AreEqual("1", _sut.GetValue(Key)); - _sut.SetValue(VariableSource.CommandLine, Key, string.Empty); - Assert.AreEqual(string.Empty, _sut.GetValue(Key)); + _sut.SetValue(VariableSource.CommandLine, Key, string.Empty); + Assert.AreEqual(string.Empty, _sut.GetValue(Key)); - _sut.SetValue(VariableSource.CommandLine, Key, null); - Assert.IsNull(_sut.GetValue(Key)); - } + _sut.SetValue(VariableSource.CommandLine, Key, null); + Assert.IsNull(_sut.GetValue(Key)); + } - [Test] - [TestCase(VariableSource.Runtime, VariableSource.ConfigurationFile)] - [TestCase(VariableSource.Runtime, VariableSource.CommandLine)] - [TestCase(VariableSource.Runtime, VariableSource.Environment)] - [TestCase(VariableSource.CommandLine, VariableSource.ConfigurationFile)] - [TestCase(VariableSource.CommandLine, VariableSource.Environment)] - [TestCase(VariableSource.Environment, VariableSource.ConfigurationFile)] - public void ResolvePriority(VariableSource expected, VariableSource competitor) - { - const string Key = "{839BA97E-9271-4D25-9453-434E269F8BDB}"; - const string ExpectedValue = "expected"; - const string CompetitorValue = "competitor"; + [Test] + [TestCase(VariableSource.Runtime, VariableSource.ConfigurationFile)] + [TestCase(VariableSource.Runtime, VariableSource.CommandLine)] + [TestCase(VariableSource.Runtime, VariableSource.Environment)] + [TestCase(VariableSource.CommandLine, VariableSource.ConfigurationFile)] + [TestCase(VariableSource.CommandLine, VariableSource.Environment)] + [TestCase(VariableSource.Environment, VariableSource.ConfigurationFile)] + public void ResolvePriority(VariableSource expected, VariableSource competitor) + { + const string Key = "{839BA97E-9271-4D25-9453-434E269F8BDB}"; + const string ExpectedValue = "expected"; + const string CompetitorValue = "competitor"; - // default - Assert.IsNull(_sut.GetValue(Key)); + // default + Assert.IsNull(_sut.GetValue(Key)); - // competitor, expected - _sut.SetValue(competitor, Key, CompetitorValue); - _sut.SetValue(expected, Key, ExpectedValue); + // competitor, expected + _sut.SetValue(competitor, Key, CompetitorValue); + _sut.SetValue(expected, Key, ExpectedValue); - Assert.AreEqual(ExpectedValue, _sut.GetValue(Key)); + Assert.AreEqual(ExpectedValue, _sut.GetValue(Key)); - // try to remove by competitor - _sut.SetValue(competitor, Key, null); + // try to remove by competitor + _sut.SetValue(competitor, Key, null); - Assert.AreEqual(ExpectedValue, _sut.GetValue(Key)); + Assert.AreEqual(ExpectedValue, _sut.GetValue(Key)); - // try to remove by expected - _sut.SetValue(expected, Key, null); + // try to remove by expected + _sut.SetValue(expected, Key, null); - Assert.IsNull(_sut.GetValue(Key)); + Assert.IsNull(_sut.GetValue(Key)); - // expected, competitor - _sut.SetValue(expected, Key, ExpectedValue); - _sut.SetValue(competitor, Key, CompetitorValue); + // expected, competitor + _sut.SetValue(expected, Key, ExpectedValue); + _sut.SetValue(competitor, Key, CompetitorValue); - Assert.AreEqual(ExpectedValue, _sut.GetValue(Key)); - } + Assert.AreEqual(ExpectedValue, _sut.GetValue(Key)); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/SqlDatabase.Test.csproj b/Sources/SqlDatabase.Test/SqlDatabase.Test.csproj index b377c177..0f3745f3 100644 --- a/Sources/SqlDatabase.Test/SqlDatabase.Test.csproj +++ b/Sources/SqlDatabase.Test/SqlDatabase.Test.csproj @@ -1,7 +1,7 @@  - net472;netcoreapp3.1;net5.0;net6.0 + net472;netcoreapp3.1;net5.0;net6.0;net7.0 SqlDatabase NU1702 ..\..\bin\Tests @@ -9,12 +9,12 @@ - - - - - - + + + + + + diff --git a/Sources/SqlDatabase.Test/TestApi/FileFactory.cs b/Sources/SqlDatabase.Test/TestApi/FileFactory.cs index e8fc1cbc..d21981f1 100644 --- a/Sources/SqlDatabase.Test/TestApi/FileFactory.cs +++ b/Sources/SqlDatabase.Test/TestApi/FileFactory.cs @@ -5,62 +5,61 @@ using NUnit.Framework; using SqlDatabase.IO; -namespace SqlDatabase.TestApi +namespace SqlDatabase.TestApi; + +internal static class FileFactory { - internal static class FileFactory + public static IFile File(string name, byte[] content, IFolder parent) { - public static IFile File(string name, byte[] content, IFolder parent) - { - var file = new Mock(MockBehavior.Strict); + var file = new Mock(MockBehavior.Strict); - file.SetupGet(f => f.Name).Returns(name); + file.SetupGet(f => f.Name).Returns(name); - if (content != null) - { - file.Setup(f => f.OpenRead()).Returns(new MemoryStream(content)); - } + if (content != null) + { + file.Setup(f => f.OpenRead()).Returns(new MemoryStream(content)); + } - file.Setup(f => f.GetParent()).Returns(parent); + file.Setup(f => f.GetParent()).Returns(parent); - return file.Object; - } + return file.Object; + } - public static IFile File(string name, byte[] content = null) => File(name, content, null); + public static IFile File(string name, byte[] content = null) => File(name, content, null); - public static IFile File(string name, string content) => File(name, content, null); + public static IFile File(string name, string content) => File(name, content, null); - public static IFile File(string name, string content, IFolder parent) - { - return File( - name, - string.IsNullOrEmpty(content) ? new byte[0] : Encoding.UTF8.GetBytes(content), - parent); - } + public static IFile File(string name, string content, IFolder parent) + { + return File( + name, + string.IsNullOrEmpty(content) ? new byte[0] : Encoding.UTF8.GetBytes(content), + parent); + } - public static IFolder Folder(string name, params IFileSystemInfo[] content) - { - var folder = new Mock(MockBehavior.Strict); + public static IFolder Folder(string name, params IFileSystemInfo[] content) + { + var folder = new Mock(MockBehavior.Strict); - folder.SetupGet(f => f.Name).Returns(name); + folder.SetupGet(f => f.Name).Returns(name); - var files = content.OfType().ToArray(); - folder.Setup(f => f.GetFiles()).Returns(files); + var files = content.OfType().ToArray(); + folder.Setup(f => f.GetFiles()).Returns(files); - var subFolders = content.OfType().ToArray(); - folder.Setup(f => f.GetFolders()).Returns(subFolders); + var subFolders = content.OfType().ToArray(); + folder.Setup(f => f.GetFolders()).Returns(subFolders); - return folder.Object; - } + return folder.Object; + } - public static string ReadAllText(this IFile file) - { - Assert.IsNotNull(file); + public static string ReadAllText(this IFile file) + { + Assert.IsNotNull(file); - using (var stream = file.OpenRead()) - using (var reader = new StreamReader(stream)) - { - return reader.ReadToEnd(); - } + using (var stream = file.OpenRead()) + using (var reader = new StreamReader(stream)) + { + return reader.ReadToEnd(); } } } \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/TestApi/MsSqlQuery.cs b/Sources/SqlDatabase.Test/TestApi/MsSqlQuery.cs index 6afffc83..9578653d 100644 --- a/Sources/SqlDatabase.Test/TestApi/MsSqlQuery.cs +++ b/Sources/SqlDatabase.Test/TestApi/MsSqlQuery.cs @@ -1,30 +1,29 @@ using System.Configuration; using System.Data.SqlClient; -namespace SqlDatabase.TestApi +namespace SqlDatabase.TestApi; + +internal static class MsSqlQuery { - internal static class MsSqlQuery - { - public static string ConnectionString => ConfigurationManager.ConnectionStrings["mssql"].ConnectionString; + public static string ConnectionString => ConfigurationManager.ConnectionStrings["mssql"].ConnectionString; - public static string DatabaseName => new SqlConnectionStringBuilder(ConnectionString).InitialCatalog; + public static string DatabaseName => new SqlConnectionStringBuilder(ConnectionString).InitialCatalog; - public static SqlConnection Open() - { - var con = new SqlConnection(ConnectionString); - con.Open(); + public static SqlConnection Open() + { + var con = new SqlConnection(ConnectionString); + con.Open(); - return con; - } + return con; + } - public static object ExecuteScalar(string sql) + public static object ExecuteScalar(string sql) + { + using (var connection = Open()) + using (var cmd = connection.CreateCommand()) { - using (var connection = Open()) - using (var cmd = connection.CreateCommand()) - { - cmd.CommandText = sql; - return cmd.ExecuteScalar(); - } + cmd.CommandText = sql; + return cmd.ExecuteScalar(); } } } \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/TestApi/MySqlQuery.cs b/Sources/SqlDatabase.Test/TestApi/MySqlQuery.cs index 81cf38a3..85fc1f75 100644 --- a/Sources/SqlDatabase.Test/TestApi/MySqlQuery.cs +++ b/Sources/SqlDatabase.Test/TestApi/MySqlQuery.cs @@ -1,30 +1,29 @@ using System.Configuration; using MySqlConnector; -namespace SqlDatabase.TestApi +namespace SqlDatabase.TestApi; + +internal static class MySqlQuery { - internal static class MySqlQuery - { - public static string ConnectionString => ConfigurationManager.ConnectionStrings["mysql"].ConnectionString; + public static string ConnectionString => ConfigurationManager.ConnectionStrings["mysql"].ConnectionString; - public static string DatabaseName => new MySqlConnectionStringBuilder(ConnectionString).Database; + public static string DatabaseName => new MySqlConnectionStringBuilder(ConnectionString).Database; - public static MySqlConnection Open() - { - var con = new MySqlConnection(ConnectionString); - con.Open(); + public static MySqlConnection Open() + { + var con = new MySqlConnection(ConnectionString); + con.Open(); - return con; - } + return con; + } - public static object ExecuteScalar(string sql) + public static object ExecuteScalar(string sql) + { + using (var connection = Open()) + using (var cmd = connection.CreateCommand()) { - using (var connection = Open()) - using (var cmd = connection.CreateCommand()) - { - cmd.CommandText = sql; - return cmd.ExecuteScalar(); - } + cmd.CommandText = sql; + return cmd.ExecuteScalar(); } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/TestApi/PgSqlQuery.cs b/Sources/SqlDatabase.Test/TestApi/PgSqlQuery.cs index a1dccb31..9faaebf2 100644 --- a/Sources/SqlDatabase.Test/TestApi/PgSqlQuery.cs +++ b/Sources/SqlDatabase.Test/TestApi/PgSqlQuery.cs @@ -1,30 +1,29 @@ using System.Configuration; using Npgsql; -namespace SqlDatabase.TestApi +namespace SqlDatabase.TestApi; + +internal static class PgSqlQuery { - internal static class PgSqlQuery - { - public static string ConnectionString => ConfigurationManager.ConnectionStrings["pgsql"].ConnectionString; + public static string ConnectionString => ConfigurationManager.ConnectionStrings["pgsql"].ConnectionString; - public static string DatabaseName => new NpgsqlConnectionStringBuilder(ConnectionString).Database; + public static string DatabaseName => new NpgsqlConnectionStringBuilder(ConnectionString).Database; - public static NpgsqlConnection Open() - { - var con = new NpgsqlConnection(ConnectionString); - con.Open(); + public static NpgsqlConnection Open() + { + var con = new NpgsqlConnection(ConnectionString); + con.Open(); - return con; - } + return con; + } - public static object ExecuteScalar(string sql) + public static object ExecuteScalar(string sql) + { + using (var connection = Open()) + using (var cmd = connection.CreateCommand()) { - using (var connection = Open()) - using (var cmd = connection.CreateCommand()) - { - cmd.CommandText = sql; - return cmd.ExecuteScalar(); - } + cmd.CommandText = sql; + return cmd.ExecuteScalar(); } } } \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/TestApi/TempConsoleOut.cs b/Sources/SqlDatabase.Test/TestApi/TempConsoleOut.cs index 10f94beb..7d9be97e 100644 --- a/Sources/SqlDatabase.Test/TestApi/TempConsoleOut.cs +++ b/Sources/SqlDatabase.Test/TestApi/TempConsoleOut.cs @@ -1,37 +1,36 @@ using System; using System.IO; -namespace SqlDatabase.TestApi +namespace SqlDatabase.TestApi; + +internal sealed class TempConsoleOut : IDisposable { - internal sealed class TempConsoleOut : IDisposable - { - private readonly TextWriter _originalOutput; - private readonly Buffer _buffer; + private readonly TextWriter _originalOutput; + private readonly Buffer _buffer; - public TempConsoleOut() - { - _originalOutput = Console.Out; - _buffer = new Buffer(); - Console.SetOut(_buffer); - } + public TempConsoleOut() + { + _originalOutput = Console.Out; + _buffer = new Buffer(); + Console.SetOut(_buffer); + } - public string GetOutput() - { - _buffer.Flush(); - return _buffer.ToString(); - } + public string GetOutput() + { + _buffer.Flush(); + return _buffer.ToString(); + } - public void Dispose() - { - Console.SetOut(_originalOutput); - } + public void Dispose() + { + Console.SetOut(_originalOutput); + } - private sealed class Buffer : StringWriter, IDisposable + private sealed class Buffer : StringWriter, IDisposable + { + void IDisposable.Dispose() { - void IDisposable.Dispose() - { - Flush(); - } + Flush(); } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/TestApi/TempDirectory.cs b/Sources/SqlDatabase.Test/TestApi/TempDirectory.cs index 3f02b74c..f42cec74 100644 --- a/Sources/SqlDatabase.Test/TestApi/TempDirectory.cs +++ b/Sources/SqlDatabase.Test/TestApi/TempDirectory.cs @@ -3,45 +3,44 @@ using System.IO; using NUnit.Framework; -namespace SqlDatabase.TestApi +namespace SqlDatabase.TestApi; + +internal sealed class TempDirectory : IDisposable { - internal sealed class TempDirectory : IDisposable + public TempDirectory(string name = null) { - public TempDirectory(string name = null) - { - Location = Path.Combine(Path.GetTempPath(), name ?? Guid.NewGuid().ToString()); - Directory.CreateDirectory(Location); - } + Location = Path.Combine(Path.GetTempPath(), name ?? Guid.NewGuid().ToString()); + Directory.CreateDirectory(Location); + } - public string Location { get; } + public string Location { get; } - public string CopyFileFromResources(string resourceName, Type resourceAnchor = null) + public string CopyFileFromResources(string resourceName, Type resourceAnchor = null) + { + if (resourceAnchor == null) { - if (resourceAnchor == null) - { - resourceAnchor = new StackTrace().GetFrame(1).GetMethod().DeclaringType; - } - - var source = resourceAnchor.Assembly.GetManifestResourceStream(resourceAnchor.Namespace + "." + resourceName); - Assert.IsNotNull(source, resourceName); + resourceAnchor = new StackTrace().GetFrame(1).GetMethod().DeclaringType; + } - var fileName = Path.Combine(Location, resourceName); + var source = resourceAnchor.Assembly.GetManifestResourceStream(resourceAnchor.Namespace + "." + resourceName); + Assert.IsNotNull(source, resourceName); - using (source) - using (var dest = new FileStream(fileName, FileMode.Create, FileAccess.ReadWrite)) - { - source.CopyTo(dest); - } + var fileName = Path.Combine(Location, resourceName); - return fileName; + using (source) + using (var dest = new FileStream(fileName, FileMode.Create, FileAccess.ReadWrite)) + { + source.CopyTo(dest); } - public void Dispose() + return fileName; + } + + public void Dispose() + { + if (Directory.Exists(Location)) { - if (Directory.Exists(Location)) - { - Directory.Delete(Location, true); - } + Directory.Delete(Location, true); } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/TestApi/TempFile.cs b/Sources/SqlDatabase.Test/TestApi/TempFile.cs index 9007ee0f..91777ed8 100644 --- a/Sources/SqlDatabase.Test/TestApi/TempFile.cs +++ b/Sources/SqlDatabase.Test/TestApi/TempFile.cs @@ -1,23 +1,22 @@ using System; using System.IO; -namespace SqlDatabase.TestApi +namespace SqlDatabase.TestApi; + +internal sealed class TempFile : IDisposable { - internal sealed class TempFile : IDisposable + public TempFile(string extension) { - public TempFile(string extension) - { - Location = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + extension); - } + Location = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + extension); + } - public string Location { get; } + public string Location { get; } - public void Dispose() + public void Dispose() + { + if (File.Exists(Location)) { - if (File.Exists(Location)) - { - File.Delete(Location); - } + File.Delete(Location); } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/TestApi/TestPowerShellHost.cs b/Sources/SqlDatabase.Test/TestApi/TestPowerShellHost.cs index 2d62658e..a757c04f 100644 --- a/Sources/SqlDatabase.Test/TestApi/TestPowerShellHost.cs +++ b/Sources/SqlDatabase.Test/TestApi/TestPowerShellHost.cs @@ -3,37 +3,36 @@ using SqlDatabase.Scripts; using SqlDatabase.Scripts.PowerShellInternal; -namespace SqlDatabase.TestApi +namespace SqlDatabase.TestApi; + +internal static class TestPowerShellHost { - internal static class TestPowerShellHost + public static IPowerShellFactory GetOrCreateFactory() { - public static IPowerShellFactory GetOrCreateFactory() + if (PowerShellFactory.SharedTestFactory == null) { - if (PowerShellFactory.SharedTestFactory == null) - { - PowerShellFactory.SharedTestFactory = CreateFactory(); - } - - return PowerShellFactory.SharedTestFactory; + PowerShellFactory.SharedTestFactory = CreateFactory(); } - private static IPowerShellFactory CreateFactory() - { - var logger = new Mock(MockBehavior.Strict); - logger - .Setup(l => l.Info(It.IsNotNull())) - .Callback(m => Console.WriteLine("info: " + m)); - logger - .Setup(l => l.Error(It.IsNotNull())) - .Callback(m => Console.WriteLine("error: " + m)); - logger - .Setup(l => l.Indent()) - .Returns((IDisposable)null); + return PowerShellFactory.SharedTestFactory; + } - var factory = PowerShellFactory.Create(null); - factory.Request(); - factory.InitializeIfRequested(logger.Object); - return factory; - } + private static IPowerShellFactory CreateFactory() + { + var logger = new Mock(MockBehavior.Strict); + logger + .Setup(l => l.Info(It.IsNotNull())) + .Callback(m => Console.WriteLine("info: " + m)); + logger + .Setup(l => l.Error(It.IsNotNull())) + .Callback(m => Console.WriteLine("error: " + m)); + logger + .Setup(l => l.Indent()) + .Returns((IDisposable)null); + + var factory = PowerShellFactory.Create(null); + factory.Request(); + factory.InitializeIfRequested(logger.Object); + return factory; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase.Test/TestApi/TextExtensions.cs b/Sources/SqlDatabase.Test/TestApi/TextExtensions.cs index ea42b40c..6353f3ca 100644 --- a/Sources/SqlDatabase.Test/TestApi/TextExtensions.cs +++ b/Sources/SqlDatabase.Test/TestApi/TextExtensions.cs @@ -2,13 +2,12 @@ using System.IO; using System.Text; -namespace SqlDatabase.TestApi +namespace SqlDatabase.TestApi; + +internal static class TextExtensions { - internal static class TextExtensions + public static Func AsFuncStream(this string text) { - public static Func AsFuncStream(this string text) - { - return () => new MemoryStream(Encoding.Default.GetBytes(text)); - } + return () => new MemoryStream(Encoding.Default.GetBytes(text)); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Commands/DatabaseCommandBase.cs b/Sources/SqlDatabase/Commands/DatabaseCommandBase.cs index f51c5e7e..55af56cf 100644 --- a/Sources/SqlDatabase/Commands/DatabaseCommandBase.cs +++ b/Sources/SqlDatabase/Commands/DatabaseCommandBase.cs @@ -1,23 +1,22 @@ using SqlDatabase.Scripts; -namespace SqlDatabase.Commands +namespace SqlDatabase.Commands; + +internal abstract class DatabaseCommandBase : ICommand { - internal abstract class DatabaseCommandBase : ICommand - { - public ILogger Log { get; set; } + public ILogger Log { get; set; } - public IDatabase Database { get; set; } + public IDatabase Database { get; set; } - public void Execute() - { - Greet(Database.Adapter.GetUserFriendlyConnectionString()); - Log.Info(Database.GetServerVersion()); + public void Execute() + { + Greet(Database.Adapter.GetUserFriendlyConnectionString()); + Log.Info(Database.GetServerVersion()); - ExecuteCore(); - } + ExecuteCore(); + } - protected abstract void Greet(string databaseLocation); + protected abstract void Greet(string databaseLocation); - protected abstract void ExecuteCore(); - } + protected abstract void ExecuteCore(); } \ No newline at end of file diff --git a/Sources/SqlDatabase/Commands/DatabaseCreateCommand.cs b/Sources/SqlDatabase/Commands/DatabaseCreateCommand.cs index ae4874a9..fe7a1f4d 100644 --- a/Sources/SqlDatabase/Commands/DatabaseCreateCommand.cs +++ b/Sources/SqlDatabase/Commands/DatabaseCreateCommand.cs @@ -2,41 +2,40 @@ using System.Diagnostics; using SqlDatabase.Scripts; -namespace SqlDatabase.Commands +namespace SqlDatabase.Commands; + +internal sealed class DatabaseCreateCommand : DatabaseCommandBase { - internal sealed class DatabaseCreateCommand : DatabaseCommandBase - { - public ICreateScriptSequence ScriptSequence { get; set; } + public ICreateScriptSequence ScriptSequence { get; set; } - public IPowerShellFactory PowerShellFactory { get; set; } + public IPowerShellFactory PowerShellFactory { get; set; } - protected override void Greet(string databaseLocation) + protected override void Greet(string databaseLocation) + { + Log.Info("Create {0}".FormatWith(databaseLocation)); + } + + protected override void ExecuteCore() + { + var sequences = ScriptSequence.BuildSequence(); + if (sequences.Count == 0) { - Log.Info("Create {0}".FormatWith(databaseLocation)); + throw new ConfigurationErrorsException("scripts to create database not found."); } - protected override void ExecuteCore() - { - var sequences = ScriptSequence.BuildSequence(); - if (sequences.Count == 0) - { - throw new ConfigurationErrorsException("scripts to create database not found."); - } + PowerShellFactory.InitializeIfRequested(Log); - PowerShellFactory.InitializeIfRequested(Log); + foreach (var script in sequences) + { + var timer = Stopwatch.StartNew(); + Log.Info("execute {0} ...".FormatWith(script.DisplayName)); - foreach (var script in sequences) + using (Log.Indent()) { - var timer = Stopwatch.StartNew(); - Log.Info("execute {0} ...".FormatWith(script.DisplayName)); - - using (Log.Indent()) - { - Database.Execute(script); - } - - Log.Info("done in {0}".FormatWith(timer.Elapsed)); + Database.Execute(script); } + + Log.Info("done in {0}".FormatWith(timer.Elapsed)); } } } \ No newline at end of file diff --git a/Sources/SqlDatabase/Commands/DatabaseExecuteCommand.cs b/Sources/SqlDatabase/Commands/DatabaseExecuteCommand.cs index 487bce8e..395c041e 100644 --- a/Sources/SqlDatabase/Commands/DatabaseExecuteCommand.cs +++ b/Sources/SqlDatabase/Commands/DatabaseExecuteCommand.cs @@ -1,37 +1,36 @@ using System.Diagnostics; using SqlDatabase.Scripts; -namespace SqlDatabase.Commands +namespace SqlDatabase.Commands; + +internal sealed class DatabaseExecuteCommand : DatabaseCommandBase { - internal sealed class DatabaseExecuteCommand : DatabaseCommandBase + public ICreateScriptSequence ScriptSequence { get; set; } + + public IPowerShellFactory PowerShellFactory { get; set; } + + protected override void Greet(string databaseLocation) { - public ICreateScriptSequence ScriptSequence { get; set; } + Log.Info("Execute script on {0}".FormatWith(databaseLocation)); + } - public IPowerShellFactory PowerShellFactory { get; set; } + protected override void ExecuteCore() + { + var sequences = ScriptSequence.BuildSequence(); - protected override void Greet(string databaseLocation) - { - Log.Info("Execute script on {0}".FormatWith(databaseLocation)); - } + PowerShellFactory.InitializeIfRequested(Log); - protected override void ExecuteCore() + foreach (var script in sequences) { - var sequences = ScriptSequence.BuildSequence(); - - PowerShellFactory.InitializeIfRequested(Log); + var timer = Stopwatch.StartNew(); + Log.Info("execute {0} ...".FormatWith(script.DisplayName)); - foreach (var script in sequences) + using (Log.Indent()) { - var timer = Stopwatch.StartNew(); - Log.Info("execute {0} ...".FormatWith(script.DisplayName)); - - using (Log.Indent()) - { - Database.Execute(script); - } - - Log.Info("done in {0}".FormatWith(timer.Elapsed)); + Database.Execute(script); } + + Log.Info("done in {0}".FormatWith(timer.Elapsed)); } } } \ No newline at end of file diff --git a/Sources/SqlDatabase/Commands/DatabaseExportCommand.cs b/Sources/SqlDatabase/Commands/DatabaseExportCommand.cs index 26e70208..78cabddb 100644 --- a/Sources/SqlDatabase/Commands/DatabaseExportCommand.cs +++ b/Sources/SqlDatabase/Commands/DatabaseExportCommand.cs @@ -5,95 +5,94 @@ using SqlDatabase.Export; using SqlDatabase.Scripts; -namespace SqlDatabase.Commands +namespace SqlDatabase.Commands; + +internal sealed class DatabaseExportCommand : DatabaseCommandBase { - internal sealed class DatabaseExportCommand : DatabaseCommandBase - { - public ICreateScriptSequence ScriptSequence { get; set; } + public ICreateScriptSequence ScriptSequence { get; set; } - public Func OpenOutput { get; set; } + public Func OpenOutput { get; set; } - public string DestinationTableName { get; set; } + public string DestinationTableName { get; set; } - internal Func ExporterFactory { get; set; } = () => new DataExporter(); + internal Func ExporterFactory { get; set; } = () => new DataExporter(); - protected override void Greet(string databaseLocation) - { - Log.Info("Export data from {0}".FormatWith(databaseLocation)); - } + protected override void Greet(string databaseLocation) + { + Log.Info("Export data from {0}".FormatWith(databaseLocation)); + } - protected override void ExecuteCore() + protected override void ExecuteCore() + { + var sequences = ScriptSequence.BuildSequence(); + + using (var output = OpenOutput()) { - var sequences = ScriptSequence.BuildSequence(); + var readerIndex = 0; + + var exporter = ExporterFactory(); + exporter.Output = Database.Adapter.CreateSqlWriter(output); + exporter.Log = Log; - using (var output = OpenOutput()) + if (string.IsNullOrWhiteSpace(DestinationTableName)) { - var readerIndex = 0; + DestinationTableName = exporter.Output.GetDefaultTableName(); + } - var exporter = ExporterFactory(); - exporter.Output = Database.Adapter.CreateSqlWriter(output); - exporter.Log = Log; + foreach (var script in sequences) + { + var timer = Stopwatch.StartNew(); + Log.Info("export {0} ...".FormatWith(script.DisplayName)); - if (string.IsNullOrWhiteSpace(DestinationTableName)) + using (Log.Indent()) { - DestinationTableName = exporter.Output.GetDefaultTableName(); + ExportScript(exporter, script, ref readerIndex); } - foreach (var script in sequences) - { - var timer = Stopwatch.StartNew(); - Log.Info("export {0} ...".FormatWith(script.DisplayName)); - - using (Log.Indent()) - { - ExportScript(exporter, script, ref readerIndex); - } - - Log.Info("done in {0}".FormatWith(timer.Elapsed)); - } + Log.Info("done in {0}".FormatWith(timer.Elapsed)); } } + } - private static string GetExportTableName(string name, int index, int subIndex) - { - var result = new StringBuilder(20); - - if (string.IsNullOrWhiteSpace(name)) - { - result.Append("dbo.SqlDatabaseExport"); - } - else - { - result.Append(name); - } + private static string GetExportTableName(string name, int index, int subIndex) + { + var result = new StringBuilder(20); - if (index > 1) - { - result.Append(index); - } + if (string.IsNullOrWhiteSpace(name)) + { + result.Append("dbo.SqlDatabaseExport"); + } + else + { + result.Append(name); + } - if (subIndex > 1) - { - result.Append('_').Append(subIndex); - } + if (index > 1) + { + result.Append(index); + } - return result.ToString(); + if (subIndex > 1) + { + result.Append('_').Append(subIndex); } - private void ExportScript(IDataExporter exporter, IScript script, ref int readerIndex) + return result.ToString(); + } + + private void ExportScript(IDataExporter exporter, IScript script, ref int readerIndex) + { + foreach (var reader in Database.ExecuteReader(script)) { - foreach (var reader in Database.ExecuteReader(script)) - { - readerIndex++; - var readerSubIndex = 0; + readerIndex++; + var readerSubIndex = 0; - do - { - readerSubIndex++; - exporter.Export(reader, GetExportTableName(DestinationTableName, readerIndex, readerSubIndex)); - } - while (reader.NextResult()); + do + { + readerSubIndex++; + exporter.Export(reader, GetExportTableName(DestinationTableName, readerIndex, readerSubIndex)); } + while (reader.NextResult()); } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Commands/DatabaseUpgradeCommand.cs b/Sources/SqlDatabase/Commands/DatabaseUpgradeCommand.cs index b872049c..22e47719 100644 --- a/Sources/SqlDatabase/Commands/DatabaseUpgradeCommand.cs +++ b/Sources/SqlDatabase/Commands/DatabaseUpgradeCommand.cs @@ -4,90 +4,89 @@ using System.Text; using SqlDatabase.Scripts; -namespace SqlDatabase.Commands +namespace SqlDatabase.Commands; + +internal sealed class DatabaseUpgradeCommand : DatabaseCommandBase { - internal sealed class DatabaseUpgradeCommand : DatabaseCommandBase - { - public IUpgradeScriptSequence ScriptSequence { get; set; } + public IUpgradeScriptSequence ScriptSequence { get; set; } - public IPowerShellFactory PowerShellFactory { get; set; } + public IPowerShellFactory PowerShellFactory { get; set; } - protected override void Greet(string databaseLocation) + protected override void Greet(string databaseLocation) + { + Log.Info("Upgrade {0}".FormatWith(databaseLocation)); + } + + protected override void ExecuteCore() + { + var sequence = ScriptSequence.BuildSequence(); + if (sequence.Count == 0) { - Log.Info("Upgrade {0}".FormatWith(databaseLocation)); + Log.Info("the database is up-to-date."); + return; } - protected override void ExecuteCore() + if (sequence.Any(i => string.IsNullOrEmpty(i.ModuleName))) { - var sequence = ScriptSequence.BuildSequence(); - if (sequence.Count == 0) - { - Log.Info("the database is up-to-date."); - return; - } + ShowMigrationSequenceShort(sequence); + } + else + { + ShowMigrationSequenceFull(sequence); + } - if (sequence.Any(i => string.IsNullOrEmpty(i.ModuleName))) + PowerShellFactory.InitializeIfRequested(Log); + + foreach (var step in sequence) + { + var timer = Stopwatch.StartNew(); + if (string.IsNullOrEmpty(step.ModuleName)) { - ShowMigrationSequenceShort(sequence); + Log.Info("execute {0} ...".FormatWith(step.Script.DisplayName)); } else { - ShowMigrationSequenceFull(sequence); + Log.Info("execute {0} {1} ...".FormatWith(step.ModuleName, step.Script.DisplayName)); } - PowerShellFactory.InitializeIfRequested(Log); - - foreach (var step in sequence) + using (Log.Indent()) { - var timer = Stopwatch.StartNew(); - if (string.IsNullOrEmpty(step.ModuleName)) - { - Log.Info("execute {0} ...".FormatWith(step.Script.DisplayName)); - } - else - { - Log.Info("execute {0} {1} ...".FormatWith(step.ModuleName, step.Script.DisplayName)); - } - - using (Log.Indent()) - { - Database.Execute(step.Script, step.ModuleName, step.From, step.To); - } - - Log.Info("done in {0}".FormatWith(timer.Elapsed)); + Database.Execute(step.Script, step.ModuleName, step.From, step.To); } + + Log.Info("done in {0}".FormatWith(timer.Elapsed)); } + } + + private void ShowMigrationSequenceShort(IList sequence) + { + var message = new StringBuilder() + .AppendFormat("sequence: {0}", sequence[0].From); - private void ShowMigrationSequenceShort(IList sequence) + foreach (var step in sequence) { - var message = new StringBuilder() - .AppendFormat("sequence: {0}", sequence[0].From); + message.AppendFormat(" => {0}", step.To); + } - foreach (var step in sequence) - { - message.AppendFormat(" => {0}", step.To); - } + Log.Info(message.ToString()); + } - Log.Info(message.ToString()); - } + private void ShowMigrationSequenceFull(IList sequence) + { + var message = new StringBuilder() + .Append("sequence: "); - private void ShowMigrationSequenceFull(IList sequence) + for (var i = 0; i < sequence.Count; i++) { - var message = new StringBuilder() - .Append("sequence: "); - - for (var i = 0; i < sequence.Count; i++) + var step = sequence[i]; + if (i > 0) { - var step = sequence[i]; - if (i > 0) - { - message.Append("; "); - } - - message.AppendFormat("{0} {1} => {2}", step.ModuleName, step.From, step.To); + message.Append("; "); } - Log.Info(message.ToString()); + message.AppendFormat("{0} {1} => {2}", step.ModuleName, step.From, step.To); } + + Log.Info(message.ToString()); } } \ No newline at end of file diff --git a/Sources/SqlDatabase/Commands/EchoCommand.cs b/Sources/SqlDatabase/Commands/EchoCommand.cs index 826f8e2c..475be66a 100644 --- a/Sources/SqlDatabase/Commands/EchoCommand.cs +++ b/Sources/SqlDatabase/Commands/EchoCommand.cs @@ -1,19 +1,18 @@ using SqlDatabase.Configuration; -namespace SqlDatabase.Commands +namespace SqlDatabase.Commands; + +internal sealed class EchoCommand : ICommand { - internal sealed class EchoCommand : ICommand - { - public ILogger Logger { get; set; } + public ILogger Logger { get; set; } - public CommandLine Args { get; set; } + public CommandLine Args { get; set; } - public void Execute() + public void Execute() + { + foreach (var arg in Args.Original) { - foreach (var arg in Args.Original) - { - Logger.Info(arg); - } + Logger.Info(arg); } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Commands/ICommand.cs b/Sources/SqlDatabase/Commands/ICommand.cs index 51396ca2..921e301a 100644 --- a/Sources/SqlDatabase/Commands/ICommand.cs +++ b/Sources/SqlDatabase/Commands/ICommand.cs @@ -1,7 +1,6 @@ -namespace SqlDatabase.Commands +namespace SqlDatabase.Commands; + +internal interface ICommand { - internal interface ICommand - { - void Execute(); - } -} + void Execute(); +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/AppConfiguration.cs b/Sources/SqlDatabase/Configuration/AppConfiguration.cs index 281b81b0..e40b43d0 100644 --- a/Sources/SqlDatabase/Configuration/AppConfiguration.cs +++ b/Sources/SqlDatabase/Configuration/AppConfiguration.cs @@ -1,46 +1,45 @@ using System.Configuration; -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +public sealed class AppConfiguration : ConfigurationSection { - public sealed class AppConfiguration : ConfigurationSection + public const string SectionName = "sqlDatabase"; + + private const string PropertyGetCurrentVersionScript = "getCurrentVersion"; + private const string PropertySetCurrentVersionScript = "setCurrentVersion"; + private const string PropertyAssemblyScript = "assemblyScript"; + private const string PropertyVariables = "variables"; + private const string PropertyMsSql = "mssql"; + private const string PropertyPgSql = "pgsql"; + private const string PropertyMySql = "mysql"; + + [ConfigurationProperty(PropertyGetCurrentVersionScript)] + public string GetCurrentVersionScript { - public const string SectionName = "sqlDatabase"; - - private const string PropertyGetCurrentVersionScript = "getCurrentVersion"; - private const string PropertySetCurrentVersionScript = "setCurrentVersion"; - private const string PropertyAssemblyScript = "assemblyScript"; - private const string PropertyVariables = "variables"; - private const string PropertyMsSql = "mssql"; - private const string PropertyPgSql = "pgsql"; - private const string PropertyMySql = "mysql"; - - [ConfigurationProperty(PropertyGetCurrentVersionScript)] - public string GetCurrentVersionScript - { - get => (string)this[PropertyGetCurrentVersionScript]; - set => this[PropertyGetCurrentVersionScript] = value; - } - - [ConfigurationProperty(PropertySetCurrentVersionScript)] - public string SetCurrentVersionScript - { - get => (string)this[PropertySetCurrentVersionScript]; - set => this[PropertySetCurrentVersionScript] = value; - } - - [ConfigurationProperty(PropertyAssemblyScript)] - public AssemblyScriptConfiguration AssemblyScript => (AssemblyScriptConfiguration)this[PropertyAssemblyScript]; - - [ConfigurationProperty(PropertyVariables)] - public NameValueConfigurationCollection Variables => (NameValueConfigurationCollection)this[PropertyVariables]; - - [ConfigurationProperty(PropertyMsSql)] - public DatabaseConfiguration MsSql => (DatabaseConfiguration)this[PropertyMsSql]; - - [ConfigurationProperty(PropertyPgSql)] - public DatabaseConfiguration PgSql => (DatabaseConfiguration)this[PropertyPgSql]; - - [ConfigurationProperty(PropertyMySql)] - public DatabaseConfiguration MySql => (DatabaseConfiguration)this[PropertyMySql]; + get => (string)this[PropertyGetCurrentVersionScript]; + set => this[PropertyGetCurrentVersionScript] = value; } + + [ConfigurationProperty(PropertySetCurrentVersionScript)] + public string SetCurrentVersionScript + { + get => (string)this[PropertySetCurrentVersionScript]; + set => this[PropertySetCurrentVersionScript] = value; + } + + [ConfigurationProperty(PropertyAssemblyScript)] + public AssemblyScriptConfiguration AssemblyScript => (AssemblyScriptConfiguration)this[PropertyAssemblyScript]; + + [ConfigurationProperty(PropertyVariables)] + public NameValueConfigurationCollection Variables => (NameValueConfigurationCollection)this[PropertyVariables]; + + [ConfigurationProperty(PropertyMsSql)] + public DatabaseConfiguration MsSql => (DatabaseConfiguration)this[PropertyMsSql]; + + [ConfigurationProperty(PropertyPgSql)] + public DatabaseConfiguration PgSql => (DatabaseConfiguration)this[PropertyPgSql]; + + [ConfigurationProperty(PropertyMySql)] + public DatabaseConfiguration MySql => (DatabaseConfiguration)this[PropertyMySql]; } \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/Arg.cs b/Sources/SqlDatabase/Configuration/Arg.cs index 8f6a7df8..4ffe1c1d 100644 --- a/Sources/SqlDatabase/Configuration/Arg.cs +++ b/Sources/SqlDatabase/Configuration/Arg.cs @@ -1,55 +1,54 @@ -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +internal readonly struct Arg { - internal readonly struct Arg - { - internal const string Sign = "-"; + internal const string Sign = "-"; - internal const string Database = "database"; - internal const string Scripts = "from"; - internal const string InLineScript = "fromSql"; - internal const string Variable = "var"; - internal const string Configuration = "configuration"; - internal const string Transaction = "transaction"; - internal const string WhatIf = "whatIf"; - internal const string UsePowerShell = "usePowerShell"; - internal const string FolderAsModuleName = "folderAsModuleName"; + internal const string Database = "database"; + internal const string Scripts = "from"; + internal const string InLineScript = "fromSql"; + internal const string Variable = "var"; + internal const string Configuration = "configuration"; + internal const string Transaction = "transaction"; + internal const string WhatIf = "whatIf"; + internal const string UsePowerShell = "usePowerShell"; + internal const string FolderAsModuleName = "folderAsModuleName"; - internal const string ExportToTable = "toTable"; - internal const string ExportToFile = "toFile"; + internal const string ExportToTable = "toTable"; + internal const string ExportToFile = "toFile"; - internal const string Help = "help"; - internal const string HelpShort = "h"; + internal const string Help = "help"; + internal const string HelpShort = "h"; - internal const string Log = "log"; + internal const string Log = "log"; - public Arg(string key, string value) - { - IsPair = true; - Key = key; - Value = value; - } + public Arg(string key, string value) + { + IsPair = true; + Key = key; + Value = value; + } - public Arg(string value) - { - IsPair = false; - Key = null; - Value = value; - } + public Arg(string value) + { + IsPair = false; + Key = null; + Value = value; + } - public bool IsPair { get; } + public bool IsPair { get; } - public string Key { get; } + public string Key { get; } - public string Value { get; } + public string Value { get; } - public override string ToString() + public override string ToString() + { + if (IsPair) { - if (IsPair) - { - return "{0}={1}".FormatWith(Key, Value); - } - - return Value; + return "{0}={1}".FormatWith(Key, Value); } + + return Value; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/AssemblyScriptConfiguration.cs b/Sources/SqlDatabase/Configuration/AssemblyScriptConfiguration.cs index 07d20654..68d1c63d 100644 --- a/Sources/SqlDatabase/Configuration/AssemblyScriptConfiguration.cs +++ b/Sources/SqlDatabase/Configuration/AssemblyScriptConfiguration.cs @@ -1,34 +1,33 @@ using System.Configuration; -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +public sealed class AssemblyScriptConfiguration : ConfigurationElement { - public sealed class AssemblyScriptConfiguration : ConfigurationElement - { - private const string PropertyClassName = "className"; - private const string PropertyMethodName = "methodName"; + private const string PropertyClassName = "className"; + private const string PropertyMethodName = "methodName"; - public AssemblyScriptConfiguration() - { - } + public AssemblyScriptConfiguration() + { + } - public AssemblyScriptConfiguration(string className, string methodName) - { - ClassName = className; - MethodName = methodName; - } + public AssemblyScriptConfiguration(string className, string methodName) + { + ClassName = className; + MethodName = methodName; + } - [ConfigurationProperty(PropertyClassName, DefaultValue = "SqlDatabaseScript")] - public string ClassName - { - get => (string)this[PropertyClassName]; - set => this[PropertyClassName] = value; - } + [ConfigurationProperty(PropertyClassName, DefaultValue = "SqlDatabaseScript")] + public string ClassName + { + get => (string)this[PropertyClassName]; + set => this[PropertyClassName] = value; + } - [ConfigurationProperty(PropertyMethodName, DefaultValue = "Execute")] - public string MethodName - { - get => (string)this[PropertyMethodName]; - set => this[PropertyMethodName] = value; - } + [ConfigurationProperty(PropertyMethodName, DefaultValue = "Execute")] + public string MethodName + { + get => (string)this[PropertyMethodName]; + set => this[PropertyMethodName] = value; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/CommandLine.cs b/Sources/SqlDatabase/Configuration/CommandLine.cs index daf6a7cd..d123bce7 100644 --- a/Sources/SqlDatabase/Configuration/CommandLine.cs +++ b/Sources/SqlDatabase/Configuration/CommandLine.cs @@ -1,23 +1,22 @@ using System.Collections.Generic; -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +internal struct CommandLine { - internal struct CommandLine + public CommandLine(IList args, string[] original) { - public CommandLine(IList args, string[] original) - { - Args = args; - Original = original; - } + Args = args; + Original = original; + } - public CommandLine(params Arg[] args) - { - Args = args; - Original = null; - } + public CommandLine(params Arg[] args) + { + Args = args; + Original = null; + } - public IList Args { get; } + public IList Args { get; } - public string[] Original { get; } - } -} + public string[] Original { get; } +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/CommandLineBase.cs b/Sources/SqlDatabase/Configuration/CommandLineBase.cs index fe6331e8..2116d8c4 100644 --- a/Sources/SqlDatabase/Configuration/CommandLineBase.cs +++ b/Sources/SqlDatabase/Configuration/CommandLineBase.cs @@ -5,206 +5,205 @@ using SqlDatabase.IO; using SqlDatabase.Scripts; -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +internal abstract class CommandLineBase : ICommandLine { - internal abstract class CommandLineBase : ICommandLine - { - public string ConnectionString { get; set; } + public string ConnectionString { get; set; } - public IList Scripts { get; } = new List(); + public IList Scripts { get; } = new List(); - public IDictionary Variables { get; } = new Dictionary(StringComparer.OrdinalIgnoreCase); + public IDictionary Variables { get; } = new Dictionary(StringComparer.OrdinalIgnoreCase); - public string ConfigurationFile { get; set; } + public string ConfigurationFile { get; set; } - public IFileSystemFactory FileSystemFactory { get; set; } = new FileSystemFactory(); + public IFileSystemFactory FileSystemFactory { get; set; } = new FileSystemFactory(); - public void Parse(CommandLine args) + public void Parse(CommandLine args) + { + foreach (var arg in args.Args) { - foreach (var arg in args.Args) - { - ApplyArg(arg); - } - - if (string.IsNullOrWhiteSpace(ConnectionString)) - { - throw new InvalidCommandLineException("Options {0} is not specified.".FormatWith(Arg.Database)); - } + ApplyArg(arg); + } - if (Scripts.Count == 0) - { - throw new InvalidCommandLineException("Options {0} is not specified.".FormatWith(Arg.Scripts)); - } + if (string.IsNullOrWhiteSpace(ConnectionString)) + { + throw new InvalidCommandLineException("Options {0} is not specified.".FormatWith(Arg.Database)); + } - Validate(); + if (Scripts.Count == 0) + { + throw new InvalidCommandLineException("Options {0} is not specified.".FormatWith(Arg.Scripts)); } - public abstract ICommand CreateCommand(ILogger logger); + Validate(); + } + + public abstract ICommand CreateCommand(ILogger logger); - internal Database CreateDatabase(ILogger logger, IConfigurationManager configuration, TransactionMode transaction, bool whatIf) + internal Database CreateDatabase(ILogger logger, IConfigurationManager configuration, TransactionMode transaction, bool whatIf) + { + IDatabaseAdapter adapter; + try + { + adapter = DatabaseAdapterFactory.CreateAdapter(ConnectionString, configuration.SqlDatabase, logger); + } + catch (Exception ex) { - IDatabaseAdapter adapter; - try - { - adapter = DatabaseAdapterFactory.CreateAdapter(ConnectionString, configuration.SqlDatabase, logger); - } - catch (Exception ex) - { - throw new InvalidCommandLineException(Arg.Database, "Invalid connection string value.", ex); - } + throw new InvalidCommandLineException(Arg.Database, "Invalid connection string value.", ex); + } - var database = new Database - { - Adapter = adapter, - Log = logger, - Transaction = transaction, - WhatIf = whatIf - }; + var database = new Database + { + Adapter = adapter, + Log = logger, + Transaction = transaction, + WhatIf = whatIf + }; + + var configurationVariables = configuration.SqlDatabase.Variables; + foreach (var name in configurationVariables.AllKeys) + { + database.Variables.SetValue(VariableSource.ConfigurationFile, name, configurationVariables[name].Value); + } - var configurationVariables = configuration.SqlDatabase.Variables; - foreach (var name in configurationVariables.AllKeys) - { - database.Variables.SetValue(VariableSource.ConfigurationFile, name, configurationVariables[name].Value); - } + foreach (var entry in Variables) + { + database.Variables.SetValue(VariableSource.CommandLine, entry.Key, entry.Value); + } - foreach (var entry in Variables) - { - database.Variables.SetValue(VariableSource.CommandLine, entry.Key, entry.Value); - } + var invalidNames = database + .Variables + .GetNames() + .OrderBy(i => i) + .Where(i => !SqlScriptVariableParser.IsValidVariableName(i)) + .Select(i => "[{0}]".FormatWith(i)) + .ToList(); - var invalidNames = database - .Variables - .GetNames() - .OrderBy(i => i) - .Where(i => !SqlScriptVariableParser.IsValidVariableName(i)) - .Select(i => "[{0}]".FormatWith(i)) - .ToList(); + if (invalidNames.Count == 1) + { + throw new InvalidOperationException("The variable name {0} is invalid.".FormatWith(invalidNames[0])); + } - if (invalidNames.Count == 1) - { - throw new InvalidOperationException("The variable name {0} is invalid.".FormatWith(invalidNames[0])); - } + if (invalidNames.Count > 1) + { + throw new InvalidOperationException("The following variable names are invalid: {0}.".FormatWith(string.Join(", ", invalidNames))); + } - if (invalidNames.Count > 1) - { - throw new InvalidOperationException("The following variable names are invalid: {0}.".FormatWith(string.Join(", ", invalidNames))); - } + return database; + } - return database; - } + protected internal virtual void Validate() + { + } - protected internal virtual void Validate() + protected static bool TryParseSwitchParameter(Arg arg, string parameterName, out bool value) + { + if (parameterName.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) { + value = string.IsNullOrEmpty(arg.Value) || bool.Parse(arg.Value); + return true; } - protected static bool TryParseSwitchParameter(Arg arg, string parameterName, out bool value) + if (!arg.IsPair && parameterName.Equals(arg.Value, StringComparison.OrdinalIgnoreCase)) { - if (parameterName.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) - { - value = string.IsNullOrEmpty(arg.Value) || bool.Parse(arg.Value); - return true; - } + value = true; + return true; + } - if (!arg.IsPair && parameterName.Equals(arg.Value, StringComparison.OrdinalIgnoreCase)) - { - value = true; - return true; - } + value = false; + return false; + } - value = false; - return false; - } + protected static bool TryParseWhatIf(Arg arg, out bool whatIf) => TryParseSwitchParameter(arg, Arg.WhatIf, out whatIf); - protected static bool TryParseWhatIf(Arg arg, out bool whatIf) => TryParseSwitchParameter(arg, Arg.WhatIf, out whatIf); + protected virtual bool ParseArg(Arg arg) + { + return false; + } + + protected void SetInLineScript(string value) + { + var index = Scripts.Count + 1; + var script = FileSystemFactory.FromContent("from{0}.sql".FormatWith(index), value); - protected virtual bool ParseArg(Arg arg) + Scripts.Add(script); + } + + private void ApplyArg(Arg arg) + { + bool isParsed; + try { - return false; + isParsed = (arg.IsPair && TryParseKnownPair(arg)) || ParseArg(arg); } - - protected void SetInLineScript(string value) + catch (InvalidCommandLineException) { - var index = Scripts.Count + 1; - var script = FileSystemFactory.FromContent("from{0}.sql".FormatWith(index), value); - - Scripts.Add(script); + throw; } - - private void ApplyArg(Arg arg) + catch (Exception ex) { - bool isParsed; - try - { - isParsed = (arg.IsPair && TryParseKnownPair(arg)) || ParseArg(arg); - } - catch (InvalidCommandLineException) - { - throw; - } - catch (Exception ex) - { - throw new InvalidCommandLineException("Fail to parse option [{0}].".FormatWith(arg), ex); - } - - if (!isParsed) - { - throw new InvalidCommandLineException("Unknown option [{0}].".FormatWith(arg)); - } + throw new InvalidCommandLineException("Fail to parse option [{0}].".FormatWith(arg), ex); } - private bool TryParseKnownPair(Arg arg) + if (!isParsed) { - if (Arg.Database.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) - { - ConnectionString = arg.Value; - return true; - } - - if (Arg.Scripts.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) - { - SetScripts(arg.Value); - return true; - } - - if (arg.Key.StartsWith(Arg.Variable, StringComparison.OrdinalIgnoreCase)) - { - SetVariable(arg.Key.Substring(Arg.Variable.Length), arg.Value); - return true; - } + throw new InvalidCommandLineException("Unknown option [{0}].".FormatWith(arg)); + } + } - if (Arg.Configuration.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) - { - SetConfigurationFile(arg.Value); - return true; - } + private bool TryParseKnownPair(Arg arg) + { + if (Arg.Database.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) + { + ConnectionString = arg.Value; + return true; + } - return false; + if (Arg.Scripts.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) + { + SetScripts(arg.Value); + return true; } - private void SetScripts(string value) + if (arg.Key.StartsWith(Arg.Variable, StringComparison.OrdinalIgnoreCase)) { - Scripts.Add(FileSystemFactory.FileSystemInfoFromPath(value)); + SetVariable(arg.Key.Substring(Arg.Variable.Length), arg.Value); + return true; } - private void SetVariable(string name, string value) + if (Arg.Configuration.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) { - name = name?.Trim(); - if (string.IsNullOrEmpty(name)) - { - throw new InvalidCommandLineException(Arg.Variable, "Invalid variable name [{0}].".FormatWith(name)); - } + SetConfigurationFile(arg.Value); + return true; + } - if (Variables.ContainsKey(name)) - { - throw new InvalidCommandLineException(Arg.Variable, "Variable with name [{0}] is duplicated.".FormatWith(name)); - } + return false; + } - Variables.Add(name, value); + private void SetScripts(string value) + { + Scripts.Add(FileSystemFactory.FileSystemInfoFromPath(value)); + } + + private void SetVariable(string name, string value) + { + name = name?.Trim(); + if (string.IsNullOrEmpty(name)) + { + throw new InvalidCommandLineException(Arg.Variable, "Invalid variable name [{0}].".FormatWith(name)); } - private void SetConfigurationFile(string configurationFile) + if (Variables.ContainsKey(name)) { - ConfigurationFile = configurationFile; + throw new InvalidCommandLineException(Arg.Variable, "Variable with name [{0}] is duplicated.".FormatWith(name)); } + + Variables.Add(name, value); + } + + private void SetConfigurationFile(string configurationFile) + { + ConfigurationFile = configurationFile; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/CommandLineFactory.cs b/Sources/SqlDatabase/Configuration/CommandLineFactory.cs index 182288ab..b50348a0 100644 --- a/Sources/SqlDatabase/Configuration/CommandLineFactory.cs +++ b/Sources/SqlDatabase/Configuration/CommandLineFactory.cs @@ -1,98 +1,97 @@ using System; using System.Linq; -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +internal sealed class CommandLineFactory { - internal sealed class CommandLineFactory - { - internal const string CommandUpgrade = "Upgrade"; - internal const string CommandCreate = "Create"; - internal const string CommandExecute = "Execute"; - internal const string CommandExport = "Export"; - internal const string CommandEcho = "Echo"; + internal const string CommandUpgrade = "Upgrade"; + internal const string CommandCreate = "Create"; + internal const string CommandExecute = "Execute"; + internal const string CommandExport = "Export"; + internal const string CommandEcho = "Echo"; - public CommandLine Args { get; set; } + public CommandLine Args { get; set; } - public string ActiveCommandName { get; private set; } + public string ActiveCommandName { get; private set; } - public bool ShowCommandHelp { get; private set; } + public bool ShowCommandHelp { get; private set; } - public bool Bind() + public bool Bind() + { + var commandArgs = Args.Args.ToList(); + if (commandArgs.Count == 0) { - var commandArgs = Args.Args.ToList(); - if (commandArgs.Count == 0) - { - return false; - } + return false; + } - if (commandArgs[0].IsPair) - { - throw new InvalidCommandLineException(" not found."); - } + if (commandArgs[0].IsPair) + { + throw new InvalidCommandLineException(" not found."); + } - ActiveCommandName = commandArgs[0].Value; - var command = CreateCommand(ActiveCommandName); + ActiveCommandName = commandArgs[0].Value; + var command = CreateCommand(ActiveCommandName); - if (command == null) - { - throw new InvalidCommandLineException("Unknown command [{0}].".FormatWith(ActiveCommandName)); - } + if (command == null) + { + throw new InvalidCommandLineException("Unknown command [{0}].".FormatWith(ActiveCommandName)); + } - commandArgs.RemoveAt(0); + commandArgs.RemoveAt(0); + + for (var i = 0; i < commandArgs.Count; i++) + { + var arg = commandArgs[i]; - for (var i = 0; i < commandArgs.Count; i++) + if (arg.IsPair + && (Arg.Help.Equals(arg.Key, StringComparison.OrdinalIgnoreCase) + || Arg.HelpShort.Equals(arg.Key, StringComparison.OrdinalIgnoreCase))) { - var arg = commandArgs[i]; - - if (arg.IsPair - && (Arg.Help.Equals(arg.Key, StringComparison.OrdinalIgnoreCase) - || Arg.HelpShort.Equals(arg.Key, StringComparison.OrdinalIgnoreCase))) - { - ShowCommandHelp = true; - commandArgs.RemoveAt(i); - break; - } + ShowCommandHelp = true; + commandArgs.RemoveAt(i); + break; } - - Args = new CommandLine(commandArgs, Args.Original); - return true; } - public ICommandLine Resolve() + Args = new CommandLine(commandArgs, Args.Original); + return true; + } + + public ICommandLine Resolve() + { + var command = CreateCommand(ActiveCommandName); + command.Parse(Args); + return command; + } + + internal static ICommandLine CreateCommand(string name) + { + if (CommandCreate.Equals(name, StringComparison.OrdinalIgnoreCase)) { - var command = CreateCommand(ActiveCommandName); - command.Parse(Args); - return command; + return new CreateCommandLine(); } - internal static ICommandLine CreateCommand(string name) + if (CommandUpgrade.Equals(name, StringComparison.OrdinalIgnoreCase)) { - if (CommandCreate.Equals(name, StringComparison.OrdinalIgnoreCase)) - { - return new CreateCommandLine(); - } - - if (CommandUpgrade.Equals(name, StringComparison.OrdinalIgnoreCase)) - { - return new UpgradeCommandLine(); - } - - if (CommandExecute.Equals(name, StringComparison.OrdinalIgnoreCase)) - { - return new ExecuteCommandLine(); - } + return new UpgradeCommandLine(); + } - if (CommandExport.Equals(name, StringComparison.OrdinalIgnoreCase)) - { - return new ExportCommandLine(); - } + if (CommandExecute.Equals(name, StringComparison.OrdinalIgnoreCase)) + { + return new ExecuteCommandLine(); + } - if (CommandEcho.Equals(name, StringComparison.OrdinalIgnoreCase)) - { - return new EchoCommandLine(); - } + if (CommandExport.Equals(name, StringComparison.OrdinalIgnoreCase)) + { + return new ExportCommandLine(); + } - return null; + if (CommandEcho.Equals(name, StringComparison.OrdinalIgnoreCase)) + { + return new EchoCommandLine(); } + + return null; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/CommandLineParser.cs b/Sources/SqlDatabase/Configuration/CommandLineParser.cs index 7b524841..000012e8 100644 --- a/Sources/SqlDatabase/Configuration/CommandLineParser.cs +++ b/Sources/SqlDatabase/Configuration/CommandLineParser.cs @@ -1,101 +1,100 @@ using System; using System.Collections.Generic; -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +internal sealed class CommandLineParser { - internal sealed class CommandLineParser + public static string GetLogFileName(IList args) { - public static string GetLogFileName(IList args) + for (var i = 0; i < args.Count; i++) { - for (var i = 0; i < args.Count; i++) + if (ParseArg(args[i], out var value) + && IsLog(value)) { - if (ParseArg(args[i], out var value) - && IsLog(value)) - { - return value.Value; - } + return value.Value; } - - return null; } - public CommandLine Parse(params string[] args) - { - var result = new List(args.Length); - - foreach (var arg in args) - { - if (!ParseArg(arg, out var value)) - { - throw new InvalidCommandLineException("Invalid option [{0}].".FormatWith(arg)); - } - - if (!IsLog(value)) - { - result.Add(value); - } - } + return null; + } - return new CommandLine(result, args); - } + public CommandLine Parse(params string[] args) + { + var result = new List(args.Length); - internal static bool ParseArg(string input, out Arg arg) + foreach (var arg in args) { - arg = default; - - if (string.IsNullOrEmpty(input)) + if (!ParseArg(arg, out var value)) { - return false; + throw new InvalidCommandLineException("Invalid option [{0}].".FormatWith(arg)); } - if (input.StartsWith(Arg.Sign, StringComparison.OrdinalIgnoreCase)) + if (!IsLog(value)) { - if (SplitKeyValue(input, 1, out var key, out var value)) - { - arg = new Arg(key, value); - return true; - } - - return false; + result.Add(value); } - - arg = new Arg(input); - return true; } - private static bool SplitKeyValue(string keyValue, int offset, out string key, out string value) - { - keyValue = keyValue.Substring(offset); - key = keyValue; - value = null; + return new CommandLine(result, args); + } - if (key.Length == 0) - { - return false; - } + internal static bool ParseArg(string input, out Arg arg) + { + arg = default; - var index = keyValue.IndexOf("=", StringComparison.OrdinalIgnoreCase); - if (index < 0) + if (string.IsNullOrEmpty(input)) + { + return false; + } + + if (input.StartsWith(Arg.Sign, StringComparison.OrdinalIgnoreCase)) + { + if (SplitKeyValue(input, 1, out var key, out var value)) { + arg = new Arg(key, value); return true; } - if (index == 0) - { - return false; - } + return false; + } + + arg = new Arg(input); + return true; + } + + private static bool SplitKeyValue(string keyValue, int offset, out string key, out string value) + { + keyValue = keyValue.Substring(offset); + key = keyValue; + value = null; - key = keyValue.Substring(0, index).Trim(); - value = index == keyValue.Length - 1 ? null : keyValue.Substring(index + 1).Trim(); + if (key.Length == 0) + { + return false; + } + var index = keyValue.IndexOf("=", StringComparison.OrdinalIgnoreCase); + if (index < 0) + { return true; } - private static bool IsLog(Arg arg) + if (index == 0) { - return arg.IsPair - && Arg.Log.Equals(arg.Key, StringComparison.OrdinalIgnoreCase) - && !string.IsNullOrWhiteSpace(arg.Value); + return false; } + + key = keyValue.Substring(0, index).Trim(); + value = index == keyValue.Length - 1 ? null : keyValue.Substring(index + 1).Trim(); + + return true; + } + + private static bool IsLog(Arg arg) + { + return arg.IsPair + && Arg.Log.Equals(arg.Key, StringComparison.OrdinalIgnoreCase) + && !string.IsNullOrWhiteSpace(arg.Value); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/ConfigurationManager.cs b/Sources/SqlDatabase/Configuration/ConfigurationManager.cs index 5ff2689b..5e9cb067 100644 --- a/Sources/SqlDatabase/Configuration/ConfigurationManager.cs +++ b/Sources/SqlDatabase/Configuration/ConfigurationManager.cs @@ -6,103 +6,102 @@ using SqlDatabase.IO; using Manager = System.Configuration.ConfigurationManager; -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +internal sealed class ConfigurationManager : IConfigurationManager { - internal sealed class ConfigurationManager : IConfigurationManager + public AppConfiguration SqlDatabase { get; private set; } + + public static string ResolveDefaultConfigurationFile(string probingPath) { - public AppConfiguration SqlDatabase { get; private set; } + var fileName = ResolveFile(new FileSystemFolder(probingPath)).Name; - public static string ResolveDefaultConfigurationFile(string probingPath) - { - var fileName = ResolveFile(new FileSystemFolder(probingPath)).Name; + return Path.Combine(probingPath, fileName); + } - return Path.Combine(probingPath, fileName); + public void LoadFrom(string configurationFile) + { + try + { + var info = string.IsNullOrEmpty(configurationFile) ? null : FileSystemFactory.FileSystemInfoFromPath(configurationFile); + LoadFrom(info); } - - public void LoadFrom(string configurationFile) + catch (Exception ex) when ((ex as IOException) == null) { - try - { - var info = string.IsNullOrEmpty(configurationFile) ? null : FileSystemFactory.FileSystemInfoFromPath(configurationFile); - LoadFrom(info); - } - catch (Exception ex) when ((ex as IOException) == null) - { - throw new ConfigurationErrorsException("Fail to load configuration from [{0}].".FormatWith(configurationFile), ex); - } + throw new ConfigurationErrorsException("Fail to load configuration from [{0}].".FormatWith(configurationFile), ex); } + } - internal void LoadFrom(IFileSystemInfo info) + internal void LoadFrom(IFileSystemInfo info) + { + AppConfiguration section; + if (info == null) { - AppConfiguration section; - if (info == null) - { - section = LoadCurrent(); - } - else - { - section = Load(info); - } - - SqlDatabase = section ?? new AppConfiguration(); + section = LoadCurrent(); } - - private static AppConfiguration LoadCurrent() + else { - return (AppConfiguration)Manager.GetSection(AppConfiguration.SectionName); + section = Load(info); } - private static AppConfiguration Load(IFileSystemInfo info) - { - var file = ResolveFile(info); + SqlDatabase = section ?? new AppConfiguration(); + } - var tempFile = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); - try - { - using (var destination = new FileStream(tempFile, FileMode.Create, FileAccess.ReadWrite)) - using (var source = file.OpenRead()) - { - source.CopyTo(destination); - } + private static AppConfiguration LoadCurrent() + { + return (AppConfiguration)Manager.GetSection(AppConfiguration.SectionName); + } + + private static AppConfiguration Load(IFileSystemInfo info) + { + var file = ResolveFile(info); - var configuration = Manager.OpenMappedExeConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = tempFile }, ConfigurationUserLevel.None); - return (AppConfiguration)configuration.GetSection(AppConfiguration.SectionName); + var tempFile = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); + try + { + using (var destination = new FileStream(tempFile, FileMode.Create, FileAccess.ReadWrite)) + using (var source = file.OpenRead()) + { + source.CopyTo(destination); } - finally + + var configuration = Manager.OpenMappedExeConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = tempFile }, ConfigurationUserLevel.None); + return (AppConfiguration)configuration.GetSection(AppConfiguration.SectionName); + } + finally + { + if (File.Exists(tempFile)) { - if (File.Exists(tempFile)) - { - File.Delete(tempFile); - } + File.Delete(tempFile); } } + } - private static IFile ResolveFile(IFileSystemInfo info) + private static IFile ResolveFile(IFileSystemInfo info) + { + IFile file; + if (info is IFolder folder) { - IFile file; - if (info is IFolder folder) - { - const string Name1 = "SqlDatabase.exe.config"; - const string Name2 = "SqlDatabase.dll.config"; + const string Name1 = "SqlDatabase.exe.config"; + const string Name2 = "SqlDatabase.dll.config"; - var fileName = Path.GetFileName(typeof(ConfigurationManager).Assembly.Location) + ".config"; - file = folder - .GetFiles() - .Where(i => Name1.Equals(i.Name, StringComparison.OrdinalIgnoreCase) || Name2.Equals(i.Name, StringComparison.OrdinalIgnoreCase)) - .OrderByDescending(i => i.Name, StringComparer.OrdinalIgnoreCase) - .FirstOrDefault(); + var fileName = Path.GetFileName(typeof(ConfigurationManager).Assembly.Location) + ".config"; + file = folder + .GetFiles() + .Where(i => Name1.Equals(i.Name, StringComparison.OrdinalIgnoreCase) || Name2.Equals(i.Name, StringComparison.OrdinalIgnoreCase)) + .OrderByDescending(i => i.Name, StringComparer.OrdinalIgnoreCase) + .FirstOrDefault(); - if (file == null) - { - throw new FileNotFoundException("Configuration file {0} not found in {1}.".FormatWith(fileName, info.Name)); - } - } - else + if (file == null) { - file = (IFile)info; + throw new FileNotFoundException("Configuration file {0} not found in {1}.".FormatWith(fileName, info.Name)); } - - return file; } + else + { + file = (IFile)info; + } + + return file; } } \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/CreateCommandLine.cs b/Sources/SqlDatabase/Configuration/CreateCommandLine.cs index 39ed2e8e..bf27f249 100644 --- a/Sources/SqlDatabase/Configuration/CreateCommandLine.cs +++ b/Sources/SqlDatabase/Configuration/CreateCommandLine.cs @@ -3,59 +3,58 @@ using SqlDatabase.Scripts; using SqlDatabase.Scripts.PowerShellInternal; -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +internal sealed class CreateCommandLine : CommandLineBase { - internal sealed class CreateCommandLine : CommandLineBase - { - public string UsePowerShell { get; set; } + public string UsePowerShell { get; set; } - public bool WhatIf { get; set; } + public bool WhatIf { get; set; } - public override ICommand CreateCommand(ILogger logger) - { - var configuration = new ConfigurationManager(); - configuration.LoadFrom(ConfigurationFile); + public override ICommand CreateCommand(ILogger logger) + { + var configuration = new ConfigurationManager(); + configuration.LoadFrom(ConfigurationFile); - var powerShellFactory = PowerShellFactory.Create(UsePowerShell); - var database = CreateDatabase(logger, configuration, TransactionMode.None, WhatIf); + var powerShellFactory = PowerShellFactory.Create(UsePowerShell); + var database = CreateDatabase(logger, configuration, TransactionMode.None, WhatIf); - var sequence = new CreateScriptSequence - { - ScriptFactory = new ScriptFactory - { - AssemblyScriptConfiguration = configuration.SqlDatabase.AssemblyScript, - PowerShellFactory = powerShellFactory, - TextReader = database.Adapter.CreateSqlTextReader() - }, - Sources = Scripts.ToArray() - }; - - return new DatabaseCreateCommand + var sequence = new CreateScriptSequence + { + ScriptFactory = new ScriptFactory { - Log = logger, - Database = database, - ScriptSequence = sequence, - PowerShellFactory = powerShellFactory - }; - } - - protected override bool ParseArg(Arg arg) + AssemblyScriptConfiguration = configuration.SqlDatabase.AssemblyScript, + PowerShellFactory = powerShellFactory, + TextReader = database.Adapter.CreateSqlTextReader() + }, + Sources = Scripts.ToArray() + }; + + return new DatabaseCreateCommand { + Log = logger, + Database = database, + ScriptSequence = sequence, + PowerShellFactory = powerShellFactory + }; + } + + protected override bool ParseArg(Arg arg) + { #if NETCOREAPP || NET5_0_OR_GREATER - if (Arg.UsePowerShell.Equals(arg.Key, System.StringComparison.OrdinalIgnoreCase)) - { - UsePowerShell = arg.Value; - return true; - } + if (Arg.UsePowerShell.Equals(arg.Key, System.StringComparison.OrdinalIgnoreCase)) + { + UsePowerShell = arg.Value; + return true; + } #endif - if (TryParseWhatIf(arg, out var value)) - { - WhatIf = value; - return true; - } - - return false; + if (TryParseWhatIf(arg, out var value)) + { + WhatIf = value; + return true; } + + return false; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/DatabaseConfiguration.cs b/Sources/SqlDatabase/Configuration/DatabaseConfiguration.cs index 87697cd3..ce3fda3c 100644 --- a/Sources/SqlDatabase/Configuration/DatabaseConfiguration.cs +++ b/Sources/SqlDatabase/Configuration/DatabaseConfiguration.cs @@ -1,28 +1,27 @@ using System.Configuration; -namespace SqlDatabase.Configuration -{ - public sealed class DatabaseConfiguration : ConfigurationElement - { - private const string PropertyGetCurrentVersionScript = "getCurrentVersion"; - private const string PropertySetCurrentVersionScript = "setCurrentVersion"; - private const string PropertyVariables = "variables"; +namespace SqlDatabase.Configuration; - [ConfigurationProperty(PropertyGetCurrentVersionScript)] - public string GetCurrentVersionScript - { - get => (string)this[PropertyGetCurrentVersionScript]; - set => this[PropertyGetCurrentVersionScript] = value; - } +public sealed class DatabaseConfiguration : ConfigurationElement +{ + private const string PropertyGetCurrentVersionScript = "getCurrentVersion"; + private const string PropertySetCurrentVersionScript = "setCurrentVersion"; + private const string PropertyVariables = "variables"; - [ConfigurationProperty(PropertySetCurrentVersionScript)] - public string SetCurrentVersionScript - { - get => (string)this[PropertySetCurrentVersionScript]; - set => this[PropertySetCurrentVersionScript] = value; - } + [ConfigurationProperty(PropertyGetCurrentVersionScript)] + public string GetCurrentVersionScript + { + get => (string)this[PropertyGetCurrentVersionScript]; + set => this[PropertyGetCurrentVersionScript] = value; + } - [ConfigurationProperty(PropertyVariables)] - public NameValueConfigurationCollection Variables => (NameValueConfigurationCollection)this[PropertyVariables]; + [ConfigurationProperty(PropertySetCurrentVersionScript)] + public string SetCurrentVersionScript + { + get => (string)this[PropertySetCurrentVersionScript]; + set => this[PropertySetCurrentVersionScript] = value; } + + [ConfigurationProperty(PropertyVariables)] + public NameValueConfigurationCollection Variables => (NameValueConfigurationCollection)this[PropertyVariables]; } \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/EchoCommandLine.cs b/Sources/SqlDatabase/Configuration/EchoCommandLine.cs index b7466067..83092902 100644 --- a/Sources/SqlDatabase/Configuration/EchoCommandLine.cs +++ b/Sources/SqlDatabase/Configuration/EchoCommandLine.cs @@ -1,23 +1,22 @@ using SqlDatabase.Commands; -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +internal sealed class EchoCommandLine : ICommandLine { - internal sealed class EchoCommandLine : ICommandLine - { - private CommandLine _args; + private CommandLine _args; - public void Parse(CommandLine args) - { - _args = args; - } + public void Parse(CommandLine args) + { + _args = args; + } - public ICommand CreateCommand(ILogger logger) + public ICommand CreateCommand(ILogger logger) + { + return new EchoCommand { - return new EchoCommand - { - Logger = logger, - Args = _args - }; - } + Logger = logger, + Args = _args + }; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/ExecuteCommandLine.cs b/Sources/SqlDatabase/Configuration/ExecuteCommandLine.cs index c56bae2f..3fc11ed2 100644 --- a/Sources/SqlDatabase/Configuration/ExecuteCommandLine.cs +++ b/Sources/SqlDatabase/Configuration/ExecuteCommandLine.cs @@ -4,82 +4,81 @@ using SqlDatabase.Scripts; using SqlDatabase.Scripts.PowerShellInternal; -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +internal sealed class ExecuteCommandLine : CommandLineBase { - internal sealed class ExecuteCommandLine : CommandLineBase - { - public TransactionMode Transaction { get; set; } + public TransactionMode Transaction { get; set; } - public string UsePowerShell { get; set; } + public string UsePowerShell { get; set; } - public bool WhatIf { get; set; } + public bool WhatIf { get; set; } - public override ICommand CreateCommand(ILogger logger) - { - var configuration = new ConfigurationManager(); - configuration.LoadFrom(ConfigurationFile); + public override ICommand CreateCommand(ILogger logger) + { + var configuration = new ConfigurationManager(); + configuration.LoadFrom(ConfigurationFile); - var powerShellFactory = PowerShellFactory.Create(UsePowerShell); - var database = CreateDatabase(logger, configuration, TransactionMode.None, WhatIf); + var powerShellFactory = PowerShellFactory.Create(UsePowerShell); + var database = CreateDatabase(logger, configuration, TransactionMode.None, WhatIf); - var sequence = new CreateScriptSequence + var sequence = new CreateScriptSequence + { + ScriptFactory = new ScriptFactory { - ScriptFactory = new ScriptFactory - { - AssemblyScriptConfiguration = configuration.SqlDatabase.AssemblyScript, - PowerShellFactory = powerShellFactory, - TextReader = database.Adapter.CreateSqlTextReader() - }, - Sources = Scripts.ToArray() - }; + AssemblyScriptConfiguration = configuration.SqlDatabase.AssemblyScript, + PowerShellFactory = powerShellFactory, + TextReader = database.Adapter.CreateSqlTextReader() + }, + Sources = Scripts.ToArray() + }; - return new DatabaseExecuteCommand - { - Log = logger, - Database = database, - ScriptSequence = sequence, - PowerShellFactory = powerShellFactory - }; - } + return new DatabaseExecuteCommand + { + Log = logger, + Database = database, + ScriptSequence = sequence, + PowerShellFactory = powerShellFactory + }; + } - protected override bool ParseArg(Arg arg) + protected override bool ParseArg(Arg arg) + { + if (Arg.Transaction.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) { - if (Arg.Transaction.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) - { - SetTransaction(arg.Value); - return true; - } + SetTransaction(arg.Value); + return true; + } - if (Arg.InLineScript.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) - { - SetInLineScript(arg.Value); - return true; - } + if (Arg.InLineScript.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) + { + SetInLineScript(arg.Value); + return true; + } #if NETCOREAPP || NET5_0_OR_GREATER - if (Arg.UsePowerShell.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) - { - UsePowerShell = arg.Value; - return true; - } + if (Arg.UsePowerShell.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) + { + UsePowerShell = arg.Value; + return true; + } #endif - if (TryParseWhatIf(arg, out var value)) - { - WhatIf = value; - return true; - } - - return false; + if (TryParseWhatIf(arg, out var value)) + { + WhatIf = value; + return true; } - private void SetTransaction(string modeName) - { - if (!Enum.TryParse(modeName, true, out var mode)) - { - throw new InvalidCommandLineException(Arg.Transaction, "Unknown transaction mode [{0}].".FormatWith(modeName)); - } + return false; + } - Transaction = mode; + private void SetTransaction(string modeName) + { + if (!Enum.TryParse(modeName, true, out var mode)) + { + throw new InvalidCommandLineException(Arg.Transaction, "Unknown transaction mode [{0}].".FormatWith(modeName)); } + + Transaction = mode; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/ExportCommandLine.cs b/Sources/SqlDatabase/Configuration/ExportCommandLine.cs index ac83453e..b3821385 100644 --- a/Sources/SqlDatabase/Configuration/ExportCommandLine.cs +++ b/Sources/SqlDatabase/Configuration/ExportCommandLine.cs @@ -5,79 +5,78 @@ using SqlDatabase.Export; using SqlDatabase.Scripts; -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +internal sealed class ExportCommandLine : CommandLineBase { - internal sealed class ExportCommandLine : CommandLineBase + public string DestinationTableName { get; set; } + + public string DestinationFileName { get; set; } + + public override ICommand CreateCommand(ILogger logger) { - public string DestinationTableName { get; set; } + var configuration = new ConfigurationManager(); + configuration.LoadFrom(ConfigurationFile); - public string DestinationFileName { get; set; } + var database = CreateDatabase(logger, configuration, TransactionMode.None, false); - public override ICommand CreateCommand(ILogger logger) + var sequence = new CreateScriptSequence { - var configuration = new ConfigurationManager(); - configuration.LoadFrom(ConfigurationFile); + ScriptFactory = new ScriptFactory + { + AssemblyScriptConfiguration = configuration.SqlDatabase.AssemblyScript, + TextReader = database.Adapter.CreateSqlTextReader() + }, + Sources = Scripts.ToArray() + }; - var database = CreateDatabase(logger, configuration, TransactionMode.None, false); + return new DatabaseExportCommand + { + Log = WrapLogger(logger), + OpenOutput = CreateOutput(), + Database = database, + ScriptSequence = sequence, + DestinationTableName = DestinationTableName + }; + } - var sequence = new CreateScriptSequence - { - ScriptFactory = new ScriptFactory - { - AssemblyScriptConfiguration = configuration.SqlDatabase.AssemblyScript, - TextReader = database.Adapter.CreateSqlTextReader() - }, - Sources = Scripts.ToArray() - }; + internal Func CreateOutput() + { + var fileName = DestinationFileName; - return new DatabaseExportCommand - { - Log = WrapLogger(logger), - OpenOutput = CreateOutput(), - Database = database, - ScriptSequence = sequence, - DestinationTableName = DestinationTableName - }; + if (string.IsNullOrEmpty(fileName)) + { + return () => Console.Out; } - internal Func CreateOutput() - { - var fileName = DestinationFileName; + return () => new StreamWriter(fileName, false); + } - if (string.IsNullOrEmpty(fileName)) - { - return () => Console.Out; - } + internal ILogger WrapLogger(ILogger logger) + { + return string.IsNullOrEmpty(DestinationFileName) ? new DataExportLogger(logger) : logger; + } - return () => new StreamWriter(fileName, false); + protected override bool ParseArg(Arg arg) + { + if (Arg.ExportToTable.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) + { + DestinationTableName = arg.Value; + return true; } - internal ILogger WrapLogger(ILogger logger) + if (Arg.ExportToFile.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) { - return string.IsNullOrEmpty(DestinationFileName) ? new DataExportLogger(logger) : logger; + DestinationFileName = arg.Value; + return true; } - protected override bool ParseArg(Arg arg) + if (Arg.InLineScript.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) { - if (Arg.ExportToTable.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) - { - DestinationTableName = arg.Value; - return true; - } - - if (Arg.ExportToFile.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) - { - DestinationFileName = arg.Value; - return true; - } - - if (Arg.InLineScript.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) - { - SetInLineScript(arg.Value); - return true; - } - - return false; + SetInLineScript(arg.Value); + return true; } + + return false; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/GenericCommandLine.cs b/Sources/SqlDatabase/Configuration/GenericCommandLine.cs index 23e676bc..120f26e3 100644 --- a/Sources/SqlDatabase/Configuration/GenericCommandLine.cs +++ b/Sources/SqlDatabase/Configuration/GenericCommandLine.cs @@ -1,32 +1,31 @@ using System; using System.Collections.Generic; -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +public sealed class GenericCommandLine { - public sealed class GenericCommandLine - { - public string Command { get; set; } + public string Command { get; set; } - public string Connection { get; set; } + public string Connection { get; set; } - public TransactionMode Transaction { get; set; } + public TransactionMode Transaction { get; set; } - public IList Scripts { get; } = new List(); + public IList Scripts { get; } = new List(); - public IList InLineScript { get; } = new List(); + public IList InLineScript { get; } = new List(); - public IDictionary Variables { get; } = new Dictionary(StringComparer.OrdinalIgnoreCase); + public IDictionary Variables { get; } = new Dictionary(StringComparer.OrdinalIgnoreCase); - public string ConfigurationFile { get; set; } + public string ConfigurationFile { get; set; } - public string ExportToTable { get; set; } + public string ExportToTable { get; set; } - public string ExportToFile { get; set; } + public string ExportToFile { get; set; } - public bool WhatIf { get; set; } + public bool WhatIf { get; set; } - public bool FolderAsModuleName { get; set; } + public bool FolderAsModuleName { get; set; } - public string LogFileName { get; set; } - } + public string LogFileName { get; set; } } \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/GenericCommandLineBuilder.cs b/Sources/SqlDatabase/Configuration/GenericCommandLineBuilder.cs index a3280b9e..189ce217 100644 --- a/Sources/SqlDatabase/Configuration/GenericCommandLineBuilder.cs +++ b/Sources/SqlDatabase/Configuration/GenericCommandLineBuilder.cs @@ -1,196 +1,195 @@ using System.Collections.Generic; using System.Text; -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +internal sealed class GenericCommandLineBuilder { - internal sealed class GenericCommandLineBuilder + public GenericCommandLineBuilder() + : this(new GenericCommandLine()) + { + } + + public GenericCommandLineBuilder(GenericCommandLine line) + { + Line = line; + } + + internal GenericCommandLine Line { get; } + + public GenericCommandLineBuilder SetCommand(string command) + { + Line.Command = command; + return this; + } + + public GenericCommandLineBuilder SetConnection(string connectionString) + { + Line.Connection = connectionString; + return this; + } + + public GenericCommandLineBuilder SetScripts(string value) + { + Line.Scripts.Add(value); + + return this; + } + + public GenericCommandLineBuilder SetInLineScript(string value) + { + Line.InLineScript.Add(value); + + return this; + } + + public GenericCommandLineBuilder SetTransaction(TransactionMode mode) { - public GenericCommandLineBuilder() - : this(new GenericCommandLine()) + Line.Transaction = mode; + return this; + } + + public GenericCommandLineBuilder SetVariable(string name, string value) + { + name = name?.Trim(); + if (string.IsNullOrEmpty(name)) { + throw new InvalidCommandLineException(Arg.Variable, "Invalid variable name [{0}].".FormatWith(name)); } - public GenericCommandLineBuilder(GenericCommandLine line) + if (Line.Variables.ContainsKey(name)) { - Line = line; + throw new InvalidCommandLineException(Arg.Variable, "Variable with name [{0}] is duplicated.".FormatWith(name)); } - internal GenericCommandLine Line { get; } + Line.Variables.Add(name, value); - public GenericCommandLineBuilder SetCommand(string command) - { - Line.Command = command; - return this; - } + return this; + } - public GenericCommandLineBuilder SetConnection(string connectionString) + public GenericCommandLineBuilder SetVariable(string nameValue) + { + if (!CommandLineParser.ParseArg(Arg.Sign + nameValue, out var arg) + || !arg.IsPair) { - Line.Connection = connectionString; - return this; + throw new InvalidCommandLineException(Arg.Variable, "Invalid variable value definition [{0}].".FormatWith(nameValue)); } - public GenericCommandLineBuilder SetScripts(string value) - { - Line.Scripts.Add(value); + return SetVariable(arg.Key, arg.Value); + } - return this; - } + public GenericCommandLineBuilder SetConfigurationFile(string configurationFile) + { + Line.ConfigurationFile = configurationFile; + return this; + } - public GenericCommandLineBuilder SetInLineScript(string value) - { - Line.InLineScript.Add(value); + public GenericCommandLineBuilder SetExportToTable(string name) + { + Line.ExportToTable = name; + return this; + } - return this; - } + public GenericCommandLineBuilder SetExportToFile(string fileName) + { + Line.ExportToFile = fileName; + return this; + } - public GenericCommandLineBuilder SetTransaction(TransactionMode mode) - { - Line.Transaction = mode; - return this; - } + public GenericCommandLineBuilder SetWhatIf(bool value) + { + Line.WhatIf = value; + return this; + } - public GenericCommandLineBuilder SetVariable(string name, string value) - { - name = name?.Trim(); - if (string.IsNullOrEmpty(name)) - { - throw new InvalidCommandLineException(Arg.Variable, "Invalid variable name [{0}].".FormatWith(name)); - } + public GenericCommandLineBuilder SetFolderAsModuleName(bool value) + { + Line.FolderAsModuleName = value; + return this; + } - if (Line.Variables.ContainsKey(name)) - { - throw new InvalidCommandLineException(Arg.Variable, "Variable with name [{0}] is duplicated.".FormatWith(name)); - } + public GenericCommandLineBuilder SetLogFileName(string fileName) + { + Line.LogFileName = fileName; + return this; + } - Line.Variables.Add(name, value); + public GenericCommandLine Build() + { + return Line; + } - return this; - } + public string[] BuildArray() + { + var cmd = Build(); - public GenericCommandLineBuilder SetVariable(string nameValue) + var result = new List { - if (!CommandLineParser.ParseArg(Arg.Sign + nameValue, out var arg) - || !arg.IsPair) - { - throw new InvalidCommandLineException(Arg.Variable, "Invalid variable value definition [{0}].".FormatWith(nameValue)); - } + cmd.Command, + CombineArg(Arg.Database, cmd.Connection) + }; - return SetVariable(arg.Key, arg.Value); + foreach (var script in cmd.Scripts) + { + result.Add(CombineArg(Arg.Scripts, script)); } - public GenericCommandLineBuilder SetConfigurationFile(string configurationFile) + foreach (var script in cmd.InLineScript) { - Line.ConfigurationFile = configurationFile; - return this; + result.Add(CombineArg(Arg.InLineScript, script)); } - public GenericCommandLineBuilder SetExportToTable(string name) + if (cmd.Transaction != default(TransactionMode)) { - Line.ExportToTable = name; - return this; + result.Add(CombineArg(Arg.Transaction, cmd.Transaction.ToString())); } - public GenericCommandLineBuilder SetExportToFile(string fileName) + if (!string.IsNullOrEmpty(cmd.ConfigurationFile)) { - Line.ExportToFile = fileName; - return this; + result.Add(CombineArg(Arg.Configuration, cmd.ConfigurationFile)); } - public GenericCommandLineBuilder SetWhatIf(bool value) + if (!string.IsNullOrEmpty(cmd.ExportToTable)) { - Line.WhatIf = value; - return this; + result.Add(CombineArg(Arg.ExportToTable, cmd.ExportToTable)); } - public GenericCommandLineBuilder SetFolderAsModuleName(bool value) + if (!string.IsNullOrEmpty(cmd.ExportToFile)) { - Line.FolderAsModuleName = value; - return this; + result.Add(CombineArg(Arg.ExportToFile, cmd.ExportToFile)); } - public GenericCommandLineBuilder SetLogFileName(string fileName) + foreach (var entry in cmd.Variables) { - Line.LogFileName = fileName; - return this; + result.Add(CombineArg(Arg.Variable + entry.Key, entry.Value)); } - public GenericCommandLine Build() + if (cmd.WhatIf) { - return Line; + result.Add(CombineArg(Arg.WhatIf, cmd.WhatIf.ToString())); } - public string[] BuildArray() + if (cmd.FolderAsModuleName) { - var cmd = Build(); - - var result = new List - { - cmd.Command, - CombineArg(Arg.Database, cmd.Connection) - }; - - foreach (var script in cmd.Scripts) - { - result.Add(CombineArg(Arg.Scripts, script)); - } - - foreach (var script in cmd.InLineScript) - { - result.Add(CombineArg(Arg.InLineScript, script)); - } - - if (cmd.Transaction != default(TransactionMode)) - { - result.Add(CombineArg(Arg.Transaction, cmd.Transaction.ToString())); - } - - if (!string.IsNullOrEmpty(cmd.ConfigurationFile)) - { - result.Add(CombineArg(Arg.Configuration, cmd.ConfigurationFile)); - } - - if (!string.IsNullOrEmpty(cmd.ExportToTable)) - { - result.Add(CombineArg(Arg.ExportToTable, cmd.ExportToTable)); - } - - if (!string.IsNullOrEmpty(cmd.ExportToFile)) - { - result.Add(CombineArg(Arg.ExportToFile, cmd.ExportToFile)); - } - - foreach (var entry in cmd.Variables) - { - result.Add(CombineArg(Arg.Variable + entry.Key, entry.Value)); - } - - if (cmd.WhatIf) - { - result.Add(CombineArg(Arg.WhatIf, cmd.WhatIf.ToString())); - } - - if (cmd.FolderAsModuleName) - { - result.Add(CombineArg(Arg.FolderAsModuleName, cmd.FolderAsModuleName.ToString())); - } - - if (!string.IsNullOrEmpty(cmd.LogFileName)) - { - result.Add(CombineArg(Arg.Log, cmd.LogFileName)); - } - - return result.ToArray(); + result.Add(CombineArg(Arg.FolderAsModuleName, cmd.FolderAsModuleName.ToString())); } - private static string CombineArg(string key, string value) + if (!string.IsNullOrEmpty(cmd.LogFileName)) { - var result = new StringBuilder() - .Append(Arg.Sign) - .Append(key) - .Append("=") - .Append(value); - - return result.ToString(); + result.Add(CombineArg(Arg.Log, cmd.LogFileName)); } + + return result.ToArray(); + } + + private static string CombineArg(string key, string value) + { + var result = new StringBuilder() + .Append(Arg.Sign) + .Append(key) + .Append("=") + .Append(value); + + return result.ToString(); } } \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/ICommandLine.cs b/Sources/SqlDatabase/Configuration/ICommandLine.cs index 1a92a581..fbf5ef51 100644 --- a/Sources/SqlDatabase/Configuration/ICommandLine.cs +++ b/Sources/SqlDatabase/Configuration/ICommandLine.cs @@ -1,11 +1,10 @@ using SqlDatabase.Commands; -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +internal interface ICommandLine { - internal interface ICommandLine - { - void Parse(CommandLine args); + void Parse(CommandLine args); - ICommand CreateCommand(ILogger logger); - } -} + ICommand CreateCommand(ILogger logger); +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/IConfigurationManager.cs b/Sources/SqlDatabase/Configuration/IConfigurationManager.cs index 78d58022..2bd67569 100644 --- a/Sources/SqlDatabase/Configuration/IConfigurationManager.cs +++ b/Sources/SqlDatabase/Configuration/IConfigurationManager.cs @@ -1,7 +1,6 @@ -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +public interface IConfigurationManager { - public interface IConfigurationManager - { - AppConfiguration SqlDatabase { get; } - } -} + AppConfiguration SqlDatabase { get; } +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/InvalidCommandLineException.cs b/Sources/SqlDatabase/Configuration/InvalidCommandLineException.cs index b9c3d1b2..75ef6fae 100644 --- a/Sources/SqlDatabase/Configuration/InvalidCommandLineException.cs +++ b/Sources/SqlDatabase/Configuration/InvalidCommandLineException.cs @@ -1,50 +1,49 @@ using System; using System.Runtime.Serialization; -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +[Serializable] +public class InvalidCommandLineException : SystemException { - [Serializable] - public class InvalidCommandLineException : SystemException + public InvalidCommandLineException() + { + } + + public InvalidCommandLineException(string message) + : base(message) { - public InvalidCommandLineException() - { - } - - public InvalidCommandLineException(string message) - : base(message) - { - } - - public InvalidCommandLineException(string message, Exception inner) - : base(message, inner) - { - } - - public InvalidCommandLineException(string argument, string message) - : base(message) - { - Argument = argument; - } - - public InvalidCommandLineException(string argument, string message, Exception inner) - : base(message, inner) - { - Argument = argument; - } - - protected InvalidCommandLineException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - Argument = info.GetString(nameof(Argument)); - } - - public string Argument { get; } - - public override void GetObjectData(SerializationInfo info, StreamingContext context) - { - base.GetObjectData(info, context); - - info.AddValue(nameof(Argument), Argument); - } + } + + public InvalidCommandLineException(string message, Exception inner) + : base(message, inner) + { + } + + public InvalidCommandLineException(string argument, string message) + : base(message) + { + Argument = argument; + } + + public InvalidCommandLineException(string argument, string message, Exception inner) + : base(message, inner) + { + Argument = argument; + } + + protected InvalidCommandLineException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + Argument = info.GetString(nameof(Argument)); + } + + public string Argument { get; } + + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + base.GetObjectData(info, context); + + info.AddValue(nameof(Argument), Argument); } } \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/TransactionMode.cs b/Sources/SqlDatabase/Configuration/TransactionMode.cs index a7671adc..c816290f 100644 --- a/Sources/SqlDatabase/Configuration/TransactionMode.cs +++ b/Sources/SqlDatabase/Configuration/TransactionMode.cs @@ -1,8 +1,7 @@ -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +public enum TransactionMode { - public enum TransactionMode - { - None, - PerStep - } + None, + PerStep } \ No newline at end of file diff --git a/Sources/SqlDatabase/Configuration/UpgradeCommandLine.cs b/Sources/SqlDatabase/Configuration/UpgradeCommandLine.cs index 3ad85b4a..3b2ada29 100644 --- a/Sources/SqlDatabase/Configuration/UpgradeCommandLine.cs +++ b/Sources/SqlDatabase/Configuration/UpgradeCommandLine.cs @@ -5,89 +5,88 @@ using SqlDatabase.Scripts.PowerShellInternal; using SqlDatabase.Scripts.UpgradeInternal; -namespace SqlDatabase.Configuration +namespace SqlDatabase.Configuration; + +internal sealed class UpgradeCommandLine : CommandLineBase { - internal sealed class UpgradeCommandLine : CommandLineBase - { - public TransactionMode Transaction { get; set; } + public TransactionMode Transaction { get; set; } - public string UsePowerShell { get; set; } + public string UsePowerShell { get; set; } - public bool FolderAsModuleName { get; set; } + public bool FolderAsModuleName { get; set; } - public bool WhatIf { get; set; } + public bool WhatIf { get; set; } - public override ICommand CreateCommand(ILogger logger) - { - var configuration = new ConfigurationManager(); - configuration.LoadFrom(ConfigurationFile); + public override ICommand CreateCommand(ILogger logger) + { + var configuration = new ConfigurationManager(); + configuration.LoadFrom(ConfigurationFile); - var database = CreateDatabase(logger, configuration, Transaction, WhatIf); - var powerShellFactory = PowerShellFactory.Create(UsePowerShell); + var database = CreateDatabase(logger, configuration, Transaction, WhatIf); + var powerShellFactory = PowerShellFactory.Create(UsePowerShell); - var sequence = new UpgradeScriptSequence - { - ScriptFactory = new ScriptFactory - { - AssemblyScriptConfiguration = configuration.SqlDatabase.AssemblyScript, - PowerShellFactory = powerShellFactory, - TextReader = database.Adapter.CreateSqlTextReader() - }, - VersionResolver = new ModuleVersionResolver { Database = database, Log = logger }, - Sources = Scripts.ToArray(), - Log = logger, - FolderAsModuleName = FolderAsModuleName, - WhatIf = WhatIf - }; - - return new DatabaseUpgradeCommand + var sequence = new UpgradeScriptSequence + { + ScriptFactory = new ScriptFactory { - Log = logger, - Database = database, - ScriptSequence = sequence, - PowerShellFactory = powerShellFactory - }; - } + AssemblyScriptConfiguration = configuration.SqlDatabase.AssemblyScript, + PowerShellFactory = powerShellFactory, + TextReader = database.Adapter.CreateSqlTextReader() + }, + VersionResolver = new ModuleVersionResolver { Database = database, Log = logger }, + Sources = Scripts.ToArray(), + Log = logger, + FolderAsModuleName = FolderAsModuleName, + WhatIf = WhatIf + }; - protected override bool ParseArg(Arg arg) + return new DatabaseUpgradeCommand { - if (Arg.Transaction.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) - { - SetTransaction(arg.Value); - return true; - } + Log = logger, + Database = database, + ScriptSequence = sequence, + PowerShellFactory = powerShellFactory + }; + } - if (TryParseWhatIf(arg, out var value)) - { - WhatIf = value; - return true; - } + protected override bool ParseArg(Arg arg) + { + if (Arg.Transaction.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) + { + SetTransaction(arg.Value); + return true; + } + + if (TryParseWhatIf(arg, out var value)) + { + WhatIf = value; + return true; + } #if NETCOREAPP || NET5_0_OR_GREATER - if (Arg.UsePowerShell.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) - { - UsePowerShell = arg.Value; - return true; - } + if (Arg.UsePowerShell.Equals(arg.Key, StringComparison.OrdinalIgnoreCase)) + { + UsePowerShell = arg.Value; + return true; + } #endif - if (TryParseSwitchParameter(arg, Arg.FolderAsModuleName, out value)) - { - FolderAsModuleName = value; - return true; - } - - return false; + if (TryParseSwitchParameter(arg, Arg.FolderAsModuleName, out value)) + { + FolderAsModuleName = value; + return true; } - private void SetTransaction(string modeName) - { - if (!Enum.TryParse(modeName, true, out var mode)) - { - throw new InvalidCommandLineException(Arg.Transaction, "Unknown transaction mode [{0}].".FormatWith(modeName)); - } + return false; + } - Transaction = mode; + private void SetTransaction(string modeName) + { + if (!Enum.TryParse(modeName, true, out var mode)) + { + throw new InvalidCommandLineException(Arg.Transaction, "Unknown transaction mode [{0}].".FormatWith(modeName)); } + + Transaction = mode; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/ExitCode.cs b/Sources/SqlDatabase/ExitCode.cs index b75f2ba7..4e8cff83 100644 --- a/Sources/SqlDatabase/ExitCode.cs +++ b/Sources/SqlDatabase/ExitCode.cs @@ -1,11 +1,10 @@ -namespace SqlDatabase +namespace SqlDatabase; + +internal static class ExitCode { - internal static class ExitCode - { - public const int Ok = 0; + public const int Ok = 0; - public const int InvalidCommandLine = 1; + public const int InvalidCommandLine = 1; - public const int ExecutionErrors = 2; - } + public const int ExecutionErrors = 2; } \ No newline at end of file diff --git a/Sources/SqlDatabase/Export/DataExportLogger.cs b/Sources/SqlDatabase/Export/DataExportLogger.cs index 385357dd..b7a1be15 100644 --- a/Sources/SqlDatabase/Export/DataExportLogger.cs +++ b/Sources/SqlDatabase/Export/DataExportLogger.cs @@ -2,46 +2,45 @@ using System.IO; using System.Text; -namespace SqlDatabase.Export +namespace SqlDatabase.Export; + +internal sealed class DataExportLogger : ILogger { - internal sealed class DataExportLogger : ILogger + private readonly ILogger _origin; + + public DataExportLogger(ILogger origin) { - private readonly ILogger _origin; + _origin = origin; + } - public DataExportLogger(ILogger origin) - { - _origin = origin; - } + public void Error(string message) + { + var escaped = new StringBuilder(message.Length); - public void Error(string message) + using (var reader = new StringReader(message)) { - var escaped = new StringBuilder(message.Length); - - using (var reader = new StringReader(message)) + string line; + while ((line = reader.ReadLine()) != null) { - string line; - while ((line = reader.ReadLine()) != null) + if (escaped.Length > 0) { - if (escaped.Length > 0) - { - escaped.AppendLine(); - } - - escaped.Append("-- ").Append(line); + escaped.AppendLine(); } - } - _origin.Error(escaped.ToString()); + escaped.Append("-- ").Append(line); + } } - public void Info(string message) - { - // ignore - } + _origin.Error(escaped.ToString()); + } - public IDisposable Indent() - { - return _origin.Indent(); - } + public void Info(string message) + { + // ignore + } + + public IDisposable Indent() + { + return _origin.Indent(); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Export/DataExporter.cs b/Sources/SqlDatabase/Export/DataExporter.cs index e3769a09..7122635b 100644 --- a/Sources/SqlDatabase/Export/DataExporter.cs +++ b/Sources/SqlDatabase/Export/DataExporter.cs @@ -1,137 +1,136 @@ using System.Data; -namespace SqlDatabase.Export +namespace SqlDatabase.Export; + +internal sealed class DataExporter : IDataExporter { - internal sealed class DataExporter : IDataExporter - { - public SqlWriterBase Output { get; set; } + public SqlWriterBase Output { get; set; } - public int MaxInsertBatchSize { get; set; } = 500; + public int MaxInsertBatchSize { get; set; } = 500; - public ILogger Log { get; set; } + public ILogger Log { get; set; } - public void Export(IDataReader source, string tableName) + public void Export(IDataReader source, string tableName) + { + ExportTable table; + using (var metadata = source.GetSchemaTable()) { - ExportTable table; - using (var metadata = source.GetSchemaTable()) - { - table = Output.ReadSchemaTable(metadata, tableName); - } + table = Output.ReadSchemaTable(metadata, tableName); + } - CreateTable(table); + CreateTable(table); - Output.Line(); + Output.Line(); - var batchNum = 0; - var rowNum = 0; - while (source.Read()) + var batchNum = 0; + var rowNum = 0; + while (source.Read()) + { + if (rowNum == 0) { - if (rowNum == 0) + if (batchNum > 0) { - if (batchNum > 0) - { - Output.BatchSeparator().Line(); - } - - WriteInsertHeader(table); - } - else - { - Output.Text(" ,"); + Output.BatchSeparator().Line(); } - Output.Text("("); - - for (var i = 0; i < table.Columns.Count; i++) - { - if (i > 0) - { - Output.Text(", "); - } - - Output.Value(source[i], table.Columns[i].SqlDataTypeName); - } + WriteInsertHeader(table); + } + else + { + Output.Text(" ,"); + } - Output.Line(")"); - rowNum++; + Output.Text("("); - if (rowNum == MaxInsertBatchSize) + for (var i = 0; i < table.Columns.Count; i++) + { + if (i > 0) { - batchNum++; - rowNum = 0; - - Log.Info("{0} rows".FormatWith(batchNum * MaxInsertBatchSize)); + Output.Text(", "); } + + Output.Value(source[i], table.Columns[i].SqlDataTypeName); } - Output.BatchSeparator(); - if (rowNum > 0) + Output.Line(")"); + rowNum++; + + if (rowNum == MaxInsertBatchSize) { - Log.Info("{0} rows".FormatWith((batchNum * MaxInsertBatchSize) + rowNum)); + batchNum++; + rowNum = 0; + + Log.Info("{0} rows".FormatWith(batchNum * MaxInsertBatchSize)); } } - private void CreateTable(ExportTable table) + Output.BatchSeparator(); + if (rowNum > 0) { - Output - .Text("CREATE TABLE ") - .Text(table.Name) - .Line() - .Line("("); + Log.Info("{0} rows".FormatWith((batchNum * MaxInsertBatchSize) + rowNum)); + } + } - for (var i = 0; i < table.Columns.Count; i++) - { - var column = table.Columns[i]; + private void CreateTable(ExportTable table) + { + Output + .Text("CREATE TABLE ") + .Text(table.Name) + .Line() + .Line("("); - Output.Text(" "); - if (i > 0) - { - Output.Text(","); - } + for (var i = 0; i < table.Columns.Count; i++) + { + var column = table.Columns[i]; - Output - .Name(column.Name) - .Text(" ") - .DataType(column.SqlDataTypeName, column.Size, column.NumericPrecision ?? 0, column.NumericScale ?? 0) - .Text(" "); + Output.Text(" "); + if (i > 0) + { + Output.Text(","); + } - if (!column.AllowNull) - { - Output.Text("NOT "); - } + Output + .Name(column.Name) + .Text(" ") + .DataType(column.SqlDataTypeName, column.Size, column.NumericPrecision ?? 0, column.NumericScale ?? 0) + .Text(" "); - Output - .Null() - .Line(); + if (!column.AllowNull) + { + Output.Text("NOT "); } Output - .Line(")") - .BatchSeparator(); + .Null() + .Line(); } - private void WriteInsertHeader(ExportTable table) - { - Output - .Text("INSERT INTO ") - .Text(table.Name) - .Text("("); + Output + .Line(")") + .BatchSeparator(); + } - for (var i = 0; i < table.Columns.Count; i++) - { - var column = table.Columns[i]; + private void WriteInsertHeader(ExportTable table) + { + Output + .Text("INSERT INTO ") + .Text(table.Name) + .Text("("); - if (i > 0) - { - Output.Text(", "); - } + for (var i = 0; i < table.Columns.Count; i++) + { + var column = table.Columns[i]; - Output.Name(column.Name); + if (i > 0) + { + Output.Text(", "); } - Output - .Line(")") - .Text("VALUES "); + Output.Name(column.Name); } + + Output + .Line(")") + .Text("VALUES "); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Export/DataReaderTools.cs b/Sources/SqlDatabase/Export/DataReaderTools.cs index 1c796ac9..4926625c 100644 --- a/Sources/SqlDatabase/Export/DataReaderTools.cs +++ b/Sources/SqlDatabase/Export/DataReaderTools.cs @@ -1,17 +1,16 @@ using System; -namespace SqlDatabase.Export +namespace SqlDatabase.Export; + +internal static class DataReaderTools { - internal static class DataReaderTools + public static object CleanValue(object value) { - public static object CleanValue(object value) + if (value == null || Convert.IsDBNull(value)) { - if (value == null || Convert.IsDBNull(value)) - { - return null; - } - - return value; + return null; } + + return value; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Export/ExportTable.cs b/Sources/SqlDatabase/Export/ExportTable.cs index 921d90db..7d2c5660 100644 --- a/Sources/SqlDatabase/Export/ExportTable.cs +++ b/Sources/SqlDatabase/Export/ExportTable.cs @@ -1,11 +1,10 @@ using System.Collections.Generic; -namespace SqlDatabase.Export +namespace SqlDatabase.Export; + +internal sealed class ExportTable { - internal sealed class ExportTable - { - public string Name { get; set; } + public string Name { get; set; } - public IList Columns { get; } = new List(); - } -} + public IList Columns { get; } = new List(); +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Export/ExportTableColumn.cs b/Sources/SqlDatabase/Export/ExportTableColumn.cs index 5eec42c0..9f6843f9 100644 --- a/Sources/SqlDatabase/Export/ExportTableColumn.cs +++ b/Sources/SqlDatabase/Export/ExportTableColumn.cs @@ -1,22 +1,21 @@ -namespace SqlDatabase.Export +namespace SqlDatabase.Export; + +internal struct ExportTableColumn { - internal struct ExportTableColumn - { - public string Name { get; set; } + public string Name { get; set; } - public string SqlDataTypeName { get; set; } + public string SqlDataTypeName { get; set; } - public int Size { get; set; } + public int Size { get; set; } - public int? NumericPrecision { get; set; } + public int? NumericPrecision { get; set; } - public int? NumericScale { get; set; } + public int? NumericScale { get; set; } - public bool AllowNull { get; set; } + public bool AllowNull { get; set; } - public override string ToString() - { - return "{0} {1}({2})".FormatWith(Name, SqlDataTypeName, Size); - } + public override string ToString() + { + return "{0} {1}({2})".FormatWith(Name, SqlDataTypeName, Size); } } \ No newline at end of file diff --git a/Sources/SqlDatabase/Export/IDataExporter.cs b/Sources/SqlDatabase/Export/IDataExporter.cs index 50861431..5cbddd36 100644 --- a/Sources/SqlDatabase/Export/IDataExporter.cs +++ b/Sources/SqlDatabase/Export/IDataExporter.cs @@ -1,13 +1,12 @@ using System.Data; -namespace SqlDatabase.Export +namespace SqlDatabase.Export; + +internal interface IDataExporter { - internal interface IDataExporter - { - SqlWriterBase Output { get; set; } + SqlWriterBase Output { get; set; } - ILogger Log { get; set; } + ILogger Log { get; set; } - void Export(IDataReader source, string tableName); - } -} + void Export(IDataReader source, string tableName); +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Export/SqlWriterBase.cs b/Sources/SqlDatabase/Export/SqlWriterBase.cs index a0ce7ce3..e1c93206 100644 --- a/Sources/SqlDatabase/Export/SqlWriterBase.cs +++ b/Sources/SqlDatabase/Export/SqlWriterBase.cs @@ -2,96 +2,95 @@ using System.Data; using System.IO; -namespace SqlDatabase.Export +namespace SqlDatabase.Export; + +internal abstract class SqlWriterBase : IDisposable { - internal abstract class SqlWriterBase : IDisposable + public const char Q = '\''; + + protected SqlWriterBase(TextWriter output) { - public const char Q = '\''; + Output = output; + } - protected SqlWriterBase(TextWriter output) - { - Output = output; - } + public TextWriter Output { get; } - public TextWriter Output { get; } + public void Dispose() + { + Output.Dispose(); + } - public void Dispose() - { - Output.Dispose(); - } + public SqlWriterBase Line(string value = null) + { + Output.WriteLine(value); + return this; + } - public SqlWriterBase Line(string value = null) - { - Output.WriteLine(value); - return this; - } + public SqlWriterBase Text(string value) + { + Output.Write(value); + return this; + } - public SqlWriterBase Text(string value) - { - Output.Write(value); - return this; - } + public SqlWriterBase TextFormat(string format, params object[] args) + { + Output.Write(format, args); + return this; + } - public SqlWriterBase TextFormat(string format, params object[] args) - { - Output.Write(format, args); - return this; - } + public abstract SqlWriterBase Name(string value); - public abstract SqlWriterBase Name(string value); + public abstract SqlWriterBase BatchSeparator(); - public abstract SqlWriterBase BatchSeparator(); + public abstract SqlWriterBase DataType(string typeName, int size, int precision, int scale); - public abstract SqlWriterBase DataType(string typeName, int size, int precision, int scale); + public SqlWriterBase Null() + { + Output.Write("NULL"); + return this; + } - public SqlWriterBase Null() + public SqlWriterBase Value(object value, string typeNameHint = null) + { + value = DataReaderTools.CleanValue(value); + if (value == null) { - Output.Write("NULL"); + Null(); return this; } - public SqlWriterBase Value(object value, string typeNameHint = null) + if (!TryWriteValue(value, typeNameHint)) { - value = DataReaderTools.CleanValue(value); - if (value == null) - { - Null(); - return this; - } + throw new NotSupportedException("Type [{0}] is not supported.".FormatWith(value.GetType())); + } - if (!TryWriteValue(value, typeNameHint)) - { - throw new NotSupportedException("Type [{0}] is not supported.".FormatWith(value.GetType())); - } + return this; + } - return this; - } + public abstract ExportTable ReadSchemaTable(DataTable metadata, string tableName); - public abstract ExportTable ReadSchemaTable(DataTable metadata, string tableName); + public abstract string GetDefaultTableName(); - public abstract string GetDefaultTableName(); + protected abstract bool TryWriteValue(object value, string typeNameHint); - protected abstract bool TryWriteValue(object value, string typeNameHint); + protected void ValueString(string value, char q = Q) + { + Output.Write(q); + WriteEscapedString(value); + Output.Write(q); + } - protected void ValueString(string value, char q = Q) + protected void WriteEscapedString(string value) + { + for (var i = 0; i < value.Length; i++) { - Output.Write(q); - WriteEscapedString(value); - Output.Write(q); - } + var c = value[i]; + Output.Write(c); - protected void WriteEscapedString(string value) - { - for (var i = 0; i < value.Length; i++) + if (c == '\'') { - var c = value[i]; - Output.Write(c); - - if (c == '\'') - { - Output.Write(Q); - } + Output.Write(Q); } } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/ILogger.cs b/Sources/SqlDatabase/ILogger.cs index af85f0d0..758015ec 100644 --- a/Sources/SqlDatabase/ILogger.cs +++ b/Sources/SqlDatabase/ILogger.cs @@ -1,13 +1,12 @@ using System; -namespace SqlDatabase +namespace SqlDatabase; + +public interface ILogger { - public interface ILogger - { - void Error(string message); + void Error(string message); - void Info(string message); + void Info(string message); - IDisposable Indent(); - } + IDisposable Indent(); } \ No newline at end of file diff --git a/Sources/SqlDatabase/IO/FileSystemFactory.cs b/Sources/SqlDatabase/IO/FileSystemFactory.cs index 95a3214d..80a25681 100644 --- a/Sources/SqlDatabase/IO/FileSystemFactory.cs +++ b/Sources/SqlDatabase/IO/FileSystemFactory.cs @@ -3,99 +3,98 @@ using System.IO; using System.Linq; -namespace SqlDatabase.IO +namespace SqlDatabase.IO; + +internal sealed class FileSystemFactory : IFileSystemFactory { - internal sealed class FileSystemFactory : IFileSystemFactory + public static IFileSystemInfo FileSystemInfoFromPath(string path) { - public static IFileSystemInfo FileSystemInfoFromPath(string path) + path = FileTools.RootPath(path); + + if (File.Exists(path)) { - path = FileTools.RootPath(path); + return FileTools.IsZip(path) ? (IFileSystemInfo)new ZipFolder(path) : new FileSystemFile(path); + } - if (File.Exists(path)) - { - return FileTools.IsZip(path) ? (IFileSystemInfo)new ZipFolder(path) : new FileSystemFile(path); - } + if (Directory.Exists(path)) + { + return new FileSystemFolder(path); + } + + IFolder entryPoint = null; + var items = new List(); - if (Directory.Exists(path)) + while (!string.IsNullOrEmpty(path)) + { + entryPoint = TryToResolveEntryPoint(path); + if (entryPoint != null) { - return new FileSystemFolder(path); + break; } - IFolder entryPoint = null; - var items = new List(); + items.Insert(0, Path.GetFileName(path)); + path = Path.GetDirectoryName(path); + } - while (!string.IsNullOrEmpty(path)) - { - entryPoint = TryToResolveEntryPoint(path); - if (entryPoint != null) - { - break; - } - - items.Insert(0, Path.GetFileName(path)); - path = Path.GetDirectoryName(path); - } + if (entryPoint == null) + { + throw new IOException("Directory {0} not found.".FormatWith(path)); + } + for (var i = 0; i < items.Count - 1; i++) + { + var name = items[i]; + path = Path.Combine(path, name); + + entryPoint = entryPoint.GetFolders().FirstOrDefault(f => name.Equals(f.Name, StringComparison.OrdinalIgnoreCase)); if (entryPoint == null) { throw new IOException("Directory {0} not found.".FormatWith(path)); } + } - for (var i = 0; i < items.Count - 1; i++) - { - var name = items[i]; - path = Path.Combine(path, name); - - entryPoint = entryPoint.GetFolders().FirstOrDefault(f => name.Equals(f.Name, StringComparison.OrdinalIgnoreCase)); - if (entryPoint == null) - { - throw new IOException("Directory {0} not found.".FormatWith(path)); - } - } + var resultName = items.Last(); + path = Path.Combine(path, resultName); - var resultName = items.Last(); - path = Path.Combine(path, resultName); + var file = entryPoint.GetFiles().FirstOrDefault(f => resultName.Equals(f.Name, StringComparison.OrdinalIgnoreCase)); + if (file != null) + { + return file; + } - var file = entryPoint.GetFiles().FirstOrDefault(f => resultName.Equals(f.Name, StringComparison.OrdinalIgnoreCase)); - if (file != null) - { - return file; - } + var folder = entryPoint.GetFolders().FirstOrDefault(f => resultName.Equals(f.Name, StringComparison.OrdinalIgnoreCase)); + if (folder == null) + { + throw new IOException("File or folder {0} not found.".FormatWith(path)); + } - var folder = entryPoint.GetFolders().FirstOrDefault(f => resultName.Equals(f.Name, StringComparison.OrdinalIgnoreCase)); - if (folder == null) - { - throw new IOException("File or folder {0} not found.".FormatWith(path)); - } + return folder; + } - return folder; - } + IFileSystemInfo IFileSystemFactory.FileSystemInfoFromPath(string path) => FileSystemInfoFromPath(path); - IFileSystemInfo IFileSystemFactory.FileSystemInfoFromPath(string path) => FileSystemInfoFromPath(path); + public IFileSystemInfo FromContent(string name, string content) + { + return new InLineScriptFile(name, content); + } - public IFileSystemInfo FromContent(string name, string content) + private static IFolder TryToResolveEntryPoint(string path) + { + if (Directory.Exists(path)) { - return new InLineScriptFile(name, content); + return new FileSystemFolder(path); } - private static IFolder TryToResolveEntryPoint(string path) + if (File.Exists(path)) { - if (Directory.Exists(path)) + if (!FileTools.IsZip(path)) { - return new FileSystemFolder(path); + throw new NotSupportedException("File format [{0}] is not supported as .zip container.".FormatWith(Path.GetExtension(path))); } - if (File.Exists(path)) - { - if (!FileTools.IsZip(path)) - { - throw new NotSupportedException("File format [{0}] is not supported as .zip container.".FormatWith(Path.GetExtension(path))); - } - - return new ZipFolder(path); - } - - return null; + return new ZipFolder(path); } + + return null; } } \ No newline at end of file diff --git a/Sources/SqlDatabase/IO/FileSystemFile.cs b/Sources/SqlDatabase/IO/FileSystemFile.cs index 23acb73d..2008c808 100644 --- a/Sources/SqlDatabase/IO/FileSystemFile.cs +++ b/Sources/SqlDatabase/IO/FileSystemFile.cs @@ -1,27 +1,26 @@ using System.IO; -namespace SqlDatabase.IO +namespace SqlDatabase.IO; + +internal sealed class FileSystemFile : IFile { - internal sealed class FileSystemFile : IFile + public FileSystemFile(string location) { - public FileSystemFile(string location) - { - Location = location; - Name = Path.GetFileName(location); - } + Location = location; + Name = Path.GetFileName(location); + } - public string Name { get; } + public string Name { get; } - public string Location { get; } + public string Location { get; } - public IFolder GetParent() - { - return new FileSystemFolder(Path.GetDirectoryName(Location)); - } + public IFolder GetParent() + { + return new FileSystemFolder(Path.GetDirectoryName(Location)); + } - public Stream OpenRead() - { - return File.OpenRead(Location); - } + public Stream OpenRead() + { + return File.OpenRead(Location); } } \ No newline at end of file diff --git a/Sources/SqlDatabase/IO/FileSystemFolder.cs b/Sources/SqlDatabase/IO/FileSystemFolder.cs index 4149d1eb..14047d43 100644 --- a/Sources/SqlDatabase/IO/FileSystemFolder.cs +++ b/Sources/SqlDatabase/IO/FileSystemFolder.cs @@ -2,41 +2,40 @@ using System.IO; using System.Linq; -namespace SqlDatabase.IO +namespace SqlDatabase.IO; + +internal sealed class FileSystemFolder : IFolder { - internal sealed class FileSystemFolder : IFolder + public FileSystemFolder(string location) + { + Location = location; + Name = Path.GetFileName(location); + } + + public string Name { get; } + + public string Location { get; } + + public IEnumerable GetFolders() + { + var folders = Directory + .GetDirectories(Location) + .Select(i => new FileSystemFolder(i)) + .Cast(); + + var files = FileTools + .GetZipExtensions() + .SelectMany(i => Directory.GetFiles(Location, "*" + i)) + .Select(i => new ZipFolder(i)); + + return folders.Concat(files); + } + + public IEnumerable GetFiles() { - public FileSystemFolder(string location) - { - Location = location; - Name = Path.GetFileName(location); - } - - public string Name { get; } - - public string Location { get; } - - public IEnumerable GetFolders() - { - var folders = Directory - .GetDirectories(Location) - .Select(i => new FileSystemFolder(i)) - .Cast(); - - var files = FileTools - .GetZipExtensions() - .SelectMany(i => Directory.GetFiles(Location, "*" + i)) - .Select(i => new ZipFolder(i)); - - return folders.Concat(files); - } - - public IEnumerable GetFiles() - { - return Directory - .GetFiles(Location) - .Where(i => !FileTools.IsZip(i)) - .Select(i => new FileSystemFile(i)); - } + return Directory + .GetFiles(Location) + .Where(i => !FileTools.IsZip(i)) + .Select(i => new FileSystemFile(i)); } } \ No newline at end of file diff --git a/Sources/SqlDatabase/IO/FileTools.cs b/Sources/SqlDatabase/IO/FileTools.cs index 1b8efea5..891b1706 100644 --- a/Sources/SqlDatabase/IO/FileTools.cs +++ b/Sources/SqlDatabase/IO/FileTools.cs @@ -2,42 +2,41 @@ using System.Collections.Generic; using System.IO; -namespace SqlDatabase.IO +namespace SqlDatabase.IO; + +internal static class FileTools { - internal static class FileTools - { - private const string ZipExtension = ".zip"; - private const string NuGetExtension = ".nupkg"; + private const string ZipExtension = ".zip"; + private const string NuGetExtension = ".nupkg"; - public static string RootPath(string path) + public static string RootPath(string path) + { + if (string.IsNullOrEmpty(path)) { - if (string.IsNullOrEmpty(path)) - { - return AppDomain.CurrentDomain.BaseDirectory; - } - - if (!Path.IsPathRooted(path)) - { - return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, path); - } - - return path; + return AppDomain.CurrentDomain.BaseDirectory; } - public static IEnumerable GetZipExtensions() + if (!Path.IsPathRooted(path)) { - return new[] - { - ZipExtension, - NuGetExtension - }; + return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, path); } - public static bool IsZip(string path) + return path; + } + + public static IEnumerable GetZipExtensions() + { + return new[] { - var ext = Path.GetExtension(path); - return ZipExtension.Equals(ext, StringComparison.OrdinalIgnoreCase) - || NuGetExtension.Equals(ext, StringComparison.OrdinalIgnoreCase); - } + ZipExtension, + NuGetExtension + }; + } + + public static bool IsZip(string path) + { + var ext = Path.GetExtension(path); + return ZipExtension.Equals(ext, StringComparison.OrdinalIgnoreCase) + || NuGetExtension.Equals(ext, StringComparison.OrdinalIgnoreCase); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/IO/IFile.cs b/Sources/SqlDatabase/IO/IFile.cs index 96cf351c..dfa709f2 100644 --- a/Sources/SqlDatabase/IO/IFile.cs +++ b/Sources/SqlDatabase/IO/IFile.cs @@ -1,11 +1,10 @@ using System.IO; -namespace SqlDatabase.IO +namespace SqlDatabase.IO; + +public interface IFile : IFileSystemInfo { - public interface IFile : IFileSystemInfo - { - IFolder GetParent(); + IFolder GetParent(); - Stream OpenRead(); - } + Stream OpenRead(); } \ No newline at end of file diff --git a/Sources/SqlDatabase/IO/IFileSystemFactory.cs b/Sources/SqlDatabase/IO/IFileSystemFactory.cs index 496e5dba..895e9405 100644 --- a/Sources/SqlDatabase/IO/IFileSystemFactory.cs +++ b/Sources/SqlDatabase/IO/IFileSystemFactory.cs @@ -1,9 +1,8 @@ -namespace SqlDatabase.IO +namespace SqlDatabase.IO; + +internal interface IFileSystemFactory { - internal interface IFileSystemFactory - { - IFileSystemInfo FileSystemInfoFromPath(string path); + IFileSystemInfo FileSystemInfoFromPath(string path); - IFileSystemInfo FromContent(string name, string content); - } -} + IFileSystemInfo FromContent(string name, string content); +} \ No newline at end of file diff --git a/Sources/SqlDatabase/IO/IFileSystemInfo.cs b/Sources/SqlDatabase/IO/IFileSystemInfo.cs index 422c4405..067b12fc 100644 --- a/Sources/SqlDatabase/IO/IFileSystemInfo.cs +++ b/Sources/SqlDatabase/IO/IFileSystemInfo.cs @@ -1,7 +1,6 @@ -namespace SqlDatabase.IO +namespace SqlDatabase.IO; + +public interface IFileSystemInfo { - public interface IFileSystemInfo - { - string Name { get; } - } -} + string Name { get; } +} \ No newline at end of file diff --git a/Sources/SqlDatabase/IO/IFolder.cs b/Sources/SqlDatabase/IO/IFolder.cs index cad1655f..381ec61a 100644 --- a/Sources/SqlDatabase/IO/IFolder.cs +++ b/Sources/SqlDatabase/IO/IFolder.cs @@ -1,11 +1,10 @@ using System.Collections.Generic; -namespace SqlDatabase.IO +namespace SqlDatabase.IO; + +public interface IFolder : IFileSystemInfo { - public interface IFolder : IFileSystemInfo - { - IEnumerable GetFolders(); + IEnumerable GetFolders(); - IEnumerable GetFiles(); - } + IEnumerable GetFiles(); } \ No newline at end of file diff --git a/Sources/SqlDatabase/IO/InLineScriptFile.cs b/Sources/SqlDatabase/IO/InLineScriptFile.cs index 387cc47d..af7af432 100644 --- a/Sources/SqlDatabase/IO/InLineScriptFile.cs +++ b/Sources/SqlDatabase/IO/InLineScriptFile.cs @@ -1,25 +1,24 @@ using System.IO; using System.Text; -namespace SqlDatabase.IO +namespace SqlDatabase.IO; + +internal sealed class InLineScriptFile : IFile { - internal sealed class InLineScriptFile : IFile + public InLineScriptFile(string name, string content) { - public InLineScriptFile(string name, string content) - { - Name = name; - Content = content; - } + Name = name; + Content = content; + } - public string Name { get; } + public string Name { get; } - public string Content { get; } + public string Content { get; } - public IFolder GetParent() => null; + public IFolder GetParent() => null; - public Stream OpenRead() - { - return new MemoryStream(Encoding.UTF8.GetBytes(Content)); - } + public Stream OpenRead() + { + return new MemoryStream(Encoding.UTF8.GetBytes(Content)); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/IO/ZipEntryFolder.cs b/Sources/SqlDatabase/IO/ZipEntryFolder.cs index dfa290f2..eba581f0 100644 --- a/Sources/SqlDatabase/IO/ZipEntryFolder.cs +++ b/Sources/SqlDatabase/IO/ZipEntryFolder.cs @@ -2,27 +2,26 @@ using System.Collections.Generic; using System.Diagnostics; -namespace SqlDatabase.IO +namespace SqlDatabase.IO; + +[DebuggerDisplay("{Name}")] +internal sealed class ZipEntryFolder : IFolder { - [DebuggerDisplay("{Name}")] - internal sealed class ZipEntryFolder : IFolder + public ZipEntryFolder(string name) { - public ZipEntryFolder(string name) - { - Name = name; + Name = name; - FolderByName = new Dictionary(StringComparer.OrdinalIgnoreCase); - Files = new List(); - } + FolderByName = new Dictionary(StringComparer.OrdinalIgnoreCase); + Files = new List(); + } - public string Name { get; } + public string Name { get; } - public IDictionary FolderByName { get; } + public IDictionary FolderByName { get; } - public IList Files { get; } + public IList Files { get; } - public IEnumerable GetFolders() => FolderByName.Values; + public IEnumerable GetFolders() => FolderByName.Values; - public IEnumerable GetFiles() => Files; - } -} + public IEnumerable GetFiles() => Files; +} \ No newline at end of file diff --git a/Sources/SqlDatabase/IO/ZipFolder.cs b/Sources/SqlDatabase/IO/ZipFolder.cs index b0b2f87b..f0dda263 100644 --- a/Sources/SqlDatabase/IO/ZipFolder.cs +++ b/Sources/SqlDatabase/IO/ZipFolder.cs @@ -5,108 +5,107 @@ using System.IO.Compression; using System.Linq; -namespace SqlDatabase.IO +namespace SqlDatabase.IO; + +[DebuggerDisplay("{Name}")] +internal sealed class ZipFolder : IFolder { - [DebuggerDisplay("{Name}")] - internal sealed class ZipFolder : IFolder - { - private readonly ZipFolder _parent; - private IFolder _tree; + private readonly ZipFolder _parent; + private IFolder _tree; - public ZipFolder(string fileName) - : this(null, fileName) - { - } + public ZipFolder(string fileName) + : this(null, fileName) + { + } - public ZipFolder(ZipFolder parent, string zipEntryFullName) - { - _parent = parent; + public ZipFolder(ZipFolder parent, string zipEntryFullName) + { + _parent = parent; - Name = Path.GetFileName(zipEntryFullName); - FileName = zipEntryFullName; - } + Name = Path.GetFileName(zipEntryFullName); + FileName = zipEntryFullName; + } - public string Name { get; } + public string Name { get; } - public string FileName { get; } + public string FileName { get; } - public IEnumerable GetFolders() => BuildOrGetTree().GetFolders(); + public IEnumerable GetFolders() => BuildOrGetTree().GetFolders(); - public IEnumerable GetFiles() => BuildOrGetTree().GetFiles(); + public IEnumerable GetFiles() => BuildOrGetTree().GetFiles(); - internal ZipArchive OpenRead() + internal ZipArchive OpenRead() + { + if (_parent == null) { - if (_parent == null) - { - return ZipFile.OpenRead(FileName); - } - - var file = new ZipFolderFile(_parent, _parent, FileName); - return new ZipArchive(file.OpenRead(), ZipArchiveMode.Read, false); + return ZipFile.OpenRead(FileName); } - private IFolder BuildOrGetTree() + var file = new ZipFolderFile(_parent, _parent, FileName); + return new ZipArchive(file.OpenRead(), ZipArchiveMode.Read, false); + } + + private IFolder BuildOrGetTree() + { + if (_tree == null) { - if (_tree == null) + using (var zip = OpenRead()) { - using (var zip = OpenRead()) - { - _tree = BuildTree(zip.Entries); - } + _tree = BuildTree(zip.Entries); } - - return _tree; } - private IFolder BuildTree(IEnumerable entries) + return _tree; + } + + private IFolder BuildTree(IEnumerable entries) + { + /* + 1/ + 1/11.txt + 2/ + 2/2.txt + 2/2.2/2.2.txt + inner.zip + */ + + var tree = new ZipEntryFolder(Name); + + foreach (var entry in entries) { - /* - 1/ - 1/11.txt - 2/ - 2/2.txt - 2/2.2/2.2.txt - inner.zip - */ - - var tree = new ZipEntryFolder(Name); - - foreach (var entry in entries) - { - var owner = tree; - var path = entry.FullName.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); + var owner = tree; + var path = entry.FullName.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); - for (var i = 0; i < path.Length - 1; i++) + for (var i = 0; i < path.Length - 1; i++) + { + var pathItem = path[i]; + if (!owner.FolderByName.TryGetValue(pathItem, out var next)) { - var pathItem = path[i]; - if (!owner.FolderByName.TryGetValue(pathItem, out var next)) - { - next = new ZipEntryFolder(pathItem); - owner.FolderByName.Add(pathItem, next); - } - - owner = (ZipEntryFolder)next; + next = new ZipEntryFolder(pathItem); + owner.FolderByName.Add(pathItem, next); } - var entryName = path.Last(); - if (entry.FullName.EndsWith("/")) - { - if (!owner.FolderByName.ContainsKey(entryName)) - { - owner.FolderByName.Add(entryName, new ZipEntryFolder(entryName)); - } - } - else if (FileTools.IsZip(entry.FullName)) - { - owner.FolderByName.Add(entryName, new ZipFolder(this, entry.FullName)); - } - else + owner = (ZipEntryFolder)next; + } + + var entryName = path.Last(); + if (entry.FullName.EndsWith("/")) + { + if (!owner.FolderByName.ContainsKey(entryName)) { - owner.Files.Add(new ZipFolderFile(this, owner, entry.FullName)); + owner.FolderByName.Add(entryName, new ZipEntryFolder(entryName)); } } - - return tree; + else if (FileTools.IsZip(entry.FullName)) + { + owner.FolderByName.Add(entryName, new ZipFolder(this, entry.FullName)); + } + else + { + owner.Files.Add(new ZipFolderFile(this, owner, entry.FullName)); + } } + + return tree; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/IO/ZipFolderFile.EntryStream.cs b/Sources/SqlDatabase/IO/ZipFolderFile.EntryStream.cs index 29120245..47d74217 100644 --- a/Sources/SqlDatabase/IO/ZipFolderFile.EntryStream.cs +++ b/Sources/SqlDatabase/IO/ZipFolderFile.EntryStream.cs @@ -1,65 +1,64 @@ using System; using System.IO; -namespace SqlDatabase.IO +namespace SqlDatabase.IO; + +internal partial class ZipFolderFile { - internal partial class ZipFolderFile + private sealed class EntryStream : Stream { - private sealed class EntryStream : Stream - { - private readonly IDisposable _owner; - private readonly Stream _source; + private readonly IDisposable _owner; + private readonly Stream _source; - public EntryStream(IDisposable owner, Stream source) - { - _owner = owner; - _source = source; - } + public EntryStream(IDisposable owner, Stream source) + { + _owner = owner; + _source = source; + } - public override bool CanRead => true; + public override bool CanRead => true; - public override bool CanSeek => false; + public override bool CanSeek => false; - public override bool CanWrite => false; + public override bool CanWrite => false; - public override long Length => throw new NotSupportedException(); + public override long Length => throw new NotSupportedException(); - public override long Position - { - get => throw new NotSupportedException(); - set => throw new NotSupportedException(); - } + public override long Position + { + get => throw new NotSupportedException(); + set => throw new NotSupportedException(); + } - public override void Flush() - { - throw new NotSupportedException(); - } + public override void Flush() + { + throw new NotSupportedException(); + } - public override long Seek(long offset, SeekOrigin origin) - { - throw new NotSupportedException(); - } + public override long Seek(long offset, SeekOrigin origin) + { + throw new NotSupportedException(); + } - public override void SetLength(long value) - { - throw new NotSupportedException(); - } + public override void SetLength(long value) + { + throw new NotSupportedException(); + } - public override int Read(byte[] buffer, int offset, int count) - { - return _source.Read(buffer, offset, count); - } + public override int Read(byte[] buffer, int offset, int count) + { + return _source.Read(buffer, offset, count); + } - public override void Write(byte[] buffer, int offset, int count) - { - throw new NotSupportedException(); - } + public override void Write(byte[] buffer, int offset, int count) + { + throw new NotSupportedException(); + } - public override void Close() - { - _owner.Dispose(); - base.Close(); - } + public override void Close() + { + _owner.Dispose(); + base.Close(); } } } \ No newline at end of file diff --git a/Sources/SqlDatabase/IO/ZipFolderFile.cs b/Sources/SqlDatabase/IO/ZipFolderFile.cs index 975b322c..77aeddcc 100644 --- a/Sources/SqlDatabase/IO/ZipFolderFile.cs +++ b/Sources/SqlDatabase/IO/ZipFolderFile.cs @@ -1,35 +1,34 @@ using System.Diagnostics; using System.IO; -namespace SqlDatabase.IO +namespace SqlDatabase.IO; + +[DebuggerDisplay(@"zip\{EntryName}")] +internal sealed partial class ZipFolderFile : IFile { - [DebuggerDisplay(@"zip\{EntryName}")] - internal sealed partial class ZipFolderFile : IFile - { - private readonly ZipFolder _container; - private readonly IFolder _parent; + private readonly ZipFolder _container; + private readonly IFolder _parent; - public ZipFolderFile(ZipFolder container, IFolder parent, string entryFullName) - { - _container = container; - _parent = parent; + public ZipFolderFile(ZipFolder container, IFolder parent, string entryFullName) + { + _container = container; + _parent = parent; - EntryFullName = entryFullName; - Name = Path.GetFileName(entryFullName); - } + EntryFullName = entryFullName; + Name = Path.GetFileName(entryFullName); + } - public string Name { get; } + public string Name { get; } - public string EntryFullName { get; } + public string EntryFullName { get; } - public IFolder GetParent() => _parent; + public IFolder GetParent() => _parent; - public Stream OpenRead() - { - var content = _container.OpenRead(); - var entry = content.GetEntry(EntryFullName); + public Stream OpenRead() + { + var content = _container.OpenRead(); + var entry = content.GetEntry(EntryFullName); - return new EntryStream(content, entry.Open()); - } + return new EntryStream(content, entry.Open()); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Log/CombinedLogger.cs b/Sources/SqlDatabase/Log/CombinedLogger.cs index 056cb400..78b8b8bb 100644 --- a/Sources/SqlDatabase/Log/CombinedLogger.cs +++ b/Sources/SqlDatabase/Log/CombinedLogger.cs @@ -1,70 +1,69 @@ using System; -namespace SqlDatabase.Log +namespace SqlDatabase.Log; + +internal sealed class CombinedLogger : ILogger, IDisposable { - internal sealed class CombinedLogger : ILogger, IDisposable + private readonly ILogger _logger1; + private readonly ILogger _logger2; + + public CombinedLogger(ILogger logger1, bool ownLogger1, ILogger logger2, bool ownLogger2) { - private readonly ILogger _logger1; - private readonly ILogger _logger2; + _logger1 = logger1; + _logger2 = logger2; + OwnLogger1 = ownLogger1; + OwnLogger2 = ownLogger2; + } - public CombinedLogger(ILogger logger1, bool ownLogger1, ILogger logger2, bool ownLogger2) - { - _logger1 = logger1; - _logger2 = logger2; - OwnLogger1 = ownLogger1; - OwnLogger2 = ownLogger2; - } + public bool OwnLogger1 { get; set; } - public bool OwnLogger1 { get; set; } + public bool OwnLogger2 { get; set; } - public bool OwnLogger2 { get; set; } + public void Error(string message) + { + _logger1?.Error(message); + _logger2?.Error(message); + } - public void Error(string message) - { - _logger1?.Error(message); - _logger2?.Error(message); - } + public void Info(string message) + { + _logger1?.Info(message); + _logger2?.Info(message); + } - public void Info(string message) + public IDisposable Indent() + { + return new IndentDisposable(_logger1?.Indent(), _logger2?.Indent()); + } + + public void Dispose() + { + if (OwnLogger1) { - _logger1?.Info(message); - _logger2?.Info(message); + (_logger1 as IDisposable)?.Dispose(); } - public IDisposable Indent() + if (OwnLogger2) { - return new IndentDisposable(_logger1?.Indent(), _logger2?.Indent()); + (_logger2 as IDisposable)?.Dispose(); } + } - public void Dispose() - { - if (OwnLogger1) - { - (_logger1 as IDisposable)?.Dispose(); - } + private sealed class IndentDisposable : IDisposable + { + private readonly IDisposable _ident1; + private readonly IDisposable _ident2; - if (OwnLogger2) - { - (_logger2 as IDisposable)?.Dispose(); - } + public IndentDisposable(IDisposable ident1, IDisposable ident2) + { + _ident1 = ident1; + _ident2 = ident2; } - private sealed class IndentDisposable : IDisposable + public void Dispose() { - private readonly IDisposable _ident1; - private readonly IDisposable _ident2; - - public IndentDisposable(IDisposable ident1, IDisposable ident2) - { - _ident1 = ident1; - _ident2 = ident2; - } - - public void Dispose() - { - _ident1?.Dispose(); - _ident2?.Dispose(); - } + _ident1?.Dispose(); + _ident2?.Dispose(); } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Log/ConsoleLogger.cs b/Sources/SqlDatabase/Log/ConsoleLogger.cs index f7f41ac2..eb5d386f 100644 --- a/Sources/SqlDatabase/Log/ConsoleLogger.cs +++ b/Sources/SqlDatabase/Log/ConsoleLogger.cs @@ -1,22 +1,21 @@ using System; -namespace SqlDatabase.Log +namespace SqlDatabase.Log; + +internal sealed class ConsoleLogger : LoggerBase { - internal sealed class ConsoleLogger : LoggerBase + protected override void WriteError(string message) { - protected override void WriteError(string message) - { - var color = Console.ForegroundColor; - Console.ForegroundColor = ConsoleColor.Red; + var color = Console.ForegroundColor; + Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine(message); + Console.WriteLine(message); - Console.ForegroundColor = color; - } + Console.ForegroundColor = color; + } - protected override void WriteInfo(string message) - { - Console.WriteLine(message); - } + protected override void WriteInfo(string message) + { + Console.WriteLine(message); } } \ No newline at end of file diff --git a/Sources/SqlDatabase/Log/DisposableAction.cs b/Sources/SqlDatabase/Log/DisposableAction.cs index d4dc969d..df482401 100644 --- a/Sources/SqlDatabase/Log/DisposableAction.cs +++ b/Sources/SqlDatabase/Log/DisposableAction.cs @@ -1,21 +1,20 @@ using System; -namespace SqlDatabase.Log +namespace SqlDatabase.Log; + +internal sealed class DisposableAction : IDisposable { - internal sealed class DisposableAction : IDisposable - { - private Action _action; + private Action _action; - public DisposableAction(Action action) - { - _action = action; - } + public DisposableAction(Action action) + { + _action = action; + } - public void Dispose() - { - var a = _action; - _action = null; - a?.Invoke(); - } + public void Dispose() + { + var a = _action; + _action = null; + a?.Invoke(); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Log/FileLogger.cs b/Sources/SqlDatabase/Log/FileLogger.cs index c4be8349..be471f1c 100644 --- a/Sources/SqlDatabase/Log/FileLogger.cs +++ b/Sources/SqlDatabase/Log/FileLogger.cs @@ -2,62 +2,61 @@ using System.Globalization; using System.IO; -namespace SqlDatabase.Log +namespace SqlDatabase.Log; + +internal sealed class FileLogger : LoggerBase, IDisposable { - internal sealed class FileLogger : LoggerBase, IDisposable + private readonly FileStream _file; + private readonly StreamWriter _writer; + + public FileLogger(string fileName) { - private readonly FileStream _file; - private readonly StreamWriter _writer; + var directory = Path.GetDirectoryName(fileName); + if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory)) + { + Directory.CreateDirectory(directory); + } - public FileLogger(string fileName) + _file = new FileStream(fileName, FileMode.Append, FileAccess.Write, FileShare.Read); + try { - var directory = Path.GetDirectoryName(fileName); - if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory)) - { - Directory.CreateDirectory(directory); - } + _file.Seek(0, SeekOrigin.End); + _writer = new StreamWriter(_file); - _file = new FileStream(fileName, FileMode.Append, FileAccess.Write, FileShare.Read); - try - { - _file.Seek(0, SeekOrigin.End); - _writer = new StreamWriter(_file); - - if (_file.Length > 0) - { - _writer.WriteLine(); - _writer.WriteLine(); - } - } - catch + if (_file.Length > 0) { - Dispose(); - throw; + _writer.WriteLine(); + _writer.WriteLine(); } } - - public void Dispose() + catch { - _writer?.Dispose(); - _file?.Dispose(); + Dispose(); + throw; } + } - internal void Flush() - { - _writer.Flush(); - } + public void Dispose() + { + _writer?.Dispose(); + _file?.Dispose(); + } + + internal void Flush() + { + _writer.Flush(); + } - protected override void WriteError(string message) => WriteLine("ERROR", message); + protected override void WriteError(string message) => WriteLine("ERROR", message); - protected override void WriteInfo(string message) => WriteLine("INFO", message); + protected override void WriteInfo(string message) => WriteLine("INFO", message); - private void WriteLine(string type, string message) - { - _writer.Write(DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss.fffff", CultureInfo.InvariantCulture)); - _writer.Write(" "); - _writer.Write(type); - _writer.Write(" "); - _writer.WriteLine(message); - } + private void WriteLine(string type, string message) + { + _writer.Write(DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss.fffff", CultureInfo.InvariantCulture)); + _writer.Write(" "); + _writer.Write(type); + _writer.Write(" "); + _writer.WriteLine(message); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Log/LoggerBase.cs b/Sources/SqlDatabase/Log/LoggerBase.cs index 4cbf1592..a42f0a87 100644 --- a/Sources/SqlDatabase/Log/LoggerBase.cs +++ b/Sources/SqlDatabase/Log/LoggerBase.cs @@ -1,36 +1,35 @@ using System; -namespace SqlDatabase.Log +namespace SqlDatabase.Log; + +internal abstract class LoggerBase : ILogger { - internal abstract class LoggerBase : ILogger + private string _indentation; + + public void Error(string message) { - private string _indentation; + WriteError(message); + } - public void Error(string message) - { - WriteError(message); - } + public void Info(string message) + { + WriteInfo(_indentation + message); + } - public void Info(string message) - { - WriteInfo(_indentation + message); - } + public IDisposable Indent() + { + const int IndentValue = 3; + const char IndentChar = ' '; - public IDisposable Indent() + _indentation += new string(IndentChar, IndentValue); + return new DisposableAction(() => { - const int IndentValue = 3; - const char IndentChar = ' '; - - _indentation += new string(IndentChar, IndentValue); - return new DisposableAction(() => - { - var length = (_indentation.Length / IndentValue) - 1; - _indentation = length == 0 ? null : new string(IndentChar, length * IndentValue); - }); - } + var length = (_indentation.Length / IndentValue) - 1; + _indentation = length == 0 ? null : new string(IndentChar, length * IndentValue); + }); + } - protected abstract void WriteError(string message); + protected abstract void WriteError(string message); - protected abstract void WriteInfo(string message); - } -} + protected abstract void WriteInfo(string message); +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Log/LoggerFactory.cs b/Sources/SqlDatabase/Log/LoggerFactory.cs index 8b621c1a..3ff4c6a5 100644 --- a/Sources/SqlDatabase/Log/LoggerFactory.cs +++ b/Sources/SqlDatabase/Log/LoggerFactory.cs @@ -1,10 +1,9 @@ -namespace SqlDatabase.Log +namespace SqlDatabase.Log; + +internal static class LoggerFactory { - internal static class LoggerFactory + public static ILogger CreateDefault() { - public static ILogger CreateDefault() - { - return new ConsoleLogger(); - } + return new ConsoleLogger(); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/LoggerExtensions.cs b/Sources/SqlDatabase/LoggerExtensions.cs index 9f057d4d..712a3ae9 100644 --- a/Sources/SqlDatabase/LoggerExtensions.cs +++ b/Sources/SqlDatabase/LoggerExtensions.cs @@ -1,34 +1,33 @@ using System; using System.Text; -namespace SqlDatabase +namespace SqlDatabase; + +internal static class LoggerExtensions { - internal static class LoggerExtensions + public static void Error(this ILogger logger, string message, Exception error) { - public static void Error(this ILogger logger, string message, Exception error) + var text = new StringBuilder(); + if (!string.IsNullOrEmpty(message)) { - var text = new StringBuilder(); - if (!string.IsNullOrEmpty(message)) - { - text.Append(message); - } + text.Append(message); + } - var ex = error; - while (ex != null) + var ex = error; + while (ex != null) + { + if (text.Length > 0) { - if (text.Length > 0) - { - text.Append(" ---> "); - } - - text.Append(ex.Message); - ex = ex.InnerException; + text.Append(" ---> "); } - logger.Error(text.ToString()); - logger.Info(error.StackTrace); + text.Append(ex.Message); + ex = ex.InnerException; } - public static void Error(this ILogger logger, Exception error) => Error(logger, null, error); + logger.Error(text.ToString()); + logger.Info(error.StackTrace); } -} + + public static void Error(this ILogger logger, Exception error) => Error(logger, null, error); +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Program.cs b/Sources/SqlDatabase/Program.cs index 47614c77..7c095538 100644 --- a/Sources/SqlDatabase/Program.cs +++ b/Sources/SqlDatabase/Program.cs @@ -4,162 +4,161 @@ using SqlDatabase.Configuration; using SqlDatabase.Log; -namespace SqlDatabase +namespace SqlDatabase; + +internal static class Program { - internal static class Program + public static int Main(string[] args) { - public static int Main(string[] args) + var logger = LoggerFactory.CreateDefault(); + return Run(logger, args); + } + + internal static int Run(ILogger logger, string[] args) + { + if (!TryWrapWithUsersLogger(logger, args, out var userLogger)) { - var logger = LoggerFactory.CreateDefault(); - return Run(logger, args); + return ExitCode.InvalidCommandLine; } - internal static int Run(ILogger logger, string[] args) + try { - if (!TryWrapWithUsersLogger(logger, args, out var userLogger)) - { - return ExitCode.InvalidCommandLine; - } + return MainCore(userLogger ?? logger, args); + } + finally + { + userLogger?.Dispose(); + } + } - try - { - return MainCore(userLogger ?? logger, args); - } - finally - { - userLogger?.Dispose(); - } + private static int MainCore(ILogger logger, string[] args) + { + var factory = ResolveFactory(args, logger); + if (factory == null) + { + logger.Info(LoadHelpContent("CommandLine.txt")); + return ExitCode.InvalidCommandLine; } - private static int MainCore(ILogger logger, string[] args) + if (factory.ShowCommandHelp) { - var factory = ResolveFactory(args, logger); - if (factory == null) - { - logger.Info(LoadHelpContent("CommandLine.txt")); - return ExitCode.InvalidCommandLine; - } + logger.Info(LoadHelpContent(GetHelpFileName(factory.ActiveCommandName))); + return ExitCode.InvalidCommandLine; + } - if (factory.ShowCommandHelp) - { - logger.Info(LoadHelpContent(GetHelpFileName(factory.ActiveCommandName))); - return ExitCode.InvalidCommandLine; - } + var cmd = ResolveCommandLine(factory, logger); + if (cmd == null) + { + return ExitCode.InvalidCommandLine; + } - var cmd = ResolveCommandLine(factory, logger); - if (cmd == null) - { - return ExitCode.InvalidCommandLine; - } + var exitCode = ExecuteCommand(cmd, logger) ? ExitCode.Ok : ExitCode.ExecutionErrors; + return exitCode; + } - var exitCode = ExecuteCommand(cmd, logger) ? ExitCode.Ok : ExitCode.ExecutionErrors; - return exitCode; + private static bool ExecuteCommand(ICommandLine cmd, ILogger logger) + { + try + { + cmd.CreateCommand(logger).Execute(); + return true; } - - private static bool ExecuteCommand(ICommandLine cmd, ILogger logger) + catch (Exception ex) { - try - { - cmd.CreateCommand(logger).Execute(); - return true; - } - catch (Exception ex) - { - logger.Error(ex); - return false; - } + logger.Error(ex); + return false; } + } - private static ICommandLine ResolveCommandLine(CommandLineFactory factory, ILogger logger) + private static ICommandLine ResolveCommandLine(CommandLineFactory factory, ILogger logger) + { + try { - try - { - return factory.Resolve(); - } - catch (Exception ex) - { - logger.Error("Invalid command line.", ex); - } - - return null; + return factory.Resolve(); } + catch (Exception ex) + { + logger.Error("Invalid command line.", ex); + } + + return null; + } - private static CommandLineFactory ResolveFactory(string[] args, ILogger logger) + private static CommandLineFactory ResolveFactory(string[] args, ILogger logger) + { + try { - try + var command = new CommandLineParser().Parse(args); + if (command.Args.Count == 0) { - var command = new CommandLineParser().Parse(args); - if (command.Args.Count == 0) - { - return null; - } - - var factory = new CommandLineFactory { Args = command }; - return factory.Bind() ? factory : null; - } - catch (Exception ex) - { - logger.Error("Invalid command line.", ex); + return null; } - return null; + var factory = new CommandLineFactory { Args = command }; + return factory.Bind() ? factory : null; } - - private static bool TryWrapWithUsersLogger(ILogger logger, string[] args, out CombinedLogger combined) + catch (Exception ex) { - combined = null; - var fileName = CommandLineParser.GetLogFileName(args); - if (string.IsNullOrEmpty(fileName)) - { - return true; - } + logger.Error("Invalid command line.", ex); + } - ILogger fileLogger; - try - { - fileLogger = new FileLogger(fileName); - } - catch (Exception ex) - { - logger.Error("Fail to create file log.", ex); - return false; - } + return null; + } - combined = new CombinedLogger(logger, false, fileLogger, true); + private static bool TryWrapWithUsersLogger(ILogger logger, string[] args, out CombinedLogger combined) + { + combined = null; + var fileName = CommandLineParser.GetLogFileName(args); + if (string.IsNullOrEmpty(fileName)) + { return true; } - private static string GetHelpFileName(string commandName) + ILogger fileLogger; + try + { + fileLogger = new FileLogger(fileName); + } + catch (Exception ex) { + logger.Error("Fail to create file log.", ex); + return false; + } + + combined = new CombinedLogger(logger, false, fileLogger, true); + return true; + } + + private static string GetHelpFileName(string commandName) + { #if NET452 - const string Runtime = ".net452"; + const string Runtime = ".net452"; #else - const string Runtime = null; + const string Runtime = null; #endif - return "CommandLine." + commandName + Runtime + ".txt"; - } + return "CommandLine." + commandName + Runtime + ".txt"; + } - private static string LoadHelpContent(string fileName) - { - var scope = typeof(ICommandLine); + private static string LoadHelpContent(string fileName) + { + var scope = typeof(ICommandLine); - // .net core resource name is case-sensitive - var fullName = scope.Namespace + "." + fileName; - var resourceName = scope - .Assembly - .GetManifestResourceNames() - .FirstOrDefault(i => string.Equals(fullName, i, StringComparison.OrdinalIgnoreCase)); + // .net core resource name is case-sensitive + var fullName = scope.Namespace + "." + fileName; + var resourceName = scope + .Assembly + .GetManifestResourceNames() + .FirstOrDefault(i => string.Equals(fullName, i, StringComparison.OrdinalIgnoreCase)); - if (resourceName == null) - { - throw new InvalidOperationException("Help file [{0}] not found.".FormatWith(fullName)); - } + if (resourceName == null) + { + throw new InvalidOperationException("Help file [{0}] not found.".FormatWith(fullName)); + } - using (var stream = scope.Assembly.GetManifestResourceStream(resourceName)) - using (var reader = new StreamReader(stream)) - { - return reader.ReadToEnd(); - } + using (var stream = scope.Assembly.GetManifestResourceStream(resourceName)) + using (var reader = new StreamReader(stream)) + { + return reader.ReadToEnd(); } } } \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/AssemblyInternal/ConsoleListener.cs b/Sources/SqlDatabase/Scripts/AssemblyInternal/ConsoleListener.cs index c1e488e6..fdc12512 100644 --- a/Sources/SqlDatabase/Scripts/AssemblyInternal/ConsoleListener.cs +++ b/Sources/SqlDatabase/Scripts/AssemblyInternal/ConsoleListener.cs @@ -2,46 +2,45 @@ using System.IO; using System.Text; -namespace SqlDatabase.Scripts.AssemblyInternal +namespace SqlDatabase.Scripts.AssemblyInternal; + +internal sealed class ConsoleListener : TextWriter { - internal sealed class ConsoleListener : TextWriter - { - private readonly TextWriter _original; - private readonly ILogger _logger; + private readonly TextWriter _original; + private readonly ILogger _logger; - public ConsoleListener(ILogger logger) - { - _logger = logger; + public ConsoleListener(ILogger logger) + { + _logger = logger; - _original = Console.Out; - Console.SetOut(this); - } + _original = Console.Out; + Console.SetOut(this); + } - public override Encoding Encoding => _original.Encoding; + public override Encoding Encoding => _original.Encoding; - public override IFormatProvider FormatProvider => _original.FormatProvider; + public override IFormatProvider FormatProvider => _original.FormatProvider; - public override string NewLine - { - get => _original.NewLine; - set => _original.NewLine = value; - } + public override string NewLine + { + get => _original.NewLine; + set => _original.NewLine = value; + } - public override void Write(string value) - { - _logger.Info(value); - } + public override void Write(string value) + { + _logger.Info(value); + } - public override void WriteLine(string value) - { - _logger.Info(value); - } + public override void WriteLine(string value) + { + _logger.Info(value); + } - protected override void Dispose(bool disposing) - { - Console.SetOut(_original); + protected override void Dispose(bool disposing) + { + Console.SetOut(_original); - base.Dispose(disposing); - } + base.Dispose(disposing); } } \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/AssemblyInternal/DefaultEntryPoint.cs b/Sources/SqlDatabase/Scripts/AssemblyInternal/DefaultEntryPoint.cs index f7562ab1..adaa929e 100644 --- a/Sources/SqlDatabase/Scripts/AssemblyInternal/DefaultEntryPoint.cs +++ b/Sources/SqlDatabase/Scripts/AssemblyInternal/DefaultEntryPoint.cs @@ -2,35 +2,34 @@ using System.Collections.Generic; using System.Data; -namespace SqlDatabase.Scripts.AssemblyInternal -{ - internal sealed class DefaultEntryPoint : IEntryPoint - { - public ILogger Log { get; set; } +namespace SqlDatabase.Scripts.AssemblyInternal; - public object ScriptInstance { get; set; } +internal sealed class DefaultEntryPoint : IEntryPoint +{ + public ILogger Log { get; set; } - public Action> Method { get; set; } + public object ScriptInstance { get; set; } - public bool Execute(IDbCommand command, IReadOnlyDictionary variables) - { - var result = false; + public Action> Method { get; set; } - try - { - Method(command, variables); - result = true; - } - catch (Exception ex) - { - Log.Error(ex); - } - finally - { - (ScriptInstance as IDisposable)?.Dispose(); - } + public bool Execute(IDbCommand command, IReadOnlyDictionary variables) + { + var result = false; - return result; + try + { + Method(command, variables); + result = true; } + catch (Exception ex) + { + Log.Error(ex); + } + finally + { + (ScriptInstance as IDisposable)?.Dispose(); + } + + return result; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/AssemblyInternal/EntryPointResolver.cs b/Sources/SqlDatabase/Scripts/AssemblyInternal/EntryPointResolver.cs index 83dcb633..b5e754ac 100644 --- a/Sources/SqlDatabase/Scripts/AssemblyInternal/EntryPointResolver.cs +++ b/Sources/SqlDatabase/Scripts/AssemblyInternal/EntryPointResolver.cs @@ -3,153 +3,152 @@ using System.Reflection; using System.Text; -namespace SqlDatabase.Scripts.AssemblyInternal +namespace SqlDatabase.Scripts.AssemblyInternal; + +internal sealed class EntryPointResolver { - internal sealed class EntryPointResolver - { - public ILogger Log { get; set; } + public ILogger Log { get; set; } - public string ExecutorClassName { get; set; } + public string ExecutorClassName { get; set; } - public string ExecutorMethodName { get; set; } + public string ExecutorMethodName { get; set; } + + public IEntryPoint Resolve(Assembly assembly) + { + Log.Info("resolve script executor"); - public IEntryPoint Resolve(Assembly assembly) + var type = ResolveClass(assembly); + if (type == null) { - Log.Info("resolve script executor"); + return null; + } - var type = ResolveClass(assembly); - if (type == null) - { - return null; - } + var method = ResolveMethod(type); + if (method == null) + { + return null; + } - var method = ResolveMethod(type); - if (method == null) + var message = new StringBuilder() + .AppendFormat("found {0}.{1}(", type.FullName, method.Method.Name); + var args = method.Method.GetParameters(); + for (var i = 0; i < args.Length; i++) + { + if (i > 0) { - return null; + message.Append(", "); } - var message = new StringBuilder() - .AppendFormat("found {0}.{1}(", type.FullName, method.Method.Name); - var args = method.Method.GetParameters(); - for (var i = 0; i < args.Length; i++) - { - if (i > 0) - { - message.Append(", "); - } - - message - .Append(args[i].ParameterType.Name) - .Append(" ") - .Append(args[i].Name); - } - - message.Append(")"); - Log.Info(message.ToString()); + message + .Append(args[i].ParameterType.Name) + .Append(" ") + .Append(args[i].Name); + } - object scriptInstance; - try - { - scriptInstance = Activator.CreateInstance(type); - } - catch (Exception ex) - { - Log.Error("Fail to create instance of {0}.".FormatWith(type.FullName), ex); - return null; - } + message.Append(")"); + Log.Info(message.ToString()); - return new DefaultEntryPoint - { - Log = Log, - ScriptInstance = scriptInstance, - Method = method.Resolver.CreateDelegate(scriptInstance, method.Method) - }; + object scriptInstance; + try + { + scriptInstance = Activator.CreateInstance(type); + } + catch (Exception ex) + { + Log.Error("Fail to create instance of {0}.".FormatWith(type.FullName), ex); + return null; } - private Type ResolveClass(Assembly assembly) + return new DefaultEntryPoint { - var filter = assembly - .GetExportedTypes() - .Where(i => i.IsClass && !i.IsAbstract && !i.IsGenericTypeDefinition); + Log = Log, + ScriptInstance = scriptInstance, + Method = method.Resolver.CreateDelegate(scriptInstance, method.Method) + }; + } - if (ExecutorClassName.IndexOf('.') >= 0 || ExecutorClassName.IndexOf('+') >= 0) - { - filter = filter.Where(i => i.FullName?.EndsWith(ExecutorClassName, StringComparison.OrdinalIgnoreCase) == true); - } - else - { - filter = filter.Where(i => ExecutorClassName.Equals(i.Name, StringComparison.Ordinal)); - } + private Type ResolveClass(Assembly assembly) + { + var filter = assembly + .GetExportedTypes() + .Where(i => i.IsClass && !i.IsAbstract && !i.IsGenericTypeDefinition); - var candidates = filter.ToList(); - if (candidates.Count == 0) - { - Log.Error("public class {0} not found.".FormatWith(ExecutorClassName)); - return null; - } + if (ExecutorClassName.IndexOf('.') >= 0 || ExecutorClassName.IndexOf('+') >= 0) + { + filter = filter.Where(i => i.FullName?.EndsWith(ExecutorClassName, StringComparison.OrdinalIgnoreCase) == true); + } + else + { + filter = filter.Where(i => ExecutorClassName.Equals(i.Name, StringComparison.Ordinal)); + } - if (candidates.Count != 1) - { - Log.Error("There are {0} items with signature public class {1}.".FormatWith(candidates.Count, ExecutorClassName)); - return null; - } + var candidates = filter.ToList(); + if (candidates.Count == 0) + { + Log.Error("public class {0} not found.".FormatWith(ExecutorClassName)); + return null; + } - return candidates[0]; + if (candidates.Count != 1) + { + Log.Error("There are {0} items with signature public class {1}.".FormatWith(candidates.Count, ExecutorClassName)); + return null; } - private ExecuteMethodRef ResolveMethod(Type type) + return candidates[0]; + } + + private ExecuteMethodRef ResolveMethod(Type type) + { + var methodResolvers = new ExecuteMethodResolverBase[] { - var methodResolvers = new ExecuteMethodResolverBase[] + new ExecuteMethodResolverCommandDictionary(), + new ExecuteMethodResolverDictionaryCommand(), + new ExecuteMethodResolverCommand(), + new ExecuteMethodResolverDbConnection(), + new ExecuteMethodResolverSqlConnection() + }; + + var methods = type + .GetMethods(BindingFlags.Instance | BindingFlags.Public) + .Where(i => i.ReturnType == typeof(void)) + .Where(i => ExecutorMethodName.Equals(i.Name, StringComparison.OrdinalIgnoreCase)) + .Select(i => { - new ExecuteMethodResolverCommandDictionary(), - new ExecuteMethodResolverDictionaryCommand(), - new ExecuteMethodResolverCommand(), - new ExecuteMethodResolverDbConnection(), - new ExecuteMethodResolverSqlConnection() - }; - - var methods = type - .GetMethods(BindingFlags.Instance | BindingFlags.Public) - .Where(i => i.ReturnType == typeof(void)) - .Where(i => ExecutorMethodName.Equals(i.Name, StringComparison.OrdinalIgnoreCase)) - .Select(i => + for (var priority = 0; priority < methodResolvers.Length; priority++) { - for (var priority = 0; priority < methodResolvers.Length; priority++) + var resolver = methodResolvers[priority]; + if (resolver.IsMatch(i)) { - var resolver = methodResolvers[priority]; - if (resolver.IsMatch(i)) + return new ExecuteMethodRef { - return new ExecuteMethodRef - { - Method = i, - Resolver = resolver, - Priority = priority - }; - } + Method = i, + Resolver = resolver, + Priority = priority + }; } + } - return null; - }) - .Where(i => i != null) - .OrderBy(i => i.Priority) - .ToList(); - - if (methods.Count == 0) - { - Log.Error("public void {0}(IDbCommand command, IReadOnlyDictionary variables) not found in {1}.".FormatWith(ExecutorMethodName, type)); - } + return null; + }) + .Where(i => i != null) + .OrderBy(i => i.Priority) + .ToList(); - return methods[0]; + if (methods.Count == 0) + { + Log.Error("public void {0}(IDbCommand command, IReadOnlyDictionary variables) not found in {1}.".FormatWith(ExecutorMethodName, type)); } - private sealed class ExecuteMethodRef - { - public int Priority { get; set; } + return methods[0]; + } - public MethodInfo Method { get; set; } + private sealed class ExecuteMethodRef + { + public int Priority { get; set; } - public ExecuteMethodResolverBase Resolver { get; set; } - } + public MethodInfo Method { get; set; } + + public ExecuteMethodResolverBase Resolver { get; set; } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/AssemblyInternal/ExecuteMethodResolverBase.cs b/Sources/SqlDatabase/Scripts/AssemblyInternal/ExecuteMethodResolverBase.cs index b91a0f43..bc060c01 100644 --- a/Sources/SqlDatabase/Scripts/AssemblyInternal/ExecuteMethodResolverBase.cs +++ b/Sources/SqlDatabase/Scripts/AssemblyInternal/ExecuteMethodResolverBase.cs @@ -3,12 +3,11 @@ using System.Data; using System.Reflection; -namespace SqlDatabase.Scripts.AssemblyInternal +namespace SqlDatabase.Scripts.AssemblyInternal; + +internal abstract class ExecuteMethodResolverBase { - internal abstract class ExecuteMethodResolverBase - { - public abstract bool IsMatch(MethodInfo method); + public abstract bool IsMatch(MethodInfo method); - public abstract Action> CreateDelegate(object instance, MethodInfo method); - } -} + public abstract Action> CreateDelegate(object instance, MethodInfo method); +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/AssemblyInternal/ExecuteMethodResolverCommand.cs b/Sources/SqlDatabase/Scripts/AssemblyInternal/ExecuteMethodResolverCommand.cs index 57a7f7eb..978582f4 100644 --- a/Sources/SqlDatabase/Scripts/AssemblyInternal/ExecuteMethodResolverCommand.cs +++ b/Sources/SqlDatabase/Scripts/AssemblyInternal/ExecuteMethodResolverCommand.cs @@ -3,26 +3,25 @@ using System.Data; using System.Reflection; -namespace SqlDatabase.Scripts.AssemblyInternal +namespace SqlDatabase.Scripts.AssemblyInternal; + +// public void Execute(IDbCommand command) +internal sealed class ExecuteMethodResolverCommand : ExecuteMethodResolverBase { - // public void Execute(IDbCommand command) - internal sealed class ExecuteMethodResolverCommand : ExecuteMethodResolverBase + public override bool IsMatch(MethodInfo method) { - public override bool IsMatch(MethodInfo method) - { - var parameters = method.GetParameters(); - return parameters.Length == 1 - && typeof(IDbCommand) == parameters[0].ParameterType; - } + var parameters = method.GetParameters(); + return parameters.Length == 1 + && typeof(IDbCommand) == parameters[0].ParameterType; + } - public override Action> CreateDelegate(object instance, MethodInfo method) - { - var execute = (Action)Delegate.CreateDelegate( - typeof(Action), - instance, - method); + public override Action> CreateDelegate(object instance, MethodInfo method) + { + var execute = (Action)Delegate.CreateDelegate( + typeof(Action), + instance, + method); - return (command, variables) => execute(command); - } + return (command, variables) => execute(command); } } \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/AssemblyInternal/ExecuteMethodResolverCommandDictionary.cs b/Sources/SqlDatabase/Scripts/AssemblyInternal/ExecuteMethodResolverCommandDictionary.cs index 6c28fe69..a442e25a 100644 --- a/Sources/SqlDatabase/Scripts/AssemblyInternal/ExecuteMethodResolverCommandDictionary.cs +++ b/Sources/SqlDatabase/Scripts/AssemblyInternal/ExecuteMethodResolverCommandDictionary.cs @@ -3,25 +3,24 @@ using System.Data; using System.Reflection; -namespace SqlDatabase.Scripts.AssemblyInternal +namespace SqlDatabase.Scripts.AssemblyInternal; + +// public void Execute(IDbCommand command, IReadOnlyDictionary variables) +internal sealed class ExecuteMethodResolverCommandDictionary : ExecuteMethodResolverBase { - // public void Execute(IDbCommand command, IReadOnlyDictionary variables) - internal sealed class ExecuteMethodResolverCommandDictionary : ExecuteMethodResolverBase + public override bool IsMatch(MethodInfo method) { - public override bool IsMatch(MethodInfo method) - { - var parameters = method.GetParameters(); - return parameters.Length == 2 - && typeof(IDbCommand) == parameters[0].ParameterType - && typeof(IReadOnlyDictionary) == parameters[1].ParameterType; - } + var parameters = method.GetParameters(); + return parameters.Length == 2 + && typeof(IDbCommand) == parameters[0].ParameterType + && typeof(IReadOnlyDictionary) == parameters[1].ParameterType; + } - public override Action> CreateDelegate(object instance, MethodInfo method) - { - return (Action>)Delegate.CreateDelegate( - typeof(Action>), - instance, - method); - } + public override Action> CreateDelegate(object instance, MethodInfo method) + { + return (Action>)Delegate.CreateDelegate( + typeof(Action>), + instance, + method); } } \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/AssemblyInternal/ExecuteMethodResolverDbConnection.cs b/Sources/SqlDatabase/Scripts/AssemblyInternal/ExecuteMethodResolverDbConnection.cs index e0703ced..b742838e 100644 --- a/Sources/SqlDatabase/Scripts/AssemblyInternal/ExecuteMethodResolverDbConnection.cs +++ b/Sources/SqlDatabase/Scripts/AssemblyInternal/ExecuteMethodResolverDbConnection.cs @@ -3,26 +3,25 @@ using System.Data; using System.Reflection; -namespace SqlDatabase.Scripts.AssemblyInternal +namespace SqlDatabase.Scripts.AssemblyInternal; + +// public void Execute(IDbConnection connection) +internal sealed class ExecuteMethodResolverDbConnection : ExecuteMethodResolverBase { - // public void Execute(IDbConnection connection) - internal sealed class ExecuteMethodResolverDbConnection : ExecuteMethodResolverBase + public override bool IsMatch(MethodInfo method) { - public override bool IsMatch(MethodInfo method) - { - var parameters = method.GetParameters(); - return parameters.Length == 1 - && typeof(IDbConnection) == parameters[0].ParameterType; - } + var parameters = method.GetParameters(); + return parameters.Length == 1 + && typeof(IDbConnection) == parameters[0].ParameterType; + } - public override Action> CreateDelegate(object instance, MethodInfo method) - { - var execute = (Action)Delegate.CreateDelegate( - typeof(Action), - instance, - method); + public override Action> CreateDelegate(object instance, MethodInfo method) + { + var execute = (Action)Delegate.CreateDelegate( + typeof(Action), + instance, + method); - return (command, variables) => execute(command.Connection); - } + return (command, variables) => execute(command.Connection); } } \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/AssemblyInternal/ExecuteMethodResolverDictionaryCommand.cs b/Sources/SqlDatabase/Scripts/AssemblyInternal/ExecuteMethodResolverDictionaryCommand.cs index d06b0fa3..3ca4bd7d 100644 --- a/Sources/SqlDatabase/Scripts/AssemblyInternal/ExecuteMethodResolverDictionaryCommand.cs +++ b/Sources/SqlDatabase/Scripts/AssemblyInternal/ExecuteMethodResolverDictionaryCommand.cs @@ -3,27 +3,26 @@ using System.Data; using System.Reflection; -namespace SqlDatabase.Scripts.AssemblyInternal +namespace SqlDatabase.Scripts.AssemblyInternal; + +// public void Execute(IReadOnlyDictionary variables, IDbCommand command) +internal sealed class ExecuteMethodResolverDictionaryCommand : ExecuteMethodResolverBase { - // public void Execute(IReadOnlyDictionary variables, IDbCommand command) - internal sealed class ExecuteMethodResolverDictionaryCommand : ExecuteMethodResolverBase + public override bool IsMatch(MethodInfo method) { - public override bool IsMatch(MethodInfo method) - { - var parameters = method.GetParameters(); - return parameters.Length == 2 - && typeof(IReadOnlyDictionary) == parameters[0].ParameterType - && typeof(IDbCommand) == parameters[1].ParameterType; - } + var parameters = method.GetParameters(); + return parameters.Length == 2 + && typeof(IReadOnlyDictionary) == parameters[0].ParameterType + && typeof(IDbCommand) == parameters[1].ParameterType; + } - public override Action> CreateDelegate(object instance, MethodInfo method) - { - var execute = (Action, IDbCommand>)Delegate.CreateDelegate( - typeof(Action, IDbCommand>), - instance, - method); + public override Action> CreateDelegate(object instance, MethodInfo method) + { + var execute = (Action, IDbCommand>)Delegate.CreateDelegate( + typeof(Action, IDbCommand>), + instance, + method); - return (command, variables) => execute(variables, command); - } + return (command, variables) => execute(variables, command); } } \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/AssemblyInternal/ExecuteMethodResolverSqlConnection.cs b/Sources/SqlDatabase/Scripts/AssemblyInternal/ExecuteMethodResolverSqlConnection.cs index f0d63de9..056b7653 100644 --- a/Sources/SqlDatabase/Scripts/AssemblyInternal/ExecuteMethodResolverSqlConnection.cs +++ b/Sources/SqlDatabase/Scripts/AssemblyInternal/ExecuteMethodResolverSqlConnection.cs @@ -4,26 +4,25 @@ using System.Data.SqlClient; using System.Reflection; -namespace SqlDatabase.Scripts.AssemblyInternal +namespace SqlDatabase.Scripts.AssemblyInternal; + +// public void Execute(SqlConnection connection) +internal sealed class ExecuteMethodResolverSqlConnection : ExecuteMethodResolverBase { - // public void Execute(SqlConnection connection) - internal sealed class ExecuteMethodResolverSqlConnection : ExecuteMethodResolverBase + public override bool IsMatch(MethodInfo method) { - public override bool IsMatch(MethodInfo method) - { - var parameters = method.GetParameters(); - return parameters.Length == 1 - && typeof(SqlConnection) == parameters[0].ParameterType; - } + var parameters = method.GetParameters(); + return parameters.Length == 1 + && typeof(SqlConnection) == parameters[0].ParameterType; + } - public override Action> CreateDelegate(object instance, MethodInfo method) - { - var execute = (Action)Delegate.CreateDelegate( - typeof(Action), - instance, - method); + public override Action> CreateDelegate(object instance, MethodInfo method) + { + var execute = (Action)Delegate.CreateDelegate( + typeof(Action), + instance, + method); - return (command, variables) => execute((SqlConnection)command.Connection); - } + return (command, variables) => execute((SqlConnection)command.Connection); } } \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/AssemblyInternal/IEntryPoint.cs b/Sources/SqlDatabase/Scripts/AssemblyInternal/IEntryPoint.cs index facc93bd..5377470b 100644 --- a/Sources/SqlDatabase/Scripts/AssemblyInternal/IEntryPoint.cs +++ b/Sources/SqlDatabase/Scripts/AssemblyInternal/IEntryPoint.cs @@ -1,10 +1,9 @@ using System.Collections.Generic; using System.Data; -namespace SqlDatabase.Scripts.AssemblyInternal +namespace SqlDatabase.Scripts.AssemblyInternal; + +internal interface IEntryPoint { - internal interface IEntryPoint - { - bool Execute(IDbCommand command, IReadOnlyDictionary variables); - } -} + bool Execute(IDbCommand command, IReadOnlyDictionary variables); +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/AssemblyInternal/ISubDomain.cs b/Sources/SqlDatabase/Scripts/AssemblyInternal/ISubDomain.cs index f406bba9..bc7ed3a2 100644 --- a/Sources/SqlDatabase/Scripts/AssemblyInternal/ISubDomain.cs +++ b/Sources/SqlDatabase/Scripts/AssemblyInternal/ISubDomain.cs @@ -1,22 +1,21 @@ using System; using System.Data; -namespace SqlDatabase.Scripts.AssemblyInternal +namespace SqlDatabase.Scripts.AssemblyInternal; + +internal interface ISubDomain : IDisposable { - internal interface ISubDomain : IDisposable - { - ILogger Logger { get; set; } + ILogger Logger { get; set; } - string AssemblyFileName { get; set; } + string AssemblyFileName { get; set; } - Func ReadAssemblyContent { get; set; } + Func ReadAssemblyContent { get; set; } - void Initialize(); + void Initialize(); - void Unload(); + void Unload(); - bool ResolveScriptExecutor(string className, string methodName); + bool ResolveScriptExecutor(string className, string methodName); - bool Execute(IDbCommand command, IVariables variables); - } -} + bool Execute(IDbCommand command, IVariables variables); +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/AssemblyInternal/Net452/DomainAgent.cs b/Sources/SqlDatabase/Scripts/AssemblyInternal/Net452/DomainAgent.cs index fc873b1d..102ab1ed 100644 --- a/Sources/SqlDatabase/Scripts/AssemblyInternal/Net452/DomainAgent.cs +++ b/Sources/SqlDatabase/Scripts/AssemblyInternal/Net452/DomainAgent.cs @@ -5,78 +5,77 @@ using System.IO; using System.Reflection; -namespace SqlDatabase.Scripts.AssemblyInternal.Net452 +namespace SqlDatabase.Scripts.AssemblyInternal.Net452; + +internal sealed class DomainAgent : MarshalByRefObject { - internal sealed class DomainAgent : MarshalByRefObject - { - private ConsoleListener _consoleRedirect; + private ConsoleListener _consoleRedirect; - internal Assembly Assembly { get; set; } + internal Assembly Assembly { get; set; } - internal IEntryPoint EntryPoint { get; set; } + internal IEntryPoint EntryPoint { get; set; } - internal ILogger Logger { get; set; } + internal ILogger Logger { get; set; } - public void LoadAssembly(string fileName) - { - Assembly = Assembly.LoadFrom(fileName); - AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve; - } + public void LoadAssembly(string fileName) + { + Assembly = Assembly.LoadFrom(fileName); + AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve; + } - public void RedirectConsoleOut(TraceListener logger) - { - Logger = new LoggerProxy(logger); - _consoleRedirect = new ConsoleListener(Logger); - } + public void RedirectConsoleOut(TraceListener logger) + { + Logger = new LoggerProxy(logger); + _consoleRedirect = new ConsoleListener(Logger); + } - public bool ResolveScriptExecutor(string className, string methodName) + public bool ResolveScriptExecutor(string className, string methodName) + { + // only for unit tests + if (EntryPoint != null) { - // only for unit tests - if (EntryPoint != null) - { - return true; - } - - var resolver = new EntryPointResolver - { - Log = Logger, - ExecutorClassName = className, - ExecutorMethodName = methodName - }; - - EntryPoint = resolver.Resolve(Assembly); - - return EntryPoint != null; + return true; } - public bool Execute(IDbCommand command, IReadOnlyDictionary variables) + var resolver = new EntryPointResolver { - return EntryPoint.Execute(command, variables); - } + Log = Logger, + ExecutorClassName = className, + ExecutorMethodName = methodName + }; - public void BeforeUnload() - { - _consoleRedirect?.Dispose(); - AppDomain.CurrentDomain.AssemblyResolve -= OnAssemblyResolve; - } + EntryPoint = resolver.Resolve(Assembly); - private Assembly OnAssemblyResolve(object sender, ResolveEventArgs args) - { - var argName = new AssemblyName(args.Name).Name; + return EntryPoint != null; + } - var sqlDataBase = GetType().Assembly; - if (sqlDataBase.GetName().Name.Equals(argName, StringComparison.OrdinalIgnoreCase)) - { - return sqlDataBase; - } + public bool Execute(IDbCommand command, IReadOnlyDictionary variables) + { + return EntryPoint.Execute(command, variables); + } - var fileName = Path.Combine(Path.GetDirectoryName(sqlDataBase.Location), argName + ".dll"); - if (File.Exists(fileName)) - { - return Assembly.LoadFrom(fileName); - } + public void BeforeUnload() + { + _consoleRedirect?.Dispose(); + AppDomain.CurrentDomain.AssemblyResolve -= OnAssemblyResolve; + } - return null; + private Assembly OnAssemblyResolve(object sender, ResolveEventArgs args) + { + var argName = new AssemblyName(args.Name).Name; + + var sqlDataBase = GetType().Assembly; + if (sqlDataBase.GetName().Name.Equals(argName, StringComparison.OrdinalIgnoreCase)) + { + return sqlDataBase; + } + + var fileName = Path.Combine(Path.GetDirectoryName(sqlDataBase.Location), argName + ".dll"); + if (File.Exists(fileName)) + { + return Assembly.LoadFrom(fileName); } + + return null; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/AssemblyInternal/Net452/DomainDirectory.cs b/Sources/SqlDatabase/Scripts/AssemblyInternal/Net452/DomainDirectory.cs index 74b012db..a38e4952 100644 --- a/Sources/SqlDatabase/Scripts/AssemblyInternal/Net452/DomainDirectory.cs +++ b/Sources/SqlDatabase/Scripts/AssemblyInternal/Net452/DomainDirectory.cs @@ -1,52 +1,51 @@ using System; using System.IO; -namespace SqlDatabase.Scripts.AssemblyInternal.Net452 +namespace SqlDatabase.Scripts.AssemblyInternal.Net452; + +internal sealed class DomainDirectory : IDisposable { - internal sealed class DomainDirectory : IDisposable + private readonly ILogger _logger; + + public DomainDirectory(ILogger logger) { - private readonly ILogger _logger; + _logger = logger; - public DomainDirectory(ILogger logger) - { - _logger = logger; + Location = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); + Directory.CreateDirectory(Location); + } + + public string Location { get; } - Location = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); - Directory.CreateDirectory(Location); + public string SaveFile(byte[] content, string fileName) + { + var location = Path.Combine(Location, fileName); + try + { + File.WriteAllBytes(location, content); + } + catch (Exception ex) + { + _logger.Error("Fail to copy content of [{0}]: {1}".FormatWith(fileName, ex.Message)); + File.Delete(location); + throw; } - public string Location { get; } + return location; + } - public string SaveFile(byte[] content, string fileName) + public void Dispose() + { + if (Directory.Exists(Location)) { - var location = Path.Combine(Location, fileName); try { - File.WriteAllBytes(location, content); + Directory.Delete(Location, true); } catch (Exception ex) { - _logger.Error("Fail to copy content of [{0}]: {1}".FormatWith(fileName, ex.Message)); - File.Delete(location); - throw; - } - - return location; - } - - public void Dispose() - { - if (Directory.Exists(Location)) - { - try - { - Directory.Delete(Location, true); - } - catch (Exception ex) - { - _logger.Info("Fail to delete assembly content from {0}: {1}".FormatWith(Location, ex.Message)); - } + _logger.Info("Fail to delete assembly content from {0}: {1}".FormatWith(Location, ex.Message)); } } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/AssemblyInternal/Net452/LoggerProxy.cs b/Sources/SqlDatabase/Scripts/AssemblyInternal/Net452/LoggerProxy.cs index 6e8f99a7..e51b96bb 100644 --- a/Sources/SqlDatabase/Scripts/AssemblyInternal/Net452/LoggerProxy.cs +++ b/Sources/SqlDatabase/Scripts/AssemblyInternal/Net452/LoggerProxy.cs @@ -1,51 +1,50 @@ using System; using System.Diagnostics; -namespace SqlDatabase.Scripts.AssemblyInternal.Net452 +namespace SqlDatabase.Scripts.AssemblyInternal.Net452; + +internal sealed class LoggerProxy : TraceListener, ILogger { - internal sealed class LoggerProxy : TraceListener, ILogger - { - private readonly TraceListener _output; - private readonly ILogger _input; - - public LoggerProxy(ILogger input) - { - _input = input; - } - - public LoggerProxy(TraceListener output) - { - _output = output; - } - - public override void Write(string message) - { - throw new NotSupportedException(); - } - - public override void WriteLine(string message) - { - _input.Info(message); - } - - public override void Fail(string message) - { - _input.Error(message); - } - - void ILogger.Error(string message) - { - _output.Fail(message); - } - - void ILogger.Info(string message) - { - _output.WriteLine(message); - } - - IDisposable ILogger.Indent() - { - throw new NotSupportedException(); - } - } -} + private readonly TraceListener _output; + private readonly ILogger _input; + + public LoggerProxy(ILogger input) + { + _input = input; + } + + public LoggerProxy(TraceListener output) + { + _output = output; + } + + public override void Write(string message) + { + throw new NotSupportedException(); + } + + public override void WriteLine(string message) + { + _input.Info(message); + } + + public override void Fail(string message) + { + _input.Error(message); + } + + void ILogger.Error(string message) + { + _output.Fail(message); + } + + void ILogger.Info(string message) + { + _output.WriteLine(message); + } + + IDisposable ILogger.Indent() + { + throw new NotSupportedException(); + } +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/AssemblyInternal/VariablesProxy.cs b/Sources/SqlDatabase/Scripts/AssemblyInternal/VariablesProxy.cs index d2dacfa3..ca1d1f74 100644 --- a/Sources/SqlDatabase/Scripts/AssemblyInternal/VariablesProxy.cs +++ b/Sources/SqlDatabase/Scripts/AssemblyInternal/VariablesProxy.cs @@ -2,44 +2,43 @@ using System.Collections; using System.Collections.Generic; -namespace SqlDatabase.Scripts.AssemblyInternal +namespace SqlDatabase.Scripts.AssemblyInternal; + +internal sealed class VariablesProxy : MarshalByRefObject, IReadOnlyDictionary { - internal sealed class VariablesProxy : MarshalByRefObject, IReadOnlyDictionary - { - private readonly IVariables _variables; + private readonly IVariables _variables; - public VariablesProxy(IVariables variables) - { - _variables = variables; - } + public VariablesProxy(IVariables variables) + { + _variables = variables; + } - public int Count => throw new NotSupportedException(); + public int Count => throw new NotSupportedException(); - public IEnumerable Keys => throw new NotSupportedException(); + public IEnumerable Keys => throw new NotSupportedException(); - public IEnumerable Values => throw new NotSupportedException(); + public IEnumerable Values => throw new NotSupportedException(); - public string this[string key] => _variables.GetValue(key); + public string this[string key] => _variables.GetValue(key); - public bool ContainsKey(string key) - { - return _variables.GetValue(key) != null; - } + public bool ContainsKey(string key) + { + return _variables.GetValue(key) != null; + } - public bool TryGetValue(string key, out string value) - { - value = _variables.GetValue(key); - return value != null; - } + public bool TryGetValue(string key, out string value) + { + value = _variables.GetValue(key); + return value != null; + } - public IEnumerator> GetEnumerator() - { - throw new NotSupportedException(); - } + public IEnumerator> GetEnumerator() + { + throw new NotSupportedException(); + } - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); } } \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/AssemblyScript.cs b/Sources/SqlDatabase/Scripts/AssemblyScript.cs index 34cc6c73..49684069 100644 --- a/Sources/SqlDatabase/Scripts/AssemblyScript.cs +++ b/Sources/SqlDatabase/Scripts/AssemblyScript.cs @@ -6,85 +6,84 @@ using SqlDatabase.Configuration; using SqlDatabase.Scripts.AssemblyInternal; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +internal sealed class AssemblyScript : IScript { - internal sealed class AssemblyScript : IScript - { - public string DisplayName { get; set; } + public string DisplayName { get; set; } - public Func ReadAssemblyContent { get; set; } + public Func ReadAssemblyContent { get; set; } - public Func ReadDescriptionContent { get; set; } + public Func ReadDescriptionContent { get; set; } - public AssemblyScriptConfiguration Configuration { get; set; } + public AssemblyScriptConfiguration Configuration { get; set; } + + public void Execute(IDbCommand command, IVariables variables, ILogger logger) + { + var domain = CreateSubDomain(); - public void Execute(IDbCommand command, IVariables variables, ILogger logger) + using (domain) { - var domain = CreateSubDomain(); + domain.Logger = logger; + domain.AssemblyFileName = DisplayName; + domain.ReadAssemblyContent = ReadAssemblyContent; - using (domain) + try { - domain.Logger = logger; - domain.AssemblyFileName = DisplayName; - domain.ReadAssemblyContent = ReadAssemblyContent; - - try - { - domain.Initialize(); - ResolveScriptExecutor(domain); - Execute(domain, command, variables); - } - finally - { - domain.Unload(); - } + domain.Initialize(); + ResolveScriptExecutor(domain); + Execute(domain, command, variables); + } + finally + { + domain.Unload(); } } + } - public IEnumerable ExecuteReader(IDbCommand command, IVariables variables, ILogger logger) - { - throw new NotSupportedException("Assembly script does not support readers."); - } + public IEnumerable ExecuteReader(IDbCommand command, IVariables variables, ILogger logger) + { + throw new NotSupportedException("Assembly script does not support readers."); + } - public IList GetDependencies() + public IList GetDependencies() + { + using (var description = ReadDescriptionContent()) { - using (var description = ReadDescriptionContent()) + if (description == null) { - if (description == null) - { - return new ScriptDependency[0]; - } - - using (var reader = new StreamReader(description)) - { - return DependencyParser.ExtractDependencies(reader, DisplayName).ToArray(); - } + return new ScriptDependency[0]; } - } - internal void ResolveScriptExecutor(ISubDomain domain) - { - if (!domain.ResolveScriptExecutor(Configuration.ClassName, Configuration.MethodName)) + using (var reader = new StreamReader(description)) { - throw new InvalidOperationException("Fail to resolve script executor."); + return DependencyParser.ExtractDependencies(reader, DisplayName).ToArray(); } } + } - internal void Execute(ISubDomain domain, IDbCommand command, IVariables variables) + internal void ResolveScriptExecutor(ISubDomain domain) + { + if (!domain.ResolveScriptExecutor(Configuration.ClassName, Configuration.MethodName)) { - if (command != null && !domain.Execute(command, variables)) - { - throw new InvalidOperationException("Errors during script execution."); - } + throw new InvalidOperationException("Fail to resolve script executor."); } + } - private ISubDomain CreateSubDomain() + internal void Execute(ISubDomain domain, IDbCommand command, IVariables variables) + { + if (command != null && !domain.Execute(command, variables)) { + throw new InvalidOperationException("Errors during script execution."); + } + } + + private ISubDomain CreateSubDomain() + { #if NET452 return new AssemblyInternal.Net452.Net452SubDomain(); #else - return new AssemblyInternal.NetCore.NetCoreSubDomain(); + return new AssemblyInternal.NetCore.NetCoreSubDomain(); #endif - } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/CreateScriptSequence.cs b/Sources/SqlDatabase/Scripts/CreateScriptSequence.cs index 4347d546..fc7bea44 100644 --- a/Sources/SqlDatabase/Scripts/CreateScriptSequence.cs +++ b/Sources/SqlDatabase/Scripts/CreateScriptSequence.cs @@ -3,60 +3,59 @@ using System.Linq; using SqlDatabase.IO; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +internal sealed class CreateScriptSequence : ICreateScriptSequence { - internal sealed class CreateScriptSequence : ICreateScriptSequence - { - public IList Sources { get; set; } + public IList Sources { get; set; } - public IScriptFactory ScriptFactory { get; set; } + public IScriptFactory ScriptFactory { get; set; } - public IList BuildSequence() - { - var result = new List(); + public IList BuildSequence() + { + var result = new List(); - foreach (var source in Sources) + foreach (var source in Sources) + { + if (source is IFolder folder) { - if (source is IFolder folder) - { - Build(folder, null, ScriptFactory, result); - } - else if (ScriptFactory.IsSupported(source.Name)) - { - result.Add(ScriptFactory.FromFile((IFile)source)); - } + Build(folder, null, ScriptFactory, result); + } + else if (ScriptFactory.IsSupported(source.Name)) + { + result.Add(ScriptFactory.FromFile((IFile)source)); } - - return result; } - private static void Build( - IFolder root, - string fullPath, - IScriptFactory factory, - List scripts) - { - fullPath = fullPath == null ? root.Name : Path.Combine(fullPath, root.Name); + return result; + } - var files = root - .GetFiles() - .Where(i => factory.IsSupported(i.Name)) - .OrderBy(i => i.Name) - .Select(factory.FromFile); + private static void Build( + IFolder root, + string fullPath, + IScriptFactory factory, + List scripts) + { + fullPath = fullPath == null ? root.Name : Path.Combine(fullPath, root.Name); - foreach (var file in files) - { - file.DisplayName = Path.Combine(fullPath, file.DisplayName); - scripts.Add(file); - } + var files = root + .GetFiles() + .Where(i => factory.IsSupported(i.Name)) + .OrderBy(i => i.Name) + .Select(factory.FromFile); - var folders = root - .GetFolders() - .OrderBy(i => i.Name); - foreach (var subFolder in folders) - { - Build(subFolder, fullPath, factory, scripts); - } + foreach (var file in files) + { + file.DisplayName = Path.Combine(fullPath, file.DisplayName); + scripts.Add(file); + } + + var folders = root + .GetFolders() + .OrderBy(i => i.Name); + foreach (var subFolder in folders) + { + Build(subFolder, fullPath, factory, scripts); } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/Database.cs b/Sources/SqlDatabase/Scripts/Database.cs index 35ac02a4..9281be8f 100644 --- a/Sources/SqlDatabase/Scripts/Database.cs +++ b/Sources/SqlDatabase/Scripts/Database.cs @@ -4,213 +4,212 @@ using System.Data.Common; using SqlDatabase.Configuration; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +internal sealed class Database : IDatabase { - internal sealed class Database : IDatabase + public Database() { - public Database() - { - Variables = new Variables(); - } + Variables = new Variables(); + } - public IDatabaseAdapter Adapter { get; set; } + public IDatabaseAdapter Adapter { get; set; } - public ILogger Log { get; set; } + public ILogger Log { get; set; } - public TransactionMode Transaction { get; set; } + public TransactionMode Transaction { get; set; } - public bool WhatIf { get; set; } + public bool WhatIf { get; set; } - internal Variables Variables { get; } + internal Variables Variables { get; } - public Version GetCurrentVersion(string moduleName) - { - Variables.ModuleName = moduleName; + public Version GetCurrentVersion(string moduleName) + { + Variables.ModuleName = moduleName; - using (var connection = Adapter.CreateConnection(false)) - using (var command = connection.CreateCommand()) - { - command.CommandTimeout = 0; - connection.Open(); + using (var connection = Adapter.CreateConnection(false)) + using (var command = connection.CreateCommand()) + { + command.CommandTimeout = 0; + connection.Open(); - return ReadCurrentVersion(command); - } + return ReadCurrentVersion(command); } + } - public string GetServerVersion() + public string GetServerVersion() + { + using (var connection = Adapter.CreateConnection(true)) + using (var command = connection.CreateCommand()) { - using (var connection = Adapter.CreateConnection(true)) - using (var command = connection.CreateCommand()) - { - command.CommandText = Adapter.GetServerVersionSelectScript(); + command.CommandText = Adapter.GetServerVersionSelectScript(); - connection.Open(); - return Convert.ToString(command.ExecuteScalar()); - } + connection.Open(); + return Convert.ToString(command.ExecuteScalar()); } + } - public void Execute(IScript script, string moduleName, Version currentVersion, Version targetVersion) - { - Variables.ModuleName = moduleName; - Variables.CurrentVersion = currentVersion.ToString(); - Variables.TargetVersion = targetVersion.ToString(); - Variables.DatabaseName = Adapter.DatabaseName; + public void Execute(IScript script, string moduleName, Version currentVersion, Version targetVersion) + { + Variables.ModuleName = moduleName; + Variables.CurrentVersion = currentVersion.ToString(); + Variables.TargetVersion = targetVersion.ToString(); + Variables.DatabaseName = Adapter.DatabaseName; - if (WhatIf) - { - ExecuteWhatIf(script); - } - else - { - InvokeExecuteUpgrade(script, targetVersion); - } + if (WhatIf) + { + ExecuteWhatIf(script); } - - public void Execute(IScript script) + else { - Variables.DatabaseName = Adapter.DatabaseName; + InvokeExecuteUpgrade(script, targetVersion); + } + } - if (WhatIf) - { - ExecuteWhatIf(script); - } - else - { - InvokeExecute(script); - } + public void Execute(IScript script) + { + Variables.DatabaseName = Adapter.DatabaseName; + + if (WhatIf) + { + ExecuteWhatIf(script); + } + else + { + InvokeExecute(script); } + } + + public IEnumerable ExecuteReader(IScript script) + { + Variables.DatabaseName = Adapter.DatabaseName; - public IEnumerable ExecuteReader(IScript script) + using (var connection = Adapter.CreateConnection(false)) { - Variables.DatabaseName = Adapter.DatabaseName; + connection.Open(); - using (var connection = Adapter.CreateConnection(false)) + using (var command = connection.CreateCommand()) { - connection.Open(); + command.CommandTimeout = 0; - using (var command = connection.CreateCommand()) + foreach (var reader in script.ExecuteReader(command, Variables, Log)) { - command.CommandTimeout = 0; - - foreach (var reader in script.ExecuteReader(command, Variables, Log)) - { - yield return reader; - } + yield return reader; } } } + } - private void WriteCurrentVersion(IDbCommand command, Version targetVersion) - { - var script = new SqlScriptVariableParser(Variables).ApplyVariables(Adapter.GetVersionUpdateScript()); - command.CommandText = script; - - try - { - command.ExecuteNonQuery(); - } - catch (DbException ex) - { - throw new InvalidOperationException("Fail to update the version, script: {0}".FormatWith(script), ex); - } + private void WriteCurrentVersion(IDbCommand command, Version targetVersion) + { + var script = new SqlScriptVariableParser(Variables).ApplyVariables(Adapter.GetVersionUpdateScript()); + command.CommandText = script; - var checkVersion = ReadCurrentVersion(command); - if (checkVersion != targetVersion) - { - throw new InvalidOperationException("Set version script works incorrectly: expected version is {0}, but actual is {1}. Script: {2}".FormatWith( - targetVersion, - checkVersion, - script)); - } + try + { + command.ExecuteNonQuery(); + } + catch (DbException ex) + { + throw new InvalidOperationException("Fail to update the version, script: {0}".FormatWith(script), ex); } - private Version ReadCurrentVersion(IDbCommand command) + var checkVersion = ReadCurrentVersion(command); + if (checkVersion != targetVersion) { - var script = new SqlScriptVariableParser(Variables).ApplyVariables(Adapter.GetVersionSelectScript()); - command.CommandText = script; + throw new InvalidOperationException("Set version script works incorrectly: expected version is {0}, but actual is {1}. Script: {2}".FormatWith( + targetVersion, + checkVersion, + script)); + } + } - string version; - try - { - version = Convert.ToString(command.ExecuteScalar()); - } - catch (DbException ex) - { - throw new InvalidOperationException("Fail to read the version, script: {0}".FormatWith(script), ex); - } + private Version ReadCurrentVersion(IDbCommand command) + { + var script = new SqlScriptVariableParser(Variables).ApplyVariables(Adapter.GetVersionSelectScript()); + command.CommandText = script; - if (!Version.TryParse(version, out var result)) - { - if (string.IsNullOrEmpty(Variables.ModuleName)) - { - throw new InvalidOperationException("The version [{0}] of database is invalid.".FormatWith(version)); - } + string version; + try + { + version = Convert.ToString(command.ExecuteScalar()); + } + catch (DbException ex) + { + throw new InvalidOperationException("Fail to read the version, script: {0}".FormatWith(script), ex); + } - throw new InvalidOperationException("The version [{0}] of module [{1}] is invalid.".FormatWith(version, Variables.ModuleName)); + if (!Version.TryParse(version, out var result)) + { + if (string.IsNullOrEmpty(Variables.ModuleName)) + { + throw new InvalidOperationException("The version [{0}] of database is invalid.".FormatWith(version)); } - return result; + throw new InvalidOperationException("The version [{0}] of module [{1}] is invalid.".FormatWith(version, Variables.ModuleName)); } - private void InvokeExecuteUpgrade(IScript script, Version targetVersion) + return result; + } + + private void InvokeExecuteUpgrade(IScript script, Version targetVersion) + { + using (var connection = Adapter.CreateConnection(false)) + using (var command = connection.CreateCommand()) { - using (var connection = Adapter.CreateConnection(false)) - using (var command = connection.CreateCommand()) - { - command.CommandTimeout = 0; - connection.Open(); + command.CommandTimeout = 0; + connection.Open(); - using (var transaction = Transaction == TransactionMode.PerStep ? connection.BeginTransaction(IsolationLevel.ReadCommitted) : null) - { - command.Transaction = transaction; + using (var transaction = Transaction == TransactionMode.PerStep ? connection.BeginTransaction(IsolationLevel.ReadCommitted) : null) + { + command.Transaction = transaction; - script.Execute(command, Variables, Log); + script.Execute(command, Variables, Log); - WriteCurrentVersion(command, targetVersion); + WriteCurrentVersion(command, targetVersion); - transaction?.Commit(); - } + transaction?.Commit(); } } + } - private void InvokeExecute(IScript script) + private void InvokeExecute(IScript script) + { + bool useMaster; + + using (var connection = Adapter.CreateConnection(true)) + using (var command = connection.CreateCommand()) { - bool useMaster; + command.CommandTimeout = 0; + connection.Open(); - using (var connection = Adapter.CreateConnection(true)) - using (var command = connection.CreateCommand()) - { - command.CommandTimeout = 0; - connection.Open(); + command.CommandText = Adapter.GetDatabaseExistsScript(Variables.DatabaseName); + var value = command.ExecuteScalar(); - command.CommandText = Adapter.GetDatabaseExistsScript(Variables.DatabaseName); - var value = command.ExecuteScalar(); + useMaster = value == null || Convert.IsDBNull(value); + } - useMaster = value == null || Convert.IsDBNull(value); - } + using (var connection = Adapter.CreateConnection(useMaster)) + { + connection.Open(); - using (var connection = Adapter.CreateConnection(useMaster)) + using (var transaction = Transaction == TransactionMode.PerStep ? connection.BeginTransaction(IsolationLevel.ReadCommitted) : null) { - connection.Open(); - - using (var transaction = Transaction == TransactionMode.PerStep ? connection.BeginTransaction(IsolationLevel.ReadCommitted) : null) + using (var command = connection.CreateCommand()) { - using (var command = connection.CreateCommand()) - { - command.Transaction = transaction; - command.CommandTimeout = 0; - script.Execute(command, Variables, Log); - } - - transaction?.Commit(); + command.Transaction = transaction; + command.CommandTimeout = 0; + script.Execute(command, Variables, Log); } + + transaction?.Commit(); } } + } - private void ExecuteWhatIf(IScript script) - { - Log.Info("what-if mode"); - script.Execute(null, Variables, Log); - } + private void ExecuteWhatIf(IScript script) + { + Log.Info("what-if mode"); + script.Execute(null, Variables, Log); } } \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/DatabaseAdapterFactory.cs b/Sources/SqlDatabase/Scripts/DatabaseAdapterFactory.cs index a1c3a685..c64f5aa8 100644 --- a/Sources/SqlDatabase/Scripts/DatabaseAdapterFactory.cs +++ b/Sources/SqlDatabase/Scripts/DatabaseAdapterFactory.cs @@ -10,91 +10,90 @@ using SqlDatabase.Scripts.MySql; using SqlDatabase.Scripts.PgSql; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +internal static class DatabaseAdapterFactory { - internal static class DatabaseAdapterFactory + public static IDatabaseAdapter CreateAdapter(string connectionString, AppConfiguration configuration, ILogger log) { - public static IDatabaseAdapter CreateAdapter(string connectionString, AppConfiguration configuration, ILogger log) + // connection strings are compatible + var factories = new List>(3); + + if (CanBe(connectionString, "Data Source", "Initial Catalog")) { - // connection strings are compatible - var factories = new List>(3); - - if (CanBe(connectionString, "Data Source", "Initial Catalog")) - { - factories.Add(CreateMsSql); - } - - if (CanBe(connectionString, "Host", "Database")) - { - factories.Add(CreatePgSql); - } - - if (CanBe(connectionString, "Server", "Database")) - { - factories.Add(CreateMySql); - } - - if (factories.Count != 1) - { - throw new ConfigurationErrorsException("Could not determine the database type from the provided connection string."); - } - - return factories[0](connectionString, configuration, log); + factories.Add(CreateMsSql); } - private static IDatabaseAdapter CreateMsSql(string connectionString, AppConfiguration configuration, ILogger log) + if (CanBe(connectionString, "Host", "Database")) { - return new MsSqlDatabaseAdapter(connectionString, configuration, log); + factories.Add(CreatePgSql); } - private static IDatabaseAdapter CreatePgSql(string connectionString, AppConfiguration configuration, ILogger log) + if (CanBe(connectionString, "Server", "Database")) { - return new PgSqlDatabaseAdapter(connectionString, configuration, log); + factories.Add(CreateMySql); } - private static IDatabaseAdapter CreateMySql(string connectionString, AppConfiguration configuration, ILogger log) + if (factories.Count != 1) { - return new MySqlDatabaseAdapter(connectionString, configuration, log); + throw new ConfigurationErrorsException("Could not determine the database type from the provided connection string."); } - private static bool CanBe(string connectionString, params string[] keywords) - where TBuilder : DbConnectionStringBuilder, new() - { - if (!Is(connectionString)) - { - return false; - } + return factories[0](connectionString, configuration, log); + } + + private static IDatabaseAdapter CreateMsSql(string connectionString, AppConfiguration configuration, ILogger log) + { + return new MsSqlDatabaseAdapter(connectionString, configuration, log); + } - var test = new HashSet(keywords, StringComparer.OrdinalIgnoreCase); + private static IDatabaseAdapter CreatePgSql(string connectionString, AppConfiguration configuration, ILogger log) + { + return new PgSqlDatabaseAdapter(connectionString, configuration, log); + } - var pairs = connectionString.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); - for (var i = 0; i < pairs.Length; i++) - { - var pair = pairs[i].Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries); - test.Remove(pair[0]); - } + private static IDatabaseAdapter CreateMySql(string connectionString, AppConfiguration configuration, ILogger log) + { + return new MySqlDatabaseAdapter(connectionString, configuration, log); + } - return test.Count == 0; + private static bool CanBe(string connectionString, params string[] keywords) + where TBuilder : DbConnectionStringBuilder, new() + { + if (!Is(connectionString)) + { + return false; } - private static bool Is(string connectionString) - where TBuilder : DbConnectionStringBuilder, new() + var test = new HashSet(keywords, StringComparer.OrdinalIgnoreCase); + + var pairs = connectionString.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); + for (var i = 0; i < pairs.Length; i++) { - var builder = new TBuilder(); - - try - { - builder.ConnectionString = connectionString; - return true; - } - catch (ArgumentException) - { - } - catch (FormatException) - { - } + var pair = pairs[i].Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries); + test.Remove(pair[0]); + } - return false; + return test.Count == 0; + } + + private static bool Is(string connectionString) + where TBuilder : DbConnectionStringBuilder, new() + { + var builder = new TBuilder(); + + try + { + builder.ConnectionString = connectionString; + return true; + } + catch (ArgumentException) + { } + catch (FormatException) + { + } + + return false; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/DependencyParser.cs b/Sources/SqlDatabase/Scripts/DependencyParser.cs index 53c7c202..4161bead 100644 --- a/Sources/SqlDatabase/Scripts/DependencyParser.cs +++ b/Sources/SqlDatabase/Scripts/DependencyParser.cs @@ -4,43 +4,42 @@ using System.Text; using System.Text.RegularExpressions; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +internal static class DependencyParser { - internal static class DependencyParser - { - private const string ModuleDependencyPattern = "^(-|\\*)+.*module dependency:\\s?(?'name'[\\w\\-]+)(\\s+|\\s*-\\s*)(?'version'[\\.\\w]+)"; + private const string ModuleDependencyPattern = "^(-|\\*)+.*module dependency:\\s?(?'name'[\\w\\-]+)(\\s+|\\s*-\\s*)(?'version'[\\.\\w]+)"; - public static IEnumerable ExtractDependencies(TextReader reader, string scriptName) + public static IEnumerable ExtractDependencies(TextReader reader, string scriptName) + { + string line; + while ((line = reader.ReadLine()) != null) { - string line; - while ((line = reader.ReadLine()) != null) + if (TryParseDependencyLine(line, out var moduleName, out var versionText)) { - if (TryParseDependencyLine(line, out var moduleName, out var versionText)) + if (!Version.TryParse(versionText, out var version)) { - if (!Version.TryParse(versionText, out var version)) - { - throw new InvalidOperationException("The current version value [{0}] of module [{1}] is invalid, script {2}.".FormatWith(versionText, moduleName, scriptName)); - } - - yield return new ScriptDependency(moduleName, version); + throw new InvalidOperationException("The current version value [{0}] of module [{1}] is invalid, script {2}.".FormatWith(versionText, moduleName, scriptName)); } + + yield return new ScriptDependency(moduleName, version); } } + } - private static bool TryParseDependencyLine(string line, out string moduleName, out string version) - { - moduleName = null; - version = null; - - var match = Regex.Match(line, ModuleDependencyPattern, RegexOptions.IgnoreCase); - if (!match.Success) - { - return false; - } + private static bool TryParseDependencyLine(string line, out string moduleName, out string version) + { + moduleName = null; + version = null; - moduleName = match.Groups["name"].Value; - version = match.Groups["version"].Value; - return true; + var match = Regex.Match(line, ModuleDependencyPattern, RegexOptions.IgnoreCase); + if (!match.Success) + { + return false; } + + moduleName = match.Groups["name"].Value; + version = match.Groups["version"].Value; + return true; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/ICreateScriptSequence.cs b/Sources/SqlDatabase/Scripts/ICreateScriptSequence.cs index c8d89db0..86ff0c0c 100644 --- a/Sources/SqlDatabase/Scripts/ICreateScriptSequence.cs +++ b/Sources/SqlDatabase/Scripts/ICreateScriptSequence.cs @@ -1,9 +1,8 @@ using System.Collections.Generic; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +public interface ICreateScriptSequence { - public interface ICreateScriptSequence - { - IList BuildSequence(); - } + IList BuildSequence(); } \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/IDatabase.cs b/Sources/SqlDatabase/Scripts/IDatabase.cs index 883ffaa3..0f75c7ed 100644 --- a/Sources/SqlDatabase/Scripts/IDatabase.cs +++ b/Sources/SqlDatabase/Scripts/IDatabase.cs @@ -2,20 +2,19 @@ using System.Collections.Generic; using System.Data; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +internal interface IDatabase { - internal interface IDatabase - { - IDatabaseAdapter Adapter { get; } + IDatabaseAdapter Adapter { get; } - string GetServerVersion(); + string GetServerVersion(); - Version GetCurrentVersion(string moduleName); + Version GetCurrentVersion(string moduleName); - void Execute(IScript script, string moduleName, Version currentVersion, Version targetVersion); + void Execute(IScript script, string moduleName, Version currentVersion, Version targetVersion); - void Execute(IScript script); + void Execute(IScript script); - IEnumerable ExecuteReader(IScript script); - } -} + IEnumerable ExecuteReader(IScript script); +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/IDatabaseAdapter.cs b/Sources/SqlDatabase/Scripts/IDatabaseAdapter.cs index 83c0e9d6..a646ab38 100644 --- a/Sources/SqlDatabase/Scripts/IDatabaseAdapter.cs +++ b/Sources/SqlDatabase/Scripts/IDatabaseAdapter.cs @@ -2,26 +2,25 @@ using System.IO; using SqlDatabase.Export; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +internal interface IDatabaseAdapter { - internal interface IDatabaseAdapter - { - string DatabaseName { get; } + string DatabaseName { get; } - string GetUserFriendlyConnectionString(); + string GetUserFriendlyConnectionString(); - ISqlTextReader CreateSqlTextReader(); + ISqlTextReader CreateSqlTextReader(); - SqlWriterBase CreateSqlWriter(TextWriter output); + SqlWriterBase CreateSqlWriter(TextWriter output); - IDbConnection CreateConnection(bool switchToMaster); + IDbConnection CreateConnection(bool switchToMaster); - string GetServerVersionSelectScript(); + string GetServerVersionSelectScript(); - string GetDatabaseExistsScript(string databaseName); + string GetDatabaseExistsScript(string databaseName); - string GetVersionSelectScript(); + string GetVersionSelectScript(); - string GetVersionUpdateScript(); - } -} + string GetVersionUpdateScript(); +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/IPowerShellFactory.cs b/Sources/SqlDatabase/Scripts/IPowerShellFactory.cs index 39ca0756..f68528f5 100644 --- a/Sources/SqlDatabase/Scripts/IPowerShellFactory.cs +++ b/Sources/SqlDatabase/Scripts/IPowerShellFactory.cs @@ -1,15 +1,14 @@ using SqlDatabase.Scripts.PowerShellInternal; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +internal interface IPowerShellFactory { - internal interface IPowerShellFactory - { - string InstallationPath { get; } + string InstallationPath { get; } - void Request(); + void Request(); - void InitializeIfRequested(ILogger logger); + void InitializeIfRequested(ILogger logger); - IPowerShell Create(); - } -} + IPowerShell Create(); +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/IScript.cs b/Sources/SqlDatabase/Scripts/IScript.cs index a19c53e3..2cd6ce71 100644 --- a/Sources/SqlDatabase/Scripts/IScript.cs +++ b/Sources/SqlDatabase/Scripts/IScript.cs @@ -1,16 +1,15 @@ using System.Collections.Generic; using System.Data; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +public interface IScript { - public interface IScript - { - string DisplayName { get; set; } + string DisplayName { get; set; } - void Execute(IDbCommand command, IVariables variables, ILogger logger); + void Execute(IDbCommand command, IVariables variables, ILogger logger); - IEnumerable ExecuteReader(IDbCommand command, IVariables variables, ILogger logger); + IEnumerable ExecuteReader(IDbCommand command, IVariables variables, ILogger logger); - IList GetDependencies(); - } + IList GetDependencies(); } \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/IScriptFactory.cs b/Sources/SqlDatabase/Scripts/IScriptFactory.cs index 813f2d7f..a24eb2a1 100644 --- a/Sources/SqlDatabase/Scripts/IScriptFactory.cs +++ b/Sources/SqlDatabase/Scripts/IScriptFactory.cs @@ -1,11 +1,10 @@ using SqlDatabase.IO; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +public interface IScriptFactory { - public interface IScriptFactory - { - bool IsSupported(string fileName); + bool IsSupported(string fileName); - IScript FromFile(IFile file); - } + IScript FromFile(IFile file); } \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/ISqlTextReader.cs b/Sources/SqlDatabase/Scripts/ISqlTextReader.cs index ca0e5df9..1985cee0 100644 --- a/Sources/SqlDatabase/Scripts/ISqlTextReader.cs +++ b/Sources/SqlDatabase/Scripts/ISqlTextReader.cs @@ -1,12 +1,11 @@ using System.Collections.Generic; using System.IO; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +internal interface ISqlTextReader { - internal interface ISqlTextReader - { - string ReadFirstBatch(Stream sql); + string ReadFirstBatch(Stream sql); - IEnumerable ReadBatches(Stream sql); - } -} + IEnumerable ReadBatches(Stream sql); +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/IUpgradeScriptSequence.cs b/Sources/SqlDatabase/Scripts/IUpgradeScriptSequence.cs index 8c019cea..aad5a73d 100644 --- a/Sources/SqlDatabase/Scripts/IUpgradeScriptSequence.cs +++ b/Sources/SqlDatabase/Scripts/IUpgradeScriptSequence.cs @@ -1,9 +1,8 @@ using System.Collections.Generic; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +public interface IUpgradeScriptSequence { - public interface IUpgradeScriptSequence - { - IList BuildSequence(); - } + IList BuildSequence(); } \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/IVariables.cs b/Sources/SqlDatabase/Scripts/IVariables.cs index 15d6f588..f814e8e7 100644 --- a/Sources/SqlDatabase/Scripts/IVariables.cs +++ b/Sources/SqlDatabase/Scripts/IVariables.cs @@ -1,7 +1,6 @@ -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +public interface IVariables { - public interface IVariables - { - string GetValue(string name); - } + string GetValue(string name); } \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/MsSql/MsSqlDatabaseAdapter.cs b/Sources/SqlDatabase/Scripts/MsSql/MsSqlDatabaseAdapter.cs index 6bf130a2..442fe36f 100644 --- a/Sources/SqlDatabase/Scripts/MsSql/MsSqlDatabaseAdapter.cs +++ b/Sources/SqlDatabase/Scripts/MsSql/MsSqlDatabaseAdapter.cs @@ -4,97 +4,96 @@ using SqlDatabase.Configuration; using SqlDatabase.Export; -namespace SqlDatabase.Scripts.MsSql +namespace SqlDatabase.Scripts.MsSql; + +internal sealed class MsSqlDatabaseAdapter : IDatabaseAdapter { - internal sealed class MsSqlDatabaseAdapter : IDatabaseAdapter + public const string DefaultSelectVersion = "SELECT value from sys.fn_listextendedproperty('version', default, default, default, default, default, default)"; + public const string DefaultUpdateVersion = "EXEC sys.sp_updateextendedproperty @name=N'version', @value=N'{{TargetVersion}}'"; + + private readonly string _connectionString; + private readonly string _connectionStringMaster; + private readonly AppConfiguration _configuration; + private readonly ILogger _log; + private readonly SqlInfoMessageEventHandler _onConnectionInfoMessage; + + public MsSqlDatabaseAdapter( + string connectionString, + AppConfiguration configuration, + ILogger log) { - public const string DefaultSelectVersion = "SELECT value from sys.fn_listextendedproperty('version', default, default, default, default, default, default)"; - public const string DefaultUpdateVersion = "EXEC sys.sp_updateextendedproperty @name=N'version', @value=N'{{TargetVersion}}'"; - - private readonly string _connectionString; - private readonly string _connectionStringMaster; - private readonly AppConfiguration _configuration; - private readonly ILogger _log; - private readonly SqlInfoMessageEventHandler _onConnectionInfoMessage; - - public MsSqlDatabaseAdapter( - string connectionString, - AppConfiguration configuration, - ILogger log) - { - _connectionString = connectionString; - _configuration = configuration; - _log = log; + _connectionString = connectionString; + _configuration = configuration; + _log = log; - var builder = new SqlConnectionStringBuilder(connectionString); - DatabaseName = builder.InitialCatalog; - builder.InitialCatalog = "master"; - _connectionStringMaster = builder.ToString(); + var builder = new SqlConnectionStringBuilder(connectionString); + DatabaseName = builder.InitialCatalog; + builder.InitialCatalog = "master"; + _connectionStringMaster = builder.ToString(); - _onConnectionInfoMessage = OnConnectionInfoMessage; - } + _onConnectionInfoMessage = OnConnectionInfoMessage; + } - public string DatabaseName { get; } + public string DatabaseName { get; } - public string GetUserFriendlyConnectionString() - { - var cs = new SqlConnectionStringBuilder(_connectionString); - return "database [{0}] on [{1}]".FormatWith(cs.InitialCatalog, cs.DataSource); - } + public string GetUserFriendlyConnectionString() + { + var cs = new SqlConnectionStringBuilder(_connectionString); + return "database [{0}] on [{1}]".FormatWith(cs.InitialCatalog, cs.DataSource); + } - public ISqlTextReader CreateSqlTextReader() => new MsSqlTextReader(); + public ISqlTextReader CreateSqlTextReader() => new MsSqlTextReader(); - public SqlWriterBase CreateSqlWriter(TextWriter output) => new MsSqlWriter(output); + public SqlWriterBase CreateSqlWriter(TextWriter output) => new MsSqlWriter(output); - public IDbConnection CreateConnection(bool switchToMaster) - { - var connectionString = switchToMaster ? _connectionStringMaster : _connectionString; + public IDbConnection CreateConnection(bool switchToMaster) + { + var connectionString = switchToMaster ? _connectionStringMaster : _connectionString; - var connection = new SqlConnection(connectionString); - connection.InfoMessage += _onConnectionInfoMessage; + var connection = new SqlConnection(connectionString); + connection.InfoMessage += _onConnectionInfoMessage; - return connection; - } + return connection; + } - public string GetServerVersionSelectScript() => "select @@version"; + public string GetServerVersionSelectScript() => "select @@version"; - public string GetDatabaseExistsScript(string databaseName) => "SELECT 1 FROM sys.databases WHERE Name=N'{0}'".FormatWith(databaseName); + public string GetDatabaseExistsScript(string databaseName) => "SELECT 1 FROM sys.databases WHERE Name=N'{0}'".FormatWith(databaseName); - public string GetVersionSelectScript() + public string GetVersionSelectScript() + { + var script = _configuration.MsSql.GetCurrentVersionScript; + if (string.IsNullOrWhiteSpace(script)) { - var script = _configuration.MsSql.GetCurrentVersionScript; - if (string.IsNullOrWhiteSpace(script)) - { - script = _configuration.GetCurrentVersionScript; - } - - if (string.IsNullOrWhiteSpace(script)) - { - script = DefaultSelectVersion; - } - - return script; + script = _configuration.GetCurrentVersionScript; } - public string GetVersionUpdateScript() + if (string.IsNullOrWhiteSpace(script)) { - var script = _configuration.MsSql.SetCurrentVersionScript; - if (string.IsNullOrWhiteSpace(script)) - { - script = _configuration.SetCurrentVersionScript; - } - - if (string.IsNullOrWhiteSpace(script)) - { - script = DefaultUpdateVersion; - } - - return script; + script = DefaultSelectVersion; } - private void OnConnectionInfoMessage(object sender, SqlInfoMessageEventArgs e) + return script; + } + + public string GetVersionUpdateScript() + { + var script = _configuration.MsSql.SetCurrentVersionScript; + if (string.IsNullOrWhiteSpace(script)) { - _log.Info("output: {0}".FormatWith(e.ToString())); + script = _configuration.SetCurrentVersionScript; } + + if (string.IsNullOrWhiteSpace(script)) + { + script = DefaultUpdateVersion; + } + + return script; + } + + private void OnConnectionInfoMessage(object sender, SqlInfoMessageEventArgs e) + { + _log.Info("output: {0}".FormatWith(e.ToString())); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/MsSql/MsSqlTextReader.cs b/Sources/SqlDatabase/Scripts/MsSql/MsSqlTextReader.cs index 390569ab..6c49231c 100644 --- a/Sources/SqlDatabase/Scripts/MsSql/MsSqlTextReader.cs +++ b/Sources/SqlDatabase/Scripts/MsSql/MsSqlTextReader.cs @@ -4,60 +4,59 @@ using System.Text; using System.Text.RegularExpressions; -namespace SqlDatabase.Scripts.MsSql +namespace SqlDatabase.Scripts.MsSql; + +internal sealed class MsSqlTextReader : ISqlTextReader { - internal sealed class MsSqlTextReader : ISqlTextReader + private readonly Regex _goRegex = new Regex("^(\\s*(go)+\\s*)+$", RegexOptions.Compiled | RegexOptions.IgnoreCase); + + public string ReadFirstBatch(Stream sql) { - private readonly Regex _goRegex = new Regex("^(\\s*(go)+\\s*)+$", RegexOptions.Compiled | RegexOptions.IgnoreCase); + return ReadBatches(sql).FirstOrDefault(); + } - public string ReadFirstBatch(Stream sql) - { - return ReadBatches(sql).FirstOrDefault(); - } + public IEnumerable ReadBatches(Stream sql) + { + var batch = new StringBuilder(); - public IEnumerable ReadBatches(Stream sql) + foreach (var line in ReadLines(sql)) { - var batch = new StringBuilder(); - - foreach (var line in ReadLines(sql)) + if (IsGo(line)) { - if (IsGo(line)) + if (batch.Length > 0) { - if (batch.Length > 0) - { - yield return batch.ToString(); - batch.Clear(); - } + yield return batch.ToString(); + batch.Clear(); } - else if (batch.Length > 0 || line.Trim().Length > 0) + } + else if (batch.Length > 0 || line.Trim().Length > 0) + { + if (batch.Length > 0) { - if (batch.Length > 0) - { - batch.AppendLine(); - } - - batch.Append(line); + batch.AppendLine(); } - } - if (batch.Length > 0) - { - yield return batch.ToString(); + batch.Append(line); } } - internal bool IsGo(string text) => _goRegex.IsMatch(text); + if (batch.Length > 0) + { + yield return batch.ToString(); + } + } - private static IEnumerable ReadLines(Stream sql) + internal bool IsGo(string text) => _goRegex.IsMatch(text); + + private static IEnumerable ReadLines(Stream sql) + { + using (var reader = new StreamReader(sql)) { - using (var reader = new StreamReader(sql)) + string line; + while ((line = reader.ReadLine()) != null) { - string line; - while ((line = reader.ReadLine()) != null) - { - yield return line; - } + yield return line; } } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/MsSql/MsSqlWriter.cs b/Sources/SqlDatabase/Scripts/MsSql/MsSqlWriter.cs index 357f05c4..1df7ab2f 100644 --- a/Sources/SqlDatabase/Scripts/MsSql/MsSqlWriter.cs +++ b/Sources/SqlDatabase/Scripts/MsSql/MsSqlWriter.cs @@ -6,255 +6,254 @@ using System.Text; using SqlDatabase.Export; -namespace SqlDatabase.Scripts.MsSql +namespace SqlDatabase.Scripts.MsSql; + +internal sealed class MsSqlWriter : SqlWriterBase { - internal sealed class MsSqlWriter : SqlWriterBase + public MsSqlWriter(TextWriter output) + : base(output) { - public MsSqlWriter(TextWriter output) - : base(output) - { - } - - public override SqlWriterBase Name(string value) - { - const char OpenBracket = '['; - const char CloseBracket = ']'; - - if (value[0] != OpenBracket) - { - Output.Write(OpenBracket); - } - - Output.Write(value); - - if (value[value.Length - 1] != CloseBracket) - { - Output.Write(CloseBracket); - } + } - return this; - } + public override SqlWriterBase Name(string value) + { + const char OpenBracket = '['; + const char CloseBracket = ']'; - public override SqlWriterBase BatchSeparator() + if (value[0] != OpenBracket) { - Output.WriteLine("GO"); - return this; + Output.Write(OpenBracket); } - public override SqlWriterBase DataType(string typeName, int size, int precision, int scale) + Output.Write(value); + + if (value[value.Length - 1] != CloseBracket) { - var name = typeName.ToUpperInvariant(); - string sizeText = null; + Output.Write(CloseBracket); + } - switch (name) - { - case "INT": - case "TINYINT": - case "SMALLINT": - case "BIGINT": - break; - case "DECIMAL": - if (scale != 0) - { - sizeText = "{0},{1}".FormatWith(precision, scale); - } - else if (precision != 18) - { - // 18 is default - sizeText = precision.ToString(CultureInfo.InvariantCulture); - } - - break; - case "REAL": - name = "FLOAT"; - - break; - case "CHAR": - case "NCHAR": - case "VARCHAR": - case "NVARCHAR": - case "BINARY": - case "VARBINARY": - if (size <= 0 || size == int.MaxValue) - { - sizeText = "MAX"; - } - else if (size != 1) - { - sizeText = size.ToString(CultureInfo.InvariantCulture); - } - - break; - } + return this; + } - Output.Write(name.ToUpperInvariant()); - if (sizeText != null) - { - Output.Write("("); - Output.Write(sizeText); - Output.Write(")"); - } + public override SqlWriterBase BatchSeparator() + { + Output.WriteLine("GO"); + return this; + } - return this; - } + public override SqlWriterBase DataType(string typeName, int size, int precision, int scale) + { + var name = typeName.ToUpperInvariant(); + string sizeText = null; - public override ExportTable ReadSchemaTable(DataTable metadata, string tableName) + switch (name) { - var result = new ExportTable { Name = tableName }; - - const string GeneratedName = "GeneratedName"; - var generatedIndex = 0; - - var rows = metadata.Rows.Cast().OrderBy(i => (int)i["ColumnOrdinal"]); - foreach (var row in rows) - { - var name = (string)row["ColumnName"]; - if (string.IsNullOrWhiteSpace(name)) + case "INT": + case "TINYINT": + case "SMALLINT": + case "BIGINT": + break; + case "DECIMAL": + if (scale != 0) { - generatedIndex++; - name = GeneratedName + generatedIndex; + sizeText = "{0},{1}".FormatWith(precision, scale); + } + else if (precision != 18) + { + // 18 is default + sizeText = precision.ToString(CultureInfo.InvariantCulture); } - var typeName = (string)row["DataTypeName"]; - var size = (int)row["ColumnSize"]; - - if ("timestamp".Equals(typeName, StringComparison.OrdinalIgnoreCase) - || "RowVersion".Equals(typeName, StringComparison.OrdinalIgnoreCase)) + break; + case "REAL": + name = "FLOAT"; + + break; + case "CHAR": + case "NCHAR": + case "VARCHAR": + case "NVARCHAR": + case "BINARY": + case "VARBINARY": + if (size <= 0 || size == int.MaxValue) { - typeName = "VARBINARY"; - size = 8; + sizeText = "MAX"; } - else if (typeName.EndsWith("sys.HIERARCHYID", StringComparison.OrdinalIgnoreCase)) + else if (size != 1) { - // System.IO.FileNotFoundException : Could not load file or assembly 'Microsoft.SqlServer.Types, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies - throw new NotSupportedException("Data type hierarchyid is not supported, to export data convert value to NVARCHAR: SELECT CAST([{0}] AND NVARCHAR(100)) [{0}]".FormatWith(name)); + sizeText = size.ToString(CultureInfo.InvariantCulture); } - result.Columns.Add(new ExportTableColumn - { - Name = name, - SqlDataTypeName = typeName, - Size = size, - NumericPrecision = (short?)DataReaderTools.CleanValue(row["NumericPrecision"]), - NumericScale = (short?)DataReaderTools.CleanValue(row["NumericScale"]), - AllowNull = (bool)row["AllowDBNull"] - }); - } + break; + } - return result; + Output.Write(name.ToUpperInvariant()); + if (sizeText != null) + { + Output.Write("("); + Output.Write(sizeText); + Output.Write(")"); } - public override string GetDefaultTableName() => "dbo.SqlDatabaseExport"; + return this; + } + + public override ExportTable ReadSchemaTable(DataTable metadata, string tableName) + { + var result = new ExportTable { Name = tableName }; - protected override bool TryWriteValue(object value, string typeNameHint) - { - var type = value.GetType(); + const string GeneratedName = "GeneratedName"; + var generatedIndex = 0; - switch (Type.GetTypeCode(type)) + var rows = metadata.Rows.Cast().OrderBy(i => (int)i["ColumnOrdinal"]); + foreach (var row in rows) + { + var name = (string)row["ColumnName"]; + if (string.IsNullOrWhiteSpace(name)) { - case TypeCode.Boolean: - Output.Write((bool)value ? "1" : "0"); - return true; - - case TypeCode.Char: - break; - case TypeCode.SByte: - case TypeCode.UInt16: - case TypeCode.Byte: - case TypeCode.Int32: - case TypeCode.Int64: - case TypeCode.Int16: - case TypeCode.Single: - case TypeCode.UInt32: - case TypeCode.UInt64: - case TypeCode.Decimal: - Output.Write(Convert.ToString(value, CultureInfo.InvariantCulture)); - return true; - - case TypeCode.Double: - ValueDouble((double)value); - return true; - - case TypeCode.DateTime: - ValueDate((DateTime)value); - return true; - - case TypeCode.String: - Output.Write('N'); - ValueString((string)value); - return true; + generatedIndex++; + name = GeneratedName + generatedIndex; } - if (value is Guid id) + var typeName = (string)row["DataTypeName"]; + var size = (int)row["ColumnSize"]; + + if ("timestamp".Equals(typeName, StringComparison.OrdinalIgnoreCase) + || "RowVersion".Equals(typeName, StringComparison.OrdinalIgnoreCase)) { - ValueGuid(id); - return true; + typeName = "VARBINARY"; + size = 8; } - - if (value is byte[] array) + else if (typeName.EndsWith("sys.HIERARCHYID", StringComparison.OrdinalIgnoreCase)) { - ValueByteArray(array); - return true; + // System.IO.FileNotFoundException : Could not load file or assembly 'Microsoft.SqlServer.Types, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies + throw new NotSupportedException("Data type hierarchyid is not supported, to export data convert value to NVARCHAR: SELECT CAST([{0}] AND NVARCHAR(100)) [{0}]".FormatWith(name)); } - if (value is TimeSpan timeSpan) + result.Columns.Add(new ExportTableColumn { - ValueTimeSpan(timeSpan); + Name = name, + SqlDataTypeName = typeName, + Size = size, + NumericPrecision = (short?)DataReaderTools.CleanValue(row["NumericPrecision"]), + NumericScale = (short?)DataReaderTools.CleanValue(row["NumericScale"]), + AllowNull = (bool)row["AllowDBNull"] + }); + } + + return result; + } + + public override string GetDefaultTableName() => "dbo.SqlDatabaseExport"; + + protected override bool TryWriteValue(object value, string typeNameHint) + { + var type = value.GetType(); + + switch (Type.GetTypeCode(type)) + { + case TypeCode.Boolean: + Output.Write((bool)value ? "1" : "0"); return true; - } - if (value is DateTimeOffset dateTimeOffset) - { - ValueDateTimeOffset(dateTimeOffset); + case TypeCode.Char: + break; + case TypeCode.SByte: + case TypeCode.UInt16: + case TypeCode.Byte: + case TypeCode.Int32: + case TypeCode.Int64: + case TypeCode.Int16: + case TypeCode.Single: + case TypeCode.UInt32: + case TypeCode.UInt64: + case TypeCode.Decimal: + Output.Write(Convert.ToString(value, CultureInfo.InvariantCulture)); return true; - } - return false; - } + case TypeCode.Double: + ValueDouble((double)value); + return true; - private void ValueDate(DateTime value) - { - Output.Write(Q); - Output.Write(value.ToString("yyyy-MM-dd HH:mm:ss:fff", CultureInfo.InvariantCulture)); - Output.Write(Q); + case TypeCode.DateTime: + ValueDate((DateTime)value); + return true; + + case TypeCode.String: + Output.Write('N'); + ValueString((string)value); + return true; } - private void ValueGuid(Guid value) + if (value is Guid id) { - Output.Write(Q); - Output.Write(value); - Output.Write(Q); + ValueGuid(id); + return true; } - private void ValueByteArray(byte[] value) + if (value is byte[] array) { - var buff = new StringBuilder((value.Length * 2) + 2); - buff.Append("0x"); - for (var i = 0; i < value.Length; i++) - { - buff.AppendFormat(CultureInfo.InvariantCulture, "{0:x2}", value[i]); - } - - Output.Write(buff.ToString()); + ValueByteArray(array); + return true; } - private void ValueDouble(double value) + if (value is TimeSpan timeSpan) { - Output.Write(value.ToString("G17", CultureInfo.InvariantCulture)); + ValueTimeSpan(timeSpan); + return true; } - private void ValueTimeSpan(TimeSpan value) + if (value is DateTimeOffset dateTimeOffset) { - Output.Write(Q); - Output.Write(value.ToString("g", CultureInfo.InvariantCulture)); - Output.Write(Q); + ValueDateTimeOffset(dateTimeOffset); + return true; } - private void ValueDateTimeOffset(DateTimeOffset value) + return false; + } + + private void ValueDate(DateTime value) + { + Output.Write(Q); + Output.Write(value.ToString("yyyy-MM-dd HH:mm:ss:fff", CultureInfo.InvariantCulture)); + Output.Write(Q); + } + + private void ValueGuid(Guid value) + { + Output.Write(Q); + Output.Write(value); + Output.Write(Q); + } + + private void ValueByteArray(byte[] value) + { + var buff = new StringBuilder((value.Length * 2) + 2); + buff.Append("0x"); + for (var i = 0; i < value.Length; i++) { - Output.Write(Q); - Output.Write(value.ToString("yyyy-MM-ddTHH:mm:ss.fffK", CultureInfo.InvariantCulture)); - Output.Write(Q); + buff.AppendFormat(CultureInfo.InvariantCulture, "{0:x2}", value[i]); } + + Output.Write(buff.ToString()); + } + + private void ValueDouble(double value) + { + Output.Write(value.ToString("G17", CultureInfo.InvariantCulture)); + } + + private void ValueTimeSpan(TimeSpan value) + { + Output.Write(Q); + Output.Write(value.ToString("g", CultureInfo.InvariantCulture)); + Output.Write(Q); + } + + private void ValueDateTimeOffset(DateTimeOffset value) + { + Output.Write(Q); + Output.Write(value.ToString("yyyy-MM-ddTHH:mm:ss.fffK", CultureInfo.InvariantCulture)); + Output.Write(Q); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/MySql/MySqlDatabaseAdapter.cs b/Sources/SqlDatabase/Scripts/MySql/MySqlDatabaseAdapter.cs index 2ed91437..5ddaad7b 100644 --- a/Sources/SqlDatabase/Scripts/MySql/MySqlDatabaseAdapter.cs +++ b/Sources/SqlDatabase/Scripts/MySql/MySqlDatabaseAdapter.cs @@ -4,103 +4,102 @@ using SqlDatabase.Configuration; using SqlDatabase.Export; -namespace SqlDatabase.Scripts.MySql +namespace SqlDatabase.Scripts.MySql; + +internal sealed class MySqlDatabaseAdapter : IDatabaseAdapter { - internal sealed class MySqlDatabaseAdapter : IDatabaseAdapter + public const string DefaultSelectVersion = "SELECT version FROM version WHERE module_name = 'database'"; + public const string DefaultUpdateVersion = "UPDATE version SET version='{{TargetVersion}}' WHERE module_name = 'database'"; + + private readonly string _connectionString; + private readonly string _connectionStringMaster; + private readonly AppConfiguration _configuration; + private readonly ILogger _log; + private readonly MySqlInfoMessageEventHandler _onConnectionInfoMessage; + + public MySqlDatabaseAdapter( + string connectionString, + AppConfiguration configuration, + ILogger log) { - public const string DefaultSelectVersion = "SELECT version FROM version WHERE module_name = 'database'"; - public const string DefaultUpdateVersion = "UPDATE version SET version='{{TargetVersion}}' WHERE module_name = 'database'"; - - private readonly string _connectionString; - private readonly string _connectionStringMaster; - private readonly AppConfiguration _configuration; - private readonly ILogger _log; - private readonly MySqlInfoMessageEventHandler _onConnectionInfoMessage; - - public MySqlDatabaseAdapter( - string connectionString, - AppConfiguration configuration, - ILogger log) - { - _configuration = configuration; - _log = log; + _configuration = configuration; + _log = log; - var builder = new MySqlConnectionStringBuilder(connectionString); + var builder = new MySqlConnectionStringBuilder(connectionString); - DatabaseName = builder.Database; - _connectionString = builder.ToString(); + DatabaseName = builder.Database; + _connectionString = builder.ToString(); - builder.Database = null; - _connectionStringMaster = builder.ToString(); + builder.Database = null; + _connectionStringMaster = builder.ToString(); - _onConnectionInfoMessage = OnConnectionInfoMessage; - } + _onConnectionInfoMessage = OnConnectionInfoMessage; + } - public string DatabaseName { get; } + public string DatabaseName { get; } - public string GetUserFriendlyConnectionString() - { - var cs = new MySqlConnectionStringBuilder(_connectionString); - return "database [{0}] on [{1}]".FormatWith(cs.Database, cs.Server); - } + public string GetUserFriendlyConnectionString() + { + var cs = new MySqlConnectionStringBuilder(_connectionString); + return "database [{0}] on [{1}]".FormatWith(cs.Database, cs.Server); + } - public ISqlTextReader CreateSqlTextReader() => new MySqlTextReader(); + public ISqlTextReader CreateSqlTextReader() => new MySqlTextReader(); - public SqlWriterBase CreateSqlWriter(TextWriter output) => new MySqlWriter(output); + public SqlWriterBase CreateSqlWriter(TextWriter output) => new MySqlWriter(output); - public IDbConnection CreateConnection(bool switchToMaster) - { - var connectionString = switchToMaster ? _connectionStringMaster : _connectionString; + public IDbConnection CreateConnection(bool switchToMaster) + { + var connectionString = switchToMaster ? _connectionStringMaster : _connectionString; + + var connection = new MySqlConnection(connectionString); + connection.InfoMessage += _onConnectionInfoMessage; - var connection = new MySqlConnection(connectionString); - connection.InfoMessage += _onConnectionInfoMessage; + return connection; + } - return connection; + public string GetServerVersionSelectScript() => "SELECT concat(@@version_comment, ', ', version(), ', ', @@version_compile_os)"; + + public string GetDatabaseExistsScript(string databaseName) => "SELECT 1 FROM information_schema.schemata WHERE LOWER(schema_name) = LOWER('{0}')".FormatWith(databaseName); + + public string GetVersionSelectScript() + { + var script = _configuration.MySql.GetCurrentVersionScript; + if (string.IsNullOrWhiteSpace(script)) + { + script = _configuration.GetCurrentVersionScript; } - public string GetServerVersionSelectScript() => "SELECT concat(@@version_comment, ', ', version(), ', ', @@version_compile_os)"; + if (string.IsNullOrWhiteSpace(script)) + { + script = DefaultSelectVersion; + } - public string GetDatabaseExistsScript(string databaseName) => "SELECT 1 FROM information_schema.schemata WHERE LOWER(schema_name) = LOWER('{0}')".FormatWith(databaseName); + return script; + } - public string GetVersionSelectScript() + public string GetVersionUpdateScript() + { + var script = _configuration.MySql.SetCurrentVersionScript; + if (string.IsNullOrWhiteSpace(script)) { - var script = _configuration.MySql.GetCurrentVersionScript; - if (string.IsNullOrWhiteSpace(script)) - { - script = _configuration.GetCurrentVersionScript; - } - - if (string.IsNullOrWhiteSpace(script)) - { - script = DefaultSelectVersion; - } - - return script; + script = _configuration.SetCurrentVersionScript; } - public string GetVersionUpdateScript() + if (string.IsNullOrWhiteSpace(script)) { - var script = _configuration.MySql.SetCurrentVersionScript; - if (string.IsNullOrWhiteSpace(script)) - { - script = _configuration.SetCurrentVersionScript; - } - - if (string.IsNullOrWhiteSpace(script)) - { - script = DefaultUpdateVersion; - } - - return script; + script = DefaultUpdateVersion; } - private void OnConnectionInfoMessage(object sender, MySqlInfoMessageEventArgs args) + return script; + } + + private void OnConnectionInfoMessage(object sender, MySqlInfoMessageEventArgs args) + { + for (var i = 0; i < args.Errors.Count; i++) { - for (var i = 0; i < args.Errors.Count; i++) - { - var error = args.Errors[i]; - _log.Info("{0}: {1}".FormatWith(error.Level, error.Message)); - } + var error = args.Errors[i]; + _log.Info("{0}: {1}".FormatWith(error.Level, error.Message)); } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/MySql/MySqlTextReader.cs b/Sources/SqlDatabase/Scripts/MySql/MySqlTextReader.cs index e94cf451..b73be41b 100644 --- a/Sources/SqlDatabase/Scripts/MySql/MySqlTextReader.cs +++ b/Sources/SqlDatabase/Scripts/MySql/MySqlTextReader.cs @@ -3,60 +3,59 @@ using System.Text; using System.Text.RegularExpressions; -namespace SqlDatabase.Scripts.MySql +namespace SqlDatabase.Scripts.MySql; + +internal sealed class MySqlTextReader : ISqlTextReader { - internal sealed class MySqlTextReader : ISqlTextReader + private const int MaxFirstBatchSize = 20; + private readonly Regex _semicolonRegex = new Regex("^(\\s*;+\\s*)+$", RegexOptions.Compiled | RegexOptions.IgnoreCase); + + public string ReadFirstBatch(Stream sql) { - private const int MaxFirstBatchSize = 20; - private readonly Regex _semicolonRegex = new Regex("^(\\s*;+\\s*)+$", RegexOptions.Compiled | RegexOptions.IgnoreCase); + var script = new StringBuilder(); - public string ReadFirstBatch(Stream sql) + using (var reader = new StreamReader(sql)) { - var script = new StringBuilder(); - - using (var reader = new StreamReader(sql)) + string line; + var lineNumber = 0; + while ((line = reader.ReadLine()) != null) { - string line; - var lineNumber = 0; - while ((line = reader.ReadLine()) != null) + if (script.Length == 0 && string.IsNullOrWhiteSpace(line)) { - if (script.Length == 0 && string.IsNullOrWhiteSpace(line)) - { - continue; - } - - lineNumber++; - if (_semicolonRegex.IsMatch(line) || lineNumber > MaxFirstBatchSize) - { - break; - } - - if (script.Length > 0) - { - script.AppendLine(); - } - - script.Append(line); + continue; } - } - return script.ToString(); - } + lineNumber++; + if (_semicolonRegex.IsMatch(line) || lineNumber > MaxFirstBatchSize) + { + break; + } - public IEnumerable ReadBatches(Stream sql) - { - string script; - using (var reader = new StreamReader(sql)) - { - script = reader.ReadToEnd(); - } + if (script.Length > 0) + { + script.AppendLine(); + } - if (string.IsNullOrWhiteSpace(script)) - { - return new string[0]; + script.Append(line); } + } - return new[] { script }; + return script.ToString(); + } + + public IEnumerable ReadBatches(Stream sql) + { + string script; + using (var reader = new StreamReader(sql)) + { + script = reader.ReadToEnd(); } + + if (string.IsNullOrWhiteSpace(script)) + { + return new string[0]; + } + + return new[] { script }; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/MySql/MySqlWriter.cs b/Sources/SqlDatabase/Scripts/MySql/MySqlWriter.cs index 5a6ab0dd..0feac799 100644 --- a/Sources/SqlDatabase/Scripts/MySql/MySqlWriter.cs +++ b/Sources/SqlDatabase/Scripts/MySql/MySqlWriter.cs @@ -6,277 +6,276 @@ using System.Text; using SqlDatabase.Export; -namespace SqlDatabase.Scripts.MySql +namespace SqlDatabase.Scripts.MySql; + +internal sealed class MySqlWriter : SqlWriterBase { - internal sealed class MySqlWriter : SqlWriterBase + public MySqlWriter(TextWriter output) + : base(output) { - public MySqlWriter(TextWriter output) - : base(output) - { - } + } - public override SqlWriterBase Name(string value) - { - Output.Write(value); - return this; - } + public override SqlWriterBase Name(string value) + { + Output.Write(value); + return this; + } - public override SqlWriterBase BatchSeparator() - { - Output.WriteLine(";"); - return this; - } + public override SqlWriterBase BatchSeparator() + { + Output.WriteLine(";"); + return this; + } - public override string GetDefaultTableName() => "sqldatabase_export"; + public override string GetDefaultTableName() => "sqldatabase_export"; - public override SqlWriterBase DataType(string typeName, int size, int precision, int scale) + public override SqlWriterBase DataType(string typeName, int size, int precision, int scale) + { + var name = typeName.ToUpperInvariant(); + string sizeText = null; + + switch (name) { - var name = typeName.ToUpperInvariant(); - string sizeText = null; + case "TINYINT": + case "SMALLINT": + case "MEDIUMINT": + case "INT": + case "BIGINT": + case "BIT": + case "NCHAR": + case "NVARCHAR": + case "BINARY": + case "VARBINARY": + if (size != 0) + { + sizeText = size.ToString(CultureInfo.InvariantCulture); + } - switch (name) - { - case "TINYINT": - case "SMALLINT": - case "MEDIUMINT": - case "INT": - case "BIGINT": - case "BIT": - case "NCHAR": - case "NVARCHAR": - case "BINARY": - case "VARBINARY": - if (size != 0) - { - sizeText = size.ToString(CultureInfo.InvariantCulture); - } - - break; - case "TINYINT UNSIGNED": - case "SMALLINT UNSIGNED": - case "MEDIUMINT UNSIGNED": - case "INT UNSIGNED": - case "BIGINT UNSIGNED": - if (size != 0) - { - name = name.Insert(name.IndexOf(' '), "({0})".FormatWith(size)); - } - - break; - - case "NUMERIC": - if (scale != 0) - { - sizeText = "{0},{1}".FormatWith(precision, scale); - } - else if (precision != 0) - { - sizeText = precision.ToString(CultureInfo.InvariantCulture); - } - - break; - - case "FLOAT": - case "DOUBLE": - break; - } + break; + case "TINYINT UNSIGNED": + case "SMALLINT UNSIGNED": + case "MEDIUMINT UNSIGNED": + case "INT UNSIGNED": + case "BIGINT UNSIGNED": + if (size != 0) + { + name = name.Insert(name.IndexOf(' '), "({0})".FormatWith(size)); + } - Output.Write(name); - if (sizeText != null) - { - Output.Write("("); - Output.Write(sizeText); - Output.Write(")"); - } + break; + + case "NUMERIC": + if (scale != 0) + { + sizeText = "{0},{1}".FormatWith(precision, scale); + } + else if (precision != 0) + { + sizeText = precision.ToString(CultureInfo.InvariantCulture); + } + + break; - return this; + case "FLOAT": + case "DOUBLE": + break; } - public override ExportTable ReadSchemaTable(DataTable metadata, string tableName) + Output.Write(name); + if (sizeText != null) { - var result = new ExportTable { Name = tableName }; + Output.Write("("); + Output.Write(sizeText); + Output.Write(")"); + } - const string GeneratedName = "GeneratedName"; - var generatedIndex = 0; + return this; + } - var rows = metadata.Rows.Cast().OrderBy(i => (int)i["ColumnOrdinal"]); - foreach (var row in rows) - { - var name = (string)row["ColumnName"]; - if (string.IsNullOrWhiteSpace(name)) - { - generatedIndex++; - name = GeneratedName + generatedIndex; - } + public override ExportTable ReadSchemaTable(DataTable metadata, string tableName) + { + var result = new ExportTable { Name = tableName }; - var typeName = GetDataTypeName((int)row["ProviderType"]); - var size = (int)row["ColumnSize"]; + const string GeneratedName = "GeneratedName"; + var generatedIndex = 0; - result.Columns.Add(new ExportTableColumn - { - Name = name, - SqlDataTypeName = typeName, - Size = size, - NumericPrecision = (int?)DataReaderTools.CleanValue(row["NumericPrecision"]), - NumericScale = (int?)DataReaderTools.CleanValue(row["NumericScale"]), - AllowNull = (bool?)DataReaderTools.CleanValue(row["AllowDBNull"]) ?? true - }); + var rows = metadata.Rows.Cast().OrderBy(i => (int)i["ColumnOrdinal"]); + foreach (var row in rows) + { + var name = (string)row["ColumnName"]; + if (string.IsNullOrWhiteSpace(name)) + { + generatedIndex++; + name = GeneratedName + generatedIndex; } - return result; + var typeName = GetDataTypeName((int)row["ProviderType"]); + var size = (int)row["ColumnSize"]; + + result.Columns.Add(new ExportTableColumn + { + Name = name, + SqlDataTypeName = typeName, + Size = size, + NumericPrecision = (int?)DataReaderTools.CleanValue(row["NumericPrecision"]), + NumericScale = (int?)DataReaderTools.CleanValue(row["NumericScale"]), + AllowNull = (bool?)DataReaderTools.CleanValue(row["AllowDBNull"]) ?? true + }); } - protected override bool TryWriteValue(object value, string typeNameHint) + return result; + } + + protected override bool TryWriteValue(object value, string typeNameHint) + { + var type = value.GetType(); + + switch (Type.GetTypeCode(type)) { - var type = value.GetType(); + case TypeCode.Boolean: + Output.Write((bool)value ? "TRUE" : "FALSE"); + return true; - switch (Type.GetTypeCode(type)) - { - case TypeCode.Boolean: - Output.Write((bool)value ? "TRUE" : "FALSE"); - return true; - - case TypeCode.Char: - break; - case TypeCode.SByte: - case TypeCode.UInt16: - case TypeCode.Byte: - case TypeCode.Int32: - case TypeCode.Int64: - case TypeCode.Int16: - case TypeCode.Single: - case TypeCode.UInt32: - case TypeCode.UInt64: - case TypeCode.Decimal: - Output.Write(Convert.ToString(value, CultureInfo.InvariantCulture)); - return true; - - case TypeCode.Double: - Output.Write(((double)value).ToString("G17", CultureInfo.InvariantCulture)); - return true; - - case TypeCode.DateTime: - ValueDateTime((DateTime)value); - return true; - - case TypeCode.String: - if (typeNameHint == "GEOMETRY") - { - Output.Write((string)value); - } - else - { - Output.Write('N'); - ValueString((string)value); - } - - return true; - } + case TypeCode.Char: + break; + case TypeCode.SByte: + case TypeCode.UInt16: + case TypeCode.Byte: + case TypeCode.Int32: + case TypeCode.Int64: + case TypeCode.Int16: + case TypeCode.Single: + case TypeCode.UInt32: + case TypeCode.UInt64: + case TypeCode.Decimal: + Output.Write(Convert.ToString(value, CultureInfo.InvariantCulture)); + return true; - if (value is TimeSpan timeSpan) - { - ValueDateTime(new DateTime(1970, 01, 01).Add(timeSpan)); + case TypeCode.Double: + Output.Write(((double)value).ToString("G17", CultureInfo.InvariantCulture)); return true; - } - if (value is byte[] array) - { - ValueByteArray(array); + case TypeCode.DateTime: + ValueDateTime((DateTime)value); return true; - } - return false; + case TypeCode.String: + if (typeNameHint == "GEOMETRY") + { + Output.Write((string)value); + } + else + { + Output.Write('N'); + ValueString((string)value); + } + + return true; } - private static string GetDataTypeName(int providerType) + if (value is TimeSpan timeSpan) { - // MySqlDbType - switch (providerType) - { - case -1: - return "BOOL"; - case 1: - return "TINYINT"; - case 501: - return "TINYINT UNSIGNED"; - case 2: - return "SMALLINT"; - case 502: - return "SMALLINT UNSIGNED"; - case 3: - return "INT"; - case 503: - return "INT UNSIGNED"; - case 4: - return "FLOAT"; - case 5: - return "DOUBLE"; - case 7: - return "TIMESTAMP"; - case 8: - return "BIGINT"; - case 508: - return "BIGINT UNSIGNED"; - case 9: - return "MEDIUMINT"; - case 509: - return "MEDIUMINT UNSIGNED"; - case 10: - return "DATE"; - case 11: - return "TIME"; - case 12: - return "DATETIME"; - case 13: - return "YEAR"; - case 16: - return "BIT"; - case 245: - return "JSON"; - case 246: - return "NUMERIC"; - case 247: - // ENUM - return "NVARCHAR"; - case 248: - // SET - return "NVARCHAR"; - case 252: - return "BLOB"; - case 253: - return "NVARCHAR"; - case 254: - return "NCHAR"; - case 255: - return "GEOMETRY"; - case 600: - return "BINARY"; - case 601: - return "VARBINARY"; - case 752: - return "TEXT"; - } - - return "NVARCHAR"; + ValueDateTime(new DateTime(1970, 01, 01).Add(timeSpan)); + return true; } - private void ValueDateTime(DateTime value) + if (value is byte[] array) { - Output.Write(Q); - Output.Write(value.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture)); - Output.Write(Q); + ValueByteArray(array); + return true; } - private void ValueByteArray(byte[] value) + return false; + } + + private static string GetDataTypeName(int providerType) + { + // MySqlDbType + switch (providerType) { - var buff = new StringBuilder((value.Length * 2) + 2); - buff.Append("0x"); - for (var i = 0; i < value.Length; i++) - { - buff.AppendFormat(CultureInfo.InvariantCulture, "{0:x2}", value[i]); - } + case -1: + return "BOOL"; + case 1: + return "TINYINT"; + case 501: + return "TINYINT UNSIGNED"; + case 2: + return "SMALLINT"; + case 502: + return "SMALLINT UNSIGNED"; + case 3: + return "INT"; + case 503: + return "INT UNSIGNED"; + case 4: + return "FLOAT"; + case 5: + return "DOUBLE"; + case 7: + return "TIMESTAMP"; + case 8: + return "BIGINT"; + case 508: + return "BIGINT UNSIGNED"; + case 9: + return "MEDIUMINT"; + case 509: + return "MEDIUMINT UNSIGNED"; + case 10: + return "DATE"; + case 11: + return "TIME"; + case 12: + return "DATETIME"; + case 13: + return "YEAR"; + case 16: + return "BIT"; + case 245: + return "JSON"; + case 246: + return "NUMERIC"; + case 247: + // ENUM + return "NVARCHAR"; + case 248: + // SET + return "NVARCHAR"; + case 252: + return "BLOB"; + case 253: + return "NVARCHAR"; + case 254: + return "NCHAR"; + case 255: + return "GEOMETRY"; + case 600: + return "BINARY"; + case 601: + return "VARBINARY"; + case 752: + return "TEXT"; + } + + return "NVARCHAR"; + } - Output.Write(buff.ToString()); + private void ValueDateTime(DateTime value) + { + Output.Write(Q); + Output.Write(value.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture)); + Output.Write(Q); + } + + private void ValueByteArray(byte[] value) + { + var buff = new StringBuilder((value.Length * 2) + 2); + buff.Append("0x"); + for (var i = 0; i < value.Length; i++) + { + buff.AppendFormat(CultureInfo.InvariantCulture, "{0:x2}", value[i]); } + + Output.Write(buff.ToString()); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/PgSql/PgSqlDatabaseAdapter.cs b/Sources/SqlDatabase/Scripts/PgSql/PgSqlDatabaseAdapter.cs index 7fdd78df..10243fb5 100644 --- a/Sources/SqlDatabase/Scripts/PgSql/PgSqlDatabaseAdapter.cs +++ b/Sources/SqlDatabase/Scripts/PgSql/PgSqlDatabaseAdapter.cs @@ -4,103 +4,102 @@ using SqlDatabase.Configuration; using SqlDatabase.Export; -namespace SqlDatabase.Scripts.PgSql +namespace SqlDatabase.Scripts.PgSql; + +internal sealed class PgSqlDatabaseAdapter : IDatabaseAdapter { - internal sealed class PgSqlDatabaseAdapter : IDatabaseAdapter + public const string DefaultSelectVersion = "SELECT version FROM public.version WHERE module_name = 'database'"; + public const string DefaultUpdateVersion = "UPDATE public.version SET version='{{TargetVersion}}' WHERE module_name = 'database'"; + + private readonly string _connectionString; + private readonly string _connectionStringMaster; + private readonly AppConfiguration _configuration; + private readonly ILogger _log; + private readonly NoticeEventHandler _onConnectionNotice; + + public PgSqlDatabaseAdapter( + string connectionString, + AppConfiguration configuration, + ILogger log) { - public const string DefaultSelectVersion = "SELECT version FROM public.version WHERE module_name = 'database'"; - public const string DefaultUpdateVersion = "UPDATE public.version SET version='{{TargetVersion}}' WHERE module_name = 'database'"; - - private readonly string _connectionString; - private readonly string _connectionStringMaster; - private readonly AppConfiguration _configuration; - private readonly ILogger _log; - private readonly NoticeEventHandler _onConnectionNotice; - - public PgSqlDatabaseAdapter( - string connectionString, - AppConfiguration configuration, - ILogger log) + _configuration = configuration; + _log = log; + + var builder = new NpgsqlConnectionStringBuilder(connectionString) { - _configuration = configuration; - _log = log; + // force disable pooling, see IT 01.drop.ps1; 02.create.sql + Pooling = false + }; - var builder = new NpgsqlConnectionStringBuilder(connectionString) - { - // force disable pooling, see IT 01.drop.ps1; 02.create.sql - Pooling = false - }; + DatabaseName = builder.Database; + _connectionString = builder.ToString(); - DatabaseName = builder.Database; - _connectionString = builder.ToString(); + builder.Database = null; + _connectionStringMaster = builder.ToString(); - builder.Database = null; - _connectionStringMaster = builder.ToString(); + _onConnectionNotice = OnConnectionNotice; + } - _onConnectionNotice = OnConnectionNotice; - } + public string DatabaseName { get; } - public string DatabaseName { get; } + public string GetUserFriendlyConnectionString() + { + var cs = new NpgsqlConnectionStringBuilder(_connectionString); + return "database [{0}] on [{1}]".FormatWith(cs.Database, cs.Host); + } - public string GetUserFriendlyConnectionString() - { - var cs = new NpgsqlConnectionStringBuilder(_connectionString); - return "database [{0}] on [{1}]".FormatWith(cs.Database, cs.Host); - } + public ISqlTextReader CreateSqlTextReader() => new PgSqlTextReader(); - public ISqlTextReader CreateSqlTextReader() => new PgSqlTextReader(); + public SqlWriterBase CreateSqlWriter(TextWriter output) => new PgSqlWriter(output); - public SqlWriterBase CreateSqlWriter(TextWriter output) => new PgSqlWriter(output); + public IDbConnection CreateConnection(bool switchToMaster) + { + var connectionString = switchToMaster ? _connectionStringMaster : _connectionString; - public IDbConnection CreateConnection(bool switchToMaster) - { - var connectionString = switchToMaster ? _connectionStringMaster : _connectionString; + var connection = new NpgsqlConnection(connectionString); + connection.Notice += _onConnectionNotice; - var connection = new NpgsqlConnection(connectionString); - connection.Notice += _onConnectionNotice; + return connection; + } - return connection; - } + public string GetServerVersionSelectScript() => "SELECT version();"; - public string GetServerVersionSelectScript() => "SELECT version();"; + public string GetDatabaseExistsScript(string databaseName) => "SELECT 1 FROM PG_DATABASE WHERE LOWER(DATNAME) = LOWER('{0}')".FormatWith(databaseName); - public string GetDatabaseExistsScript(string databaseName) => "SELECT 1 FROM PG_DATABASE WHERE LOWER(DATNAME) = LOWER('{0}')".FormatWith(databaseName); + public string GetVersionSelectScript() + { + var script = _configuration.PgSql.GetCurrentVersionScript; + if (string.IsNullOrWhiteSpace(script)) + { + script = _configuration.GetCurrentVersionScript; + } - public string GetVersionSelectScript() + if (string.IsNullOrWhiteSpace(script)) { - var script = _configuration.PgSql.GetCurrentVersionScript; - if (string.IsNullOrWhiteSpace(script)) - { - script = _configuration.GetCurrentVersionScript; - } - - if (string.IsNullOrWhiteSpace(script)) - { - script = DefaultSelectVersion; - } - - return script; + script = DefaultSelectVersion; } - public string GetVersionUpdateScript() + return script; + } + + public string GetVersionUpdateScript() + { + var script = _configuration.PgSql.SetCurrentVersionScript; + if (string.IsNullOrWhiteSpace(script)) { - var script = _configuration.PgSql.SetCurrentVersionScript; - if (string.IsNullOrWhiteSpace(script)) - { - script = _configuration.SetCurrentVersionScript; - } - - if (string.IsNullOrWhiteSpace(script)) - { - script = DefaultUpdateVersion; - } - - return script; + script = _configuration.SetCurrentVersionScript; } - private void OnConnectionNotice(object sender, NpgsqlNoticeEventArgs e) + if (string.IsNullOrWhiteSpace(script)) { - _log.Info("{0}: {1}".FormatWith(e.Notice.Severity, e.Notice.MessageText)); + script = DefaultUpdateVersion; } + + return script; + } + + private void OnConnectionNotice(object sender, NpgsqlNoticeEventArgs e) + { + _log.Info("{0}: {1}".FormatWith(e.Notice.Severity, e.Notice.MessageText)); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/PgSql/PgSqlTextReader.cs b/Sources/SqlDatabase/Scripts/PgSql/PgSqlTextReader.cs index 2d092434..cb06f215 100644 --- a/Sources/SqlDatabase/Scripts/PgSql/PgSqlTextReader.cs +++ b/Sources/SqlDatabase/Scripts/PgSql/PgSqlTextReader.cs @@ -4,60 +4,59 @@ using System.Text; using System.Text.RegularExpressions; -namespace SqlDatabase.Scripts.PgSql +namespace SqlDatabase.Scripts.PgSql; + +internal sealed class PgSqlTextReader : ISqlTextReader { - internal sealed class PgSqlTextReader : ISqlTextReader + private const int MaxFirstBatchSize = 20; + private readonly Regex _semicolonRegex = new Regex("^(\\s*;+\\s*)+$", RegexOptions.Compiled | RegexOptions.IgnoreCase); + + public string ReadFirstBatch(Stream sql) { - private const int MaxFirstBatchSize = 20; - private readonly Regex _semicolonRegex = new Regex("^(\\s*;+\\s*)+$", RegexOptions.Compiled | RegexOptions.IgnoreCase); + var script = new StringBuilder(); - public string ReadFirstBatch(Stream sql) + using (var reader = new StreamReader(sql)) { - var script = new StringBuilder(); - - using (var reader = new StreamReader(sql)) + string line; + var lineNumber = 0; + while ((line = reader.ReadLine()) != null) { - string line; - var lineNumber = 0; - while ((line = reader.ReadLine()) != null) + if (script.Length == 0 && string.IsNullOrWhiteSpace(line)) { - if (script.Length == 0 && string.IsNullOrWhiteSpace(line)) - { - continue; - } - - lineNumber++; - if (_semicolonRegex.IsMatch(line) || lineNumber > MaxFirstBatchSize) - { - break; - } - - if (script.Length > 0) - { - script.AppendLine(); - } - - script.Append(line); + continue; } - } - return script.ToString(); - } + lineNumber++; + if (_semicolonRegex.IsMatch(line) || lineNumber > MaxFirstBatchSize) + { + break; + } - public IEnumerable ReadBatches(Stream sql) - { - string script; - using (var reader = new StreamReader(sql)) - { - script = reader.ReadToEnd(); - } + if (script.Length > 0) + { + script.AppendLine(); + } - if (string.IsNullOrWhiteSpace(script)) - { - return new string[0]; + script.Append(line); } + } - return new[] { script }; + return script.ToString(); + } + + public IEnumerable ReadBatches(Stream sql) + { + string script; + using (var reader = new StreamReader(sql)) + { + script = reader.ReadToEnd(); } + + if (string.IsNullOrWhiteSpace(script)) + { + return new string[0]; + } + + return new[] { script }; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/PgSql/PgSqlWriter.cs b/Sources/SqlDatabase/Scripts/PgSql/PgSqlWriter.cs index c1cbe1b1..838ce2ef 100644 --- a/Sources/SqlDatabase/Scripts/PgSql/PgSqlWriter.cs +++ b/Sources/SqlDatabase/Scripts/PgSql/PgSqlWriter.cs @@ -11,483 +11,482 @@ using NpgsqlTypes; using SqlDatabase.Export; -namespace SqlDatabase.Scripts.PgSql +namespace SqlDatabase.Scripts.PgSql; + +internal sealed class PgSqlWriter : SqlWriterBase { - internal sealed class PgSqlWriter : SqlWriterBase + public PgSqlWriter(TextWriter output) + : base(output) { - public PgSqlWriter(TextWriter output) - : base(output) - { - } - - public override SqlWriterBase Name(string value) - { - Output.Write(value); - return this; - } - - public override SqlWriterBase BatchSeparator() - { - Output.WriteLine(";"); - return this; - } - - public override SqlWriterBase DataType(string typeName, int size, int precision, int scale) - { - var name = typeName.ToUpperInvariant(); - string sizeText = null; - - switch (name) - { - case "INTEGER": - case "SMALLINT": - case "BIGINT": - break; - case "NUMERIC": - case "TIMESTAMP": - case "INTERVAL": - case "TIME": - if (scale != 0) - { - sizeText = "{0},{1}".FormatWith(precision, scale); - } - else if (precision != 0) - { - sizeText = precision.ToString(CultureInfo.InvariantCulture); - } - - break; - case "CHARACTER VARYING": - case "CHARACTER": - case "BIT": - if (size > 0) - { - sizeText = size.ToString(CultureInfo.InvariantCulture); - } + } - break; - } + public override SqlWriterBase Name(string value) + { + Output.Write(value); + return this; + } - Output.Write(name); - if (sizeText != null) - { - Output.Write("("); - Output.Write(sizeText); - Output.Write(")"); - } + public override SqlWriterBase BatchSeparator() + { + Output.WriteLine(";"); + return this; + } - return this; - } + public override SqlWriterBase DataType(string typeName, int size, int precision, int scale) + { + var name = typeName.ToUpperInvariant(); + string sizeText = null; - public override ExportTable ReadSchemaTable(DataTable metadata, string tableName) + switch (name) { - var result = new ExportTable { Name = tableName }; - - const string GeneratedName = "GeneratedName"; - var generatedIndex = 0; - - var rows = metadata.Rows.Cast().OrderBy(i => (int)i["ColumnOrdinal"]); - foreach (var row in rows) - { - var name = (string)row["ColumnName"]; - if (string.IsNullOrWhiteSpace(name)) + case "INTEGER": + case "SMALLINT": + case "BIGINT": + break; + case "NUMERIC": + case "TIMESTAMP": + case "INTERVAL": + case "TIME": + if (scale != 0) { - generatedIndex++; - name = GeneratedName + generatedIndex; + sizeText = "{0},{1}".FormatWith(precision, scale); + } + else if (precision != 0) + { + sizeText = precision.ToString(CultureInfo.InvariantCulture); } - var typeName = (string)row["DataTypeName"]; - var size = (int)row["ColumnSize"]; - - result.Columns.Add(new ExportTableColumn + break; + case "CHARACTER VARYING": + case "CHARACTER": + case "BIT": + if (size > 0) { - Name = name, - SqlDataTypeName = typeName, - Size = size, - NumericPrecision = (int?)DataReaderTools.CleanValue(row["NumericPrecision"]), - NumericScale = (int?)DataReaderTools.CleanValue(row["NumericScale"]), - AllowNull = (bool?)DataReaderTools.CleanValue(row["AllowDBNull"]) ?? true - }); - } + sizeText = size.ToString(CultureInfo.InvariantCulture); + } - return result; + break; } - public override string GetDefaultTableName() => "public.sqldatabase_export"; - - protected override bool TryWriteValue(object value, string typeNameHint) + Output.Write(name); + if (sizeText != null) { - var type = value.GetType(); + Output.Write("("); + Output.Write(sizeText); + Output.Write(")"); + } - switch (Type.GetTypeCode(type)) - { - case TypeCode.Boolean: - if (string.Equals(typeNameHint, "bit", StringComparison.OrdinalIgnoreCase)) - { - Output.Write('B'); - Output.Write(Q); - Output.Write((bool)value ? "1" : "0"); - Output.Write(Q); - } - else - { - Output.Write((bool)value ? "true" : "false"); - } + return this; + } - return true; - - case TypeCode.Char: - break; - case TypeCode.SByte: - case TypeCode.UInt16: - case TypeCode.Byte: - case TypeCode.Int32: - case TypeCode.Int64: - case TypeCode.Int16: - case TypeCode.Single: - case TypeCode.UInt32: - case TypeCode.UInt64: - case TypeCode.Decimal: - Output.Write(Convert.ToString(value, CultureInfo.InvariantCulture)); - return true; - - case TypeCode.Double: - ValueDouble((double)value); - return true; - - case TypeCode.DateTime: - ValueDate((DateTime)value); - return true; - - case TypeCode.String: - if (typeNameHint?.IndexOf('[') > 0) - { - // '{{"meeting", "lunch"}, {"meeting"}}' - ValueString((string)value, '"'); - } - else - { - ValueString((string)value); - } + public override ExportTable ReadSchemaTable(DataTable metadata, string tableName) + { + var result = new ExportTable { Name = tableName }; - return true; - } + const string GeneratedName = "GeneratedName"; + var generatedIndex = 0; - if (value is Guid id) + var rows = metadata.Rows.Cast().OrderBy(i => (int)i["ColumnOrdinal"]); + foreach (var row in rows) + { + var name = (string)row["ColumnName"]; + if (string.IsNullOrWhiteSpace(name)) { - ValueGuid(id); - return true; + generatedIndex++; + name = GeneratedName + generatedIndex; } - if (value is byte[] byteArray) - { - ValueByteArray(byteArray); - return true; - } + var typeName = (string)row["DataTypeName"]; + var size = (int)row["ColumnSize"]; - if (value is TimeSpan timeSpan) + result.Columns.Add(new ExportTableColumn { - ValueTimeSpan(timeSpan); + Name = name, + SqlDataTypeName = typeName, + Size = size, + NumericPrecision = (int?)DataReaderTools.CleanValue(row["NumericPrecision"]), + NumericScale = (int?)DataReaderTools.CleanValue(row["NumericScale"]), + AllowNull = (bool?)DataReaderTools.CleanValue(row["AllowDBNull"]) ?? true + }); + } + + return result; + } + + public override string GetDefaultTableName() => "public.sqldatabase_export"; + + protected override bool TryWriteValue(object value, string typeNameHint) + { + var type = value.GetType(); + + switch (Type.GetTypeCode(type)) + { + case TypeCode.Boolean: + if (string.Equals(typeNameHint, "bit", StringComparison.OrdinalIgnoreCase)) + { + Output.Write('B'); + Output.Write(Q); + Output.Write((bool)value ? "1" : "0"); + Output.Write(Q); + } + else + { + Output.Write((bool)value ? "true" : "false"); + } + return true; - } - if (value is BitArray bitArray) - { - ValueBitArray(bitArray); + case TypeCode.Char: + break; + case TypeCode.SByte: + case TypeCode.UInt16: + case TypeCode.Byte: + case TypeCode.Int32: + case TypeCode.Int64: + case TypeCode.Int16: + case TypeCode.Single: + case TypeCode.UInt32: + case TypeCode.UInt64: + case TypeCode.Decimal: + Output.Write(Convert.ToString(value, CultureInfo.InvariantCulture)); return true; - } - if (value is NpgsqlTsVector vector) - { - ValueTsVector(vector); + case TypeCode.Double: + ValueDouble((double)value); return true; - } - if (value is NpgsqlTsQuery query) - { - ValueTsQuery(query); + case TypeCode.DateTime: + ValueDate((DateTime)value); return true; - } - if (value is Array array) - { - if (array.Rank == 1) + case TypeCode.String: + if (typeNameHint?.IndexOf('[') > 0) { - Value1dArray(array, typeNameHint); - return true; + // '{{"meeting", "lunch"}, {"meeting"}}' + ValueString((string)value, '"'); } - - if (array.Rank == 2) + else { - Value2dArray(array, typeNameHint); - return true; + ValueString((string)value); } - throw new NotSupportedException("{0}d array is not supported.".FormatWith(array.Rank)); - } - - if (value is ExpandoObject composite) - { - ValueComposite(composite); return true; - } + } - if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(NpgsqlRange<>)) - { - GetType() - .GetMethod(nameof(ValueRange), BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly) - .MakeGenericMethod(type.GenericTypeArguments) - .Invoke(this, new[] { value }); - return true; - } + if (value is Guid id) + { + ValueGuid(id); + return true; + } - return false; + if (value is byte[] byteArray) + { + ValueByteArray(byteArray); + return true; } - private void ValueDate(DateTime value) + if (value is TimeSpan timeSpan) { - Output.Write(Q); - Output.Write(value.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture)); - Output.Write(Q); + ValueTimeSpan(timeSpan); + return true; } - private void ValueGuid(Guid value) + if (value is BitArray bitArray) { - Output.Write(Q); - Output.Write(value); - Output.Write(Q); + ValueBitArray(bitArray); + return true; } - private void ValueByteArray(byte[] value) + if (value is NpgsqlTsVector vector) { - var buff = new StringBuilder((value.Length * 2) + 4); - buff.Append(Q).Append("\\x"); - for (var i = 0; i < value.Length; i++) - { - buff.AppendFormat(CultureInfo.InvariantCulture, "{0:x2}", value[i]); - } + ValueTsVector(vector); + return true; + } - buff.Append(Q); - Output.Write(buff.ToString()); + if (value is NpgsqlTsQuery query) + { + ValueTsQuery(query); + return true; } - private void ValueBitArray(BitArray value) + if (value is Array array) { - var buff = new StringBuilder((value.Length * 2) + 4); - buff.Append('B').Append(Q); - for (var i = 0; i < value.Length; i++) + if (array.Rank == 1) + { + Value1dArray(array, typeNameHint); + return true; + } + + if (array.Rank == 2) { - buff.Append(value[i] ? '1' : '0'); + Value2dArray(array, typeNameHint); + return true; } - buff.Append(Q); - Output.Write(buff.ToString()); + throw new NotSupportedException("{0}d array is not supported.".FormatWith(array.Rank)); } - private void ValueDouble(double value) + if (value is ExpandoObject composite) { - Output.Write(value.ToString("G17", CultureInfo.InvariantCulture)); + ValueComposite(composite); + return true; } - private void ValueTimeSpan(TimeSpan value) + if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(NpgsqlRange<>)) { - Output.Write(Q); + GetType() + .GetMethod(nameof(ValueRange), BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly) + .MakeGenericMethod(type.GenericTypeArguments) + .Invoke(this, new[] { value }); + return true; + } - if (value.Days > 0) - { - Output.Write(value.Days.ToString(CultureInfo.InvariantCulture)); - Output.Write(" "); - value = value.Add(-TimeSpan.FromDays(value.Days)); - } + return false; + } + + private void ValueDate(DateTime value) + { + Output.Write(Q); + Output.Write(value.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture)); + Output.Write(Q); + } + + private void ValueGuid(Guid value) + { + Output.Write(Q); + Output.Write(value); + Output.Write(Q); + } + + private void ValueByteArray(byte[] value) + { + var buff = new StringBuilder((value.Length * 2) + 4); + buff.Append(Q).Append("\\x"); + for (var i = 0; i < value.Length; i++) + { + buff.AppendFormat(CultureInfo.InvariantCulture, "{0:x2}", value[i]); + } + + buff.Append(Q); + Output.Write(buff.ToString()); + } - Output.Write(value.ToString("g", CultureInfo.InvariantCulture)); - Output.Write(Q); + private void ValueBitArray(BitArray value) + { + var buff = new StringBuilder((value.Length * 2) + 4); + buff.Append('B').Append(Q); + for (var i = 0; i < value.Length; i++) + { + buff.Append(value[i] ? '1' : '0'); } - private void ValueTsVector(NpgsqlTsVector value) + buff.Append(Q); + Output.Write(buff.ToString()); + } + + private void ValueDouble(double value) + { + Output.Write(value.ToString("G17", CultureInfo.InvariantCulture)); + } + + private void ValueTimeSpan(TimeSpan value) + { + Output.Write(Q); + + if (value.Days > 0) { - Output.Write(Q); - for (var i = 0; i < value.Count; i++) + Output.Write(value.Days.ToString(CultureInfo.InvariantCulture)); + Output.Write(" "); + value = value.Add(-TimeSpan.FromDays(value.Days)); + } + + Output.Write(value.ToString("g", CultureInfo.InvariantCulture)); + Output.Write(Q); + } + + private void ValueTsVector(NpgsqlTsVector value) + { + Output.Write(Q); + for (var i = 0; i < value.Count; i++) + { + if (i > 0) { - if (i > 0) - { - Output.Write(' '); - } + Output.Write(' '); + } - var lexeme = value[i]; - WriteEscapedString(lexeme.Text); + var lexeme = value[i]; + WriteEscapedString(lexeme.Text); - if (lexeme.Count > 0) + if (lexeme.Count > 0) + { + Output.Write(':'); + for (var j = 0; j < lexeme.Count; j++) { - Output.Write(':'); - for (var j = 0; j < lexeme.Count; j++) + if (j > 0) { - if (j > 0) - { - Output.Write(','); - } - - Output.Write(lexeme[j].ToString()); + Output.Write(','); } + + Output.Write(lexeme[j].ToString()); } } - - Output.Write(Q); } - private void ValueTsQuery(NpgsqlTsQuery value) + Output.Write(Q); + } + + private void ValueTsQuery(NpgsqlTsQuery value) + { + var valueByLexeme = new Dictionary(); + CollectLexeme(value, valueByLexeme); + + var text = new StringBuilder(value.ToString()); + foreach (var entry in valueByLexeme.Values) { - var valueByLexeme = new Dictionary(); - CollectLexeme(value, valueByLexeme); + text.Replace(entry.Name, entry.Original); + } + + Output.Write(Q); + WriteEscapedString(text.ToString()); + Output.Write(Q); + } - var text = new StringBuilder(value.ToString()); - foreach (var entry in valueByLexeme.Values) + private void CollectLexeme(NpgsqlTsQuery value, IDictionary valueByLexeme) + { + if (value is NpgsqlTsQueryLexeme lexeme) + { + if (!valueByLexeme.ContainsKey(lexeme)) { - text.Replace(entry.Name, entry.Original); + var name = "___sqldb___" + valueByLexeme.Count.ToString(CultureInfo.InvariantCulture); + valueByLexeme.Add(lexeme, (lexeme.Text, Q + name + Q)); + lexeme.Text = name; } - Output.Write(Q); - WriteEscapedString(text.ToString()); - Output.Write(Q); + return; } - private void CollectLexeme(NpgsqlTsQuery value, IDictionary valueByLexeme) + if (value is NpgsqlTsQueryNot not) { - if (value is NpgsqlTsQueryLexeme lexeme) + if (not.Child != null) { - if (!valueByLexeme.ContainsKey(lexeme)) - { - var name = "___sqldb___" + valueByLexeme.Count.ToString(CultureInfo.InvariantCulture); - valueByLexeme.Add(lexeme, (lexeme.Text, Q + name + Q)); - lexeme.Text = name; - } - - return; + CollectLexeme(not.Child, valueByLexeme); } - if (value is NpgsqlTsQueryNot not) - { - if (not.Child != null) - { - CollectLexeme(not.Child, valueByLexeme); - } + return; + } - return; + if (value is NpgsqlTsQueryBinOp bin) + { + if (bin.Left != null) + { + CollectLexeme(bin.Left, valueByLexeme); } - if (value is NpgsqlTsQueryBinOp bin) + if (bin.Right != null) { - if (bin.Left != null) - { - CollectLexeme(bin.Left, valueByLexeme); - } - - if (bin.Right != null) - { - CollectLexeme(bin.Right, valueByLexeme); - } + CollectLexeme(bin.Right, valueByLexeme); } } + } - private void Value1dArray(Array value, string typeNameHint) + private void Value1dArray(Array value, string typeNameHint) + { + Output.Write(Q); + Output.Write('{'); + for (var i = 0; i < value.Length; i++) { - Output.Write(Q); - Output.Write('{'); - for (var i = 0; i < value.Length; i++) + if (i > 0) { - if (i > 0) - { - Output.Write(", "); - } - - Value(value.GetValue(i), typeNameHint); + Output.Write(", "); } - Output.Write('}'); - Output.Write(Q); + Value(value.GetValue(i), typeNameHint); } - private void Value2dArray(Array value, string typeNameHint) + Output.Write('}'); + Output.Write(Q); + } + + private void Value2dArray(Array value, string typeNameHint) + { + Output.Write(Q); + Output.Write('{'); + + if (value.Length > 0) { - Output.Write(Q); - Output.Write('{'); + var length1 = value.GetLength(0); + var length2 = value.GetLength(1); - if (value.Length > 0) + for (var i1 = 0; i1 < length1; i1++) { - var length1 = value.GetLength(0); - var length2 = value.GetLength(1); + if (i1 > 0) + { + Output.Write(", "); + } - for (var i1 = 0; i1 < length1; i1++) + Output.Write('{'); + for (var i2 = 0; i2 < length2; i2++) { - if (i1 > 0) + if (i2 > 0) { Output.Write(", "); } - Output.Write('{'); - for (var i2 = 0; i2 < length2; i2++) - { - if (i2 > 0) - { - Output.Write(", "); - } - - Value(value.GetValue(i1, i2), typeNameHint); - } - - Output.Write('}'); + Value(value.GetValue(i1, i2), typeNameHint); } - } - Output.Write('}'); - Output.Write(Q); + Output.Write('}'); + } } - private void ValueComposite(IDictionary value) - { - Output.Write("ROW("); + Output.Write('}'); + Output.Write(Q); + } - var index = 0; - foreach (var entry in value.Values) - { - if (index > 0) - { - Output.Write(", "); - } + private void ValueComposite(IDictionary value) + { + Output.Write("ROW("); - Value(entry); - index++; + var index = 0; + foreach (var entry in value.Values) + { + if (index > 0) + { + Output.Write(", "); } - Output.Write(')'); + Value(entry); + index++; } - private void ValueRange(NpgsqlRange value) - { - Output.Write(Q); + Output.Write(')'); + } - if (value.IsEmpty) + private void ValueRange(NpgsqlRange value) + { + Output.Write(Q); + + if (value.IsEmpty) + { + Output.Write("empty"); + } + else + { + Output.Write(value.LowerBoundIsInclusive ? '[' : '('); + if (!value.LowerBoundInfinite) { - Output.Write("empty"); + Value(value.LowerBound); } - else - { - Output.Write(value.LowerBoundIsInclusive ? '[' : '('); - if (!value.LowerBoundInfinite) - { - Value(value.LowerBound); - } - - Output.Write(','); - if (!value.UpperBoundInfinite) - { - Value(value.UpperBound); - } - Output.Write(value.UpperBoundIsInclusive ? ']' : ')'); + Output.Write(','); + if (!value.UpperBoundInfinite) + { + Value(value.UpperBound); } - Output.Write(Q); + Output.Write(value.UpperBoundIsInclusive ? ']' : ')'); } + + Output.Write(Q); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/PowerShellInternal/DiagnosticsTools.cs b/Sources/SqlDatabase/Scripts/PowerShellInternal/DiagnosticsTools.cs index 6d06a5b4..dac673bc 100644 --- a/Sources/SqlDatabase/Scripts/PowerShellInternal/DiagnosticsTools.cs +++ b/Sources/SqlDatabase/Scripts/PowerShellInternal/DiagnosticsTools.cs @@ -3,134 +3,133 @@ using System.IO; using System.Runtime.InteropServices; -namespace SqlDatabase.Scripts.PowerShellInternal +namespace SqlDatabase.Scripts.PowerShellInternal; + +internal static class DiagnosticsTools { - internal static class DiagnosticsTools + public static bool IsOSPlatformWindows() { - public static bool IsOSPlatformWindows() - { #if NET452 return true; #else - return RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + return RuntimeInformation.IsOSPlatform(OSPlatform.Windows); #endif - } + } - public static int? GetParentProcessId(int processId) - { + public static int? GetParentProcessId(int processId) + { #if NET452 return null; #else - return IsOSPlatformWindows() ? GetParentProcessIdWindows(processId) : GetParentProcessIdLinux(processId); + return IsOSPlatformWindows() ? GetParentProcessIdWindows(processId) : GetParentProcessIdLinux(processId); #endif - } - - internal static int? ParseParentProcessIdLinux(string fileName) - { - string line = null; - - try - { - using (var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read)) - using (var reader = new StreamReader(stream, detectEncodingFromByteOrderMarks: true)) - { - line = reader.ReadLine(); - } - } - catch - { - } - - if (string.IsNullOrWhiteSpace(line)) - { - return null; - } - - // (2) comm %s: The filename of the executable, in parentheses. - var startIndex = line.LastIndexOf(')'); - if (startIndex <= 0 || startIndex >= line.Length) - { - return null; - } + } - // (3) state %c - startIndex = line.IndexOf(' ', startIndex + 1); - if (startIndex <= 0 || startIndex >= line.Length) - { - return null; - } + internal static int? ParseParentProcessIdLinux(string fileName) + { + string line = null; - // (4) ppid %d: The PID of the parent of this process. - startIndex = line.IndexOf(' ', startIndex + 1); - if (startIndex <= 0 || startIndex >= line.Length) + try + { + using (var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read)) + using (var reader = new StreamReader(stream, detectEncodingFromByteOrderMarks: true)) { - return null; + line = reader.ReadLine(); } + } + catch + { + } - var endIndex = line.IndexOf(' ', startIndex + 1); - if (endIndex <= startIndex) - { - return null; - } + if (string.IsNullOrWhiteSpace(line)) + { + return null; + } - var ppid = line.Substring(startIndex + 1, endIndex - startIndex - 1); - if (int.TryParse(ppid, NumberStyles.Any, CultureInfo.InvariantCulture, out var result)) - { - return result; - } + // (2) comm %s: The filename of the executable, in parentheses. + var startIndex = line.LastIndexOf(')'); + if (startIndex <= 0 || startIndex >= line.Length) + { + return null; + } + // (3) state %c + startIndex = line.IndexOf(' ', startIndex + 1); + if (startIndex <= 0 || startIndex >= line.Length) + { return null; } -#if !NET452 - private static int? GetParentProcessIdLinux(int processId) + // (4) ppid %d: The PID of the parent of this process. + startIndex = line.IndexOf(' ', startIndex + 1); + if (startIndex <= 0 || startIndex >= line.Length) { - // /proc/[pid]/stat https://man7.org/linux/man-pages/man5/procfs.5.html - var fileName = "/proc/" + processId.ToString(CultureInfo.InvariantCulture) + "/stat"; + return null; + } - return ParseParentProcessIdLinux(fileName); + var endIndex = line.IndexOf(' ', startIndex + 1); + if (endIndex <= startIndex) + { + return null; } - private static int? GetParentProcessIdWindows(int processId) + var ppid = line.Substring(startIndex + 1, endIndex - startIndex - 1); + if (int.TryParse(ppid, NumberStyles.Any, CultureInfo.InvariantCulture, out var result)) { - const int DesiredAccess = 0x0400; // PROCESS_QUERY_INFORMATION - const int ProcessInfoClass = 0; // ProcessBasicInformation + return result; + } + + return null; + } + +#if !NET452 + private static int? GetParentProcessIdLinux(int processId) + { + // /proc/[pid]/stat https://man7.org/linux/man-pages/man5/procfs.5.html + var fileName = "/proc/" + processId.ToString(CultureInfo.InvariantCulture) + "/stat"; - int? result = null; - using (var hProcess = OpenProcess(DesiredAccess, false, processId)) + return ParseParentProcessIdLinux(fileName); + } + + private static int? GetParentProcessIdWindows(int processId) + { + const int DesiredAccess = 0x0400; // PROCESS_QUERY_INFORMATION + const int ProcessInfoClass = 0; // ProcessBasicInformation + + int? result = null; + using (var hProcess = OpenProcess(DesiredAccess, false, processId)) + { + if (!hProcess.IsInvalid) { - if (!hProcess.IsInvalid) + var basicInformation = default(ProcessBasicInformation); + var pSize = 0; + var pbiSize = (uint)Marshal.SizeOf(); + + if (NtQueryInformationProcess(hProcess, ProcessInfoClass, ref basicInformation, pbiSize, ref pSize) == 0) { - var basicInformation = default(ProcessBasicInformation); - var pSize = 0; - var pbiSize = (uint)Marshal.SizeOf(); - - if (NtQueryInformationProcess(hProcess, ProcessInfoClass, ref basicInformation, pbiSize, ref pSize) == 0) - { - result = (int)basicInformation.InheritedFromUniqueProcessId; - } + result = (int)basicInformation.InheritedFromUniqueProcessId; } } - - return result; } - [DllImport("kernel32.dll", SetLastError = true)] - private static extern Microsoft.Win32.SafeHandles.SafeProcessHandle OpenProcess(int dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, int dwProcessId); + return result; + } - [DllImport("ntdll.dll")] - private static extern int NtQueryInformationProcess(Microsoft.Win32.SafeHandles.SafeProcessHandle hProcess, int pic, ref ProcessBasicInformation pbi, uint cb, ref int pSize); + [DllImport("kernel32.dll", SetLastError = true)] + private static extern Microsoft.Win32.SafeHandles.SafeProcessHandle OpenProcess(int dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, int dwProcessId); - [StructLayout(LayoutKind.Sequential)] - private struct ProcessBasicInformation - { - public uint ExitStatus; - public IntPtr PebBaseAddress; - public UIntPtr AffinityMask; - public int BasePriority; - public UIntPtr UniqueProcessId; - public UIntPtr InheritedFromUniqueProcessId; - } -#endif + [DllImport("ntdll.dll")] + private static extern int NtQueryInformationProcess(Microsoft.Win32.SafeHandles.SafeProcessHandle hProcess, int pic, ref ProcessBasicInformation pbi, uint cb, ref int pSize); + + [StructLayout(LayoutKind.Sequential)] + private struct ProcessBasicInformation + { + public uint ExitStatus; + public IntPtr PebBaseAddress; + public UIntPtr AffinityMask; + public int BasePriority; + public UIntPtr UniqueProcessId; + public UIntPtr InheritedFromUniqueProcessId; } -} +#endif +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/PowerShellInternal/IPowerShell.cs b/Sources/SqlDatabase/Scripts/PowerShellInternal/IPowerShell.cs index 897c238b..4de3ab45 100644 --- a/Sources/SqlDatabase/Scripts/PowerShellInternal/IPowerShell.cs +++ b/Sources/SqlDatabase/Scripts/PowerShellInternal/IPowerShell.cs @@ -1,11 +1,10 @@ using System.Collections.Generic; -namespace SqlDatabase.Scripts.PowerShellInternal +namespace SqlDatabase.Scripts.PowerShellInternal; + +internal interface IPowerShell { - internal interface IPowerShell - { - bool SupportsShouldProcess(string script); + bool SupportsShouldProcess(string script); - void Invoke(string script, ILogger logger, params KeyValuePair[] parameters); - } -} + void Invoke(string script, ILogger logger, params KeyValuePair[] parameters); +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/PowerShellInternal/InstallationSeeker.cs b/Sources/SqlDatabase/Scripts/PowerShellInternal/InstallationSeeker.cs index f0f25193..65792f8b 100644 --- a/Sources/SqlDatabase/Scripts/PowerShellInternal/InstallationSeeker.cs +++ b/Sources/SqlDatabase/Scripts/PowerShellInternal/InstallationSeeker.cs @@ -3,193 +3,194 @@ using System.Diagnostics; using System.IO; -namespace SqlDatabase.Scripts.PowerShellInternal +namespace SqlDatabase.Scripts.PowerShellInternal; + +internal static class InstallationSeeker { - internal static class InstallationSeeker - { - public const string RootAssemblyName = "System.Management.Automation"; - public const string RootAssemblyFileName = RootAssemblyName + ".dll"; + public const string RootAssemblyName = "System.Management.Automation"; + public const string RootAssemblyFileName = RootAssemblyName + ".dll"; - public static bool TryFindByParentProcess(out string installationPath) + public static bool TryFindByParentProcess(out string installationPath) + { + int processId; + DateTime processStartTime; + using (var current = Process.GetCurrentProcess()) { - int processId; - DateTime processStartTime; - using (var current = Process.GetCurrentProcess()) - { - processId = current.Id; - processStartTime = current.StartTime; - } + processId = current.Id; + processStartTime = current.StartTime; + } - installationPath = FindPowerShellProcess(processId, processStartTime); - return !string.IsNullOrEmpty(installationPath) - && TryGetInfo(installationPath, out var info) - && IsCompatibleVersion(info.Version); + installationPath = FindPowerShellProcess(processId, processStartTime); + return !string.IsNullOrEmpty(installationPath) + && TryGetInfo(installationPath, out var info) + && IsCompatibleVersion(info.Version); + } + + public static bool TryFindOnDisk(out string installationPath) + { + installationPath = null; + var root = GetDefaultInstallationRoot(); + if (!Directory.Exists(root)) + { + return false; } - public static bool TryFindOnDisk(out string installationPath) + var candidates = new List(); + + var directories = Directory.GetDirectories(root); + for (var i = 0; i < directories.Length; i++) { - installationPath = null; - var root = GetDefaultInstallationRoot(); - if (!Directory.Exists(root)) + if (TryGetInfo(directories[i], out var info) + && IsCompatibleVersion(info.Version)) { - return false; + candidates.Add(info); } + } - var candidates = new List(); + if (candidates.Count == 0) + { + return false; + } - var directories = Directory.GetDirectories(root); - for (var i = 0; i < directories.Length; i++) - { - if (TryGetInfo(directories[i], out var info) - && IsCompatibleVersion(info.Version)) - { - candidates.Add(info); - } - } + candidates.Sort(); + installationPath = candidates[candidates.Count - 1].Location; + return true; + } - if (candidates.Count == 0) - { - return false; - } + public static bool TryGetInfo(string installationPath, out InstallationInfo info) + { + info = default; - candidates.Sort(); - installationPath = candidates[candidates.Count - 1].Location; - return true; + var root = Path.Combine(installationPath, RootAssemblyFileName); + if (!File.Exists(Path.Combine(installationPath, "pwsh.dll")) + || !File.Exists(root)) + { + return false; } - public static bool TryGetInfo(string installationPath, out InstallationInfo info) + var fileInfo = FileVersionInfo.GetVersionInfo(root); + if (string.IsNullOrEmpty(fileInfo.FileVersion) + || string.IsNullOrEmpty(fileInfo.ProductVersion) + || !Version.TryParse(fileInfo.FileVersion, out var version)) { - info = default; - - var root = Path.Combine(installationPath, RootAssemblyFileName); - if (!File.Exists(Path.Combine(installationPath, "pwsh.dll")) - || !File.Exists(root)) - { - return false; - } + return false; + } - var fileInfo = FileVersionInfo.GetVersionInfo(root); - if (string.IsNullOrEmpty(fileInfo.FileVersion) - || string.IsNullOrEmpty(fileInfo.ProductVersion) - || !Version.TryParse(fileInfo.FileVersion, out var version)) - { - return false; - } + info = new InstallationInfo(installationPath, version, fileInfo.ProductVersion); + return true; + } - info = new InstallationInfo(installationPath, version, fileInfo.ProductVersion); - return true; + private static string FindPowerShellProcess(int processId, DateTime processStartTime) + { + var parentId = DiagnosticsTools.GetParentProcessId(processId); + if (!parentId.HasValue || parentId == processId) + { + return null; } - private static string FindPowerShellProcess(int processId, DateTime processStartTime) + string parentLocation = null; + try { - var parentId = DiagnosticsTools.GetParentProcessId(processId); - if (!parentId.HasValue || parentId == processId) - { - return null; - } - - string parentLocation = null; - try + using (var parent = Process.GetProcessById(parentId.Value)) { - using (var parent = Process.GetProcessById(parentId.Value)) + if (parent.StartTime < processStartTime) { - if (parent.StartTime < processStartTime) - { - parentLocation = parent.MainModule?.FileName; - } + parentLocation = parent.MainModule?.FileName; } } - catch - { - } - - if (string.IsNullOrWhiteSpace(parentLocation) || !File.Exists(parentLocation)) - { - return null; - } - - var fileName = Path.GetFileName(parentLocation); - if (!"pwsh.exe".Equals(fileName, StringComparison.OrdinalIgnoreCase) && !"pwsh".Equals(fileName, StringComparison.OrdinalIgnoreCase)) - { - // try parent - return FindPowerShellProcess(parentId.Value, processStartTime); - } - - return Path.GetDirectoryName(parentLocation); + } + catch + { } - private static string GetDefaultInstallationRoot() + if (string.IsNullOrWhiteSpace(parentLocation) || !File.Exists(parentLocation)) { - if (DiagnosticsTools.IsOSPlatformWindows()) - { - return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "PowerShell"); - } + return null; + } - return "/opt/microsoft/powershell"; + var fileName = Path.GetFileName(parentLocation); + if (!"pwsh.exe".Equals(fileName, StringComparison.OrdinalIgnoreCase) && !"pwsh".Equals(fileName, StringComparison.OrdinalIgnoreCase)) + { + // try parent + return FindPowerShellProcess(parentId.Value, processStartTime); } - private static bool IsCompatibleVersion(Version version) + return Path.GetDirectoryName(parentLocation); + } + + private static string GetDefaultInstallationRoot() + { + if (DiagnosticsTools.IsOSPlatformWindows()) { -#if NET6_0 - return version < new Version("7.3.1"); + return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "PowerShell"); + } + + return "/opt/microsoft/powershell"; + } + + private static bool IsCompatibleVersion(Version version) + { +#if NET7_0 + return version < new Version("7.4"); +#elif NET6_0 + return version < new Version("7.3"); #elif NET5_0 - return version < new Version("7.2"); + return version < new Version("7.2"); #elif NETCOREAPP3_1_OR_GREATER - return version < new Version("7.1"); + return version < new Version("7.1"); #else - return false; + return false; #endif - } + } - [DebuggerDisplay("{Version}")] - internal readonly struct InstallationInfo : IComparable + [DebuggerDisplay("{Version}")] + internal readonly struct InstallationInfo : IComparable + { + public InstallationInfo(string location, Version version, string productVersion) { - public InstallationInfo(string location, Version version, string productVersion) - { - Location = location; - Version = version; - ProductVersion = productVersion ?? string.Empty; - } + Location = location; + Version = version; + ProductVersion = productVersion ?? string.Empty; + } - public string Location { get; } + public string Location { get; } - public Version Version { get; } + public Version Version { get; } - public string ProductVersion { get; } + public string ProductVersion { get; } - public int CompareTo(InstallationInfo other) + public int CompareTo(InstallationInfo other) + { + var result = Version.CompareTo(other.Version); + if (result != 0) { - var result = Version.CompareTo(other.Version); - if (result != 0) - { - return result; - } - - var isPreview = IsPreview(); - var otherIsPreview = other.IsPreview(); - if (isPreview && !otherIsPreview) - { - return -1; - } - - if (!isPreview && otherIsPreview) - { - return 1; - } + return result; + } - result = StringComparer.InvariantCultureIgnoreCase.Compare(ProductVersion, other.ProductVersion); - if (result == 0) - { - result = StringComparer.InvariantCultureIgnoreCase.Compare(Location, other.Location); - } + var isPreview = IsPreview(); + var otherIsPreview = other.IsPreview(); + if (isPreview && !otherIsPreview) + { + return -1; + } - return result; + if (!isPreview && otherIsPreview) + { + return 1; } - private bool IsPreview() + result = StringComparer.InvariantCultureIgnoreCase.Compare(ProductVersion, other.ProductVersion); + if (result == 0) { - return ProductVersion.IndexOf("preview", StringComparison.OrdinalIgnoreCase) > 0; + result = StringComparer.InvariantCultureIgnoreCase.Compare(Location, other.Location); } + + return result; + } + + private bool IsPreview() + { + return ProductVersion.IndexOf("preview", StringComparison.OrdinalIgnoreCase) > 0; } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/PowerShellInternal/PowerShell.cs b/Sources/SqlDatabase/Scripts/PowerShellInternal/PowerShell.cs index bf17a3a6..0c00d4e0 100644 --- a/Sources/SqlDatabase/Scripts/PowerShellInternal/PowerShell.cs +++ b/Sources/SqlDatabase/Scripts/PowerShellInternal/PowerShell.cs @@ -3,59 +3,58 @@ using System.Management.Automation; using System.Management.Automation.Runspaces; -namespace SqlDatabase.Scripts.PowerShellInternal +namespace SqlDatabase.Scripts.PowerShellInternal; + +internal sealed class PowerShell : IPowerShell { - internal sealed class PowerShell : IPowerShell + public bool SupportsShouldProcess(string script) { - public bool SupportsShouldProcess(string script) + var attributes = ScriptBlock.Create(script).Attributes; + for (var i = 0; i < attributes.Count; i++) { - var attributes = ScriptBlock.Create(script).Attributes; - for (var i = 0; i < attributes.Count; i++) + if (attributes[i] is CmdletBindingAttribute binding) { - if (attributes[i] is CmdletBindingAttribute binding) - { - return binding.SupportsShouldProcess; - } + return binding.SupportsShouldProcess; } - - return false; } - public void Invoke(string script, ILogger logger, params KeyValuePair[] parameters) + return false; + } + + public void Invoke(string script, ILogger logger, params KeyValuePair[] parameters) + { + var sessionState = InitialSessionState.CreateDefault(); + using (var runSpace = RunspaceFactory.CreateRunspace(sessionState)) { - var sessionState = InitialSessionState.CreateDefault(); - using (var runSpace = RunspaceFactory.CreateRunspace(sessionState)) + runSpace.ThreadOptions = PSThreadOptions.UseCurrentThread; + runSpace.Open(); + + using (var powerShell = System.Management.Automation.PowerShell.Create()) + using (var listener = new PowerShellStreamsListener(powerShell.Streams, logger)) { - runSpace.ThreadOptions = PSThreadOptions.UseCurrentThread; - runSpace.Open(); + powerShell.Runspace = runSpace; - using (var powerShell = System.Management.Automation.PowerShell.Create()) - using (var listener = new PowerShellStreamsListener(powerShell.Streams, logger)) + var ps = powerShell.AddScript(script); + for (var i = 0; i < parameters.Length; i++) { - powerShell.Runspace = runSpace; - - var ps = powerShell.AddScript(script); - for (var i = 0; i < parameters.Length; i++) + var p = parameters[i]; + if (p.Value == null) { - var p = parameters[i]; - if (p.Value == null) - { - ps = ps.AddParameter(p.Key); - } - else - { - ps.AddParameter(p.Key, p.Value); - } + ps = ps.AddParameter(p.Key); } - - ps.Invoke(); - - if (listener.HasErrors) + else { - throw new InvalidOperationException("Errors during script execution."); + ps.AddParameter(p.Key, p.Value); } } + + ps.Invoke(); + + if (listener.HasErrors) + { + throw new InvalidOperationException("Errors during script execution."); + } } } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/PowerShellInternal/PowerShellFactory.cs b/Sources/SqlDatabase/Scripts/PowerShellInternal/PowerShellFactory.cs index 5a96be36..eb39a55e 100644 --- a/Sources/SqlDatabase/Scripts/PowerShellInternal/PowerShellFactory.cs +++ b/Sources/SqlDatabase/Scripts/PowerShellInternal/PowerShellFactory.cs @@ -1,58 +1,57 @@ using System; -namespace SqlDatabase.Scripts.PowerShellInternal +namespace SqlDatabase.Scripts.PowerShellInternal; + +internal sealed partial class PowerShellFactory : IPowerShellFactory { - internal sealed partial class PowerShellFactory : IPowerShellFactory - { - private bool _requested; - private bool _initialized; + private bool _requested; + private bool _initialized; - private PowerShellFactory(string installationPath) - { - InstallationPath = installationPath; - } + private PowerShellFactory(string installationPath) + { + InstallationPath = installationPath; + } - public string InstallationPath { get; private set; } + public string InstallationPath { get; private set; } - // only for tests - internal static IPowerShellFactory SharedTestFactory { get; set; } + // only for tests + internal static IPowerShellFactory SharedTestFactory { get; set; } - public static IPowerShellFactory Create(string installationPath) + public static IPowerShellFactory Create(string installationPath) + { + if (SharedTestFactory != null) { - if (SharedTestFactory != null) - { - return SharedTestFactory; - } - - return new PowerShellFactory(installationPath); + return SharedTestFactory; } - public void Request() - { - _requested = true; - } + return new PowerShellFactory(installationPath); + } - public void InitializeIfRequested(ILogger logger) - { - if (_initialized || !_requested) - { - return; - } + public void Request() + { + _requested = true; + } - _initialized = true; - DoInitialize(logger); + public void InitializeIfRequested(ILogger logger) + { + if (_initialized || !_requested) + { + return; } - public IPowerShell Create() - { - if (!_initialized) - { - throw new InvalidOperationException("PowerShell host is not initialized."); - } + _initialized = true; + DoInitialize(logger); + } - return new PowerShell(); + public IPowerShell Create() + { + if (!_initialized) + { + throw new InvalidOperationException("PowerShell host is not initialized."); } - partial void DoInitialize(ILogger logger); + return new PowerShell(); } -} + + partial void DoInitialize(ILogger logger); +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/PowerShellInternal/PowerShellStreamsListener.cs b/Sources/SqlDatabase/Scripts/PowerShellInternal/PowerShellStreamsListener.cs index eebaa85a..1024b823 100644 --- a/Sources/SqlDatabase/Scripts/PowerShellInternal/PowerShellStreamsListener.cs +++ b/Sources/SqlDatabase/Scripts/PowerShellInternal/PowerShellStreamsListener.cs @@ -2,89 +2,88 @@ using System.Collections; using System.Management.Automation; -namespace SqlDatabase.Scripts.PowerShellInternal +namespace SqlDatabase.Scripts.PowerShellInternal; + +internal sealed class PowerShellStreamsListener : IDisposable { - internal sealed class PowerShellStreamsListener : IDisposable - { - private readonly PSDataStreams _streams; - private readonly ILogger _logger; - private readonly IList _information; + private readonly PSDataStreams _streams; + private readonly ILogger _logger; + private readonly IList _information; - public PowerShellStreamsListener(PSDataStreams streams, ILogger logger) - { - _streams = streams; - _logger = logger; + public PowerShellStreamsListener(PSDataStreams streams, ILogger logger) + { + _streams = streams; + _logger = logger; - _information = GetInformation(streams); + _information = GetInformation(streams); - InvokeDataAdded(_information, OnInformation, true); - streams.Verbose.DataAdded += OnVerbose; - streams.Error.DataAdded += OnError; - streams.Warning.DataAdded += OnWarning; - } + InvokeDataAdded(_information, OnInformation, true); + streams.Verbose.DataAdded += OnVerbose; + streams.Error.DataAdded += OnError; + streams.Warning.DataAdded += OnWarning; + } - public bool HasErrors { get; private set; } + public bool HasErrors { get; private set; } - public void Dispose() - { - _streams.Verbose.DataAdded -= OnVerbose; - _streams.Error.DataAdded -= OnError; - _streams.Warning.DataAdded -= OnWarning; - InvokeDataAdded(_information, OnInformation, false); - } + public void Dispose() + { + _streams.Verbose.DataAdded -= OnVerbose; + _streams.Error.DataAdded -= OnError; + _streams.Warning.DataAdded -= OnWarning; + InvokeDataAdded(_information, OnInformation, false); + } - private static IList GetInformation(PSDataStreams streams) - { + private static IList GetInformation(PSDataStreams streams) + { #if !NET452 - return streams.Information; + return streams.Information; #else return ReflectionGetInformation(streams); #endif - } - - private static IList ReflectionGetInformation(PSDataStreams streams) - { - return (IList)streams - .GetType() - .FindProperty("Information") - .GetValue(streams, null); - } + } - private static void InvokeDataAdded(object dataCollection, EventHandler handler, bool subscribe) - { - var evt = dataCollection - .GetType() - .FindEvent("DataAdded"); + private static IList ReflectionGetInformation(PSDataStreams streams) + { + return (IList)streams + .GetType() + .FindProperty("Information") + .GetValue(streams, null); + } - if (subscribe) - { - evt.AddMethod.Invoke(dataCollection, new object[] { handler }); - } - else - { - evt.RemoveMethod.Invoke(dataCollection, new object[] { handler }); - } - } + private static void InvokeDataAdded(object dataCollection, EventHandler handler, bool subscribe) + { + var evt = dataCollection + .GetType() + .FindEvent("DataAdded"); - private void OnWarning(object sender, DataAddedEventArgs e) + if (subscribe) { - _logger.Info(_streams.Warning[e.Index]?.ToString()); + evt.AddMethod.Invoke(dataCollection, new object[] { handler }); } - - private void OnError(object sender, DataAddedEventArgs e) + else { - HasErrors = true; - _logger.Error(_streams.Error[e.Index]?.ToString()); + evt.RemoveMethod.Invoke(dataCollection, new object[] { handler }); } + } - private void OnVerbose(object sender, DataAddedEventArgs e) - { - _logger.Info(_streams.Verbose[e.Index]?.ToString()); - } + private void OnWarning(object sender, DataAddedEventArgs e) + { + _logger.Info(_streams.Warning[e.Index]?.ToString()); + } - private void OnInformation(object sender, DataAddedEventArgs e) - { - _logger.Info(_information[e.Index]?.ToString()); - } + private void OnError(object sender, DataAddedEventArgs e) + { + HasErrors = true; + _logger.Error(_streams.Error[e.Index]?.ToString()); + } + + private void OnVerbose(object sender, DataAddedEventArgs e) + { + _logger.Info(_streams.Verbose[e.Index]?.ToString()); + } + + private void OnInformation(object sender, DataAddedEventArgs e) + { + _logger.Info(_information[e.Index]?.ToString()); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/PowerShellInternal/ReflectionTools.cs b/Sources/SqlDatabase/Scripts/PowerShellInternal/ReflectionTools.cs index 25da1020..49c0acbe 100644 --- a/Sources/SqlDatabase/Scripts/PowerShellInternal/ReflectionTools.cs +++ b/Sources/SqlDatabase/Scripts/PowerShellInternal/ReflectionTools.cs @@ -1,39 +1,38 @@ using System; using System.Reflection; -namespace SqlDatabase.Scripts.PowerShellInternal +namespace SqlDatabase.Scripts.PowerShellInternal; + +internal static class ReflectionTools { - internal static class ReflectionTools + public static PropertyInfo FindProperty(this Type type, string name) { - public static PropertyInfo FindProperty(this Type type, string name) + var result = type.GetProperty(name, BindingFlags.Public | BindingFlags.Instance); + if (result == null) { - var result = type.GetProperty(name, BindingFlags.Public | BindingFlags.Instance); - if (result == null) - { - throw new InvalidOperationException( - "public property {0} not found in {1}.".FormatWith( - name, - type.FullName)); - } - - return result; + throw new InvalidOperationException( + "public property {0} not found in {1}.".FormatWith( + name, + type.FullName)); } - public static EventInfo FindEvent(this Type type, string name) - { - var result = type.GetEvent(name, BindingFlags.Public | BindingFlags.Instance); - if (result?.AddMethod == null || result.RemoveMethod == null) - { - throw new InvalidOperationException("Event {0} not found in {1}.".FormatWith(name, type.FullName)); - } - - return result; - } + return result; + } - public static T CreateDelegate(this MethodInfo method) - where T : Delegate + public static EventInfo FindEvent(this Type type, string name) + { + var result = type.GetEvent(name, BindingFlags.Public | BindingFlags.Instance); + if (result?.AddMethod == null || result.RemoveMethod == null) { - return (T)method.CreateDelegate(typeof(T)); + throw new InvalidOperationException("Event {0} not found in {1}.".FormatWith(name, type.FullName)); } + + return result; + } + + public static T CreateDelegate(this MethodInfo method) + where T : Delegate + { + return (T)method.CreateDelegate(typeof(T)); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/PowerShellInternal/VariablesProxy.cs b/Sources/SqlDatabase/Scripts/PowerShellInternal/VariablesProxy.cs index 7c72b4b8..e7032814 100644 --- a/Sources/SqlDatabase/Scripts/PowerShellInternal/VariablesProxy.cs +++ b/Sources/SqlDatabase/Scripts/PowerShellInternal/VariablesProxy.cs @@ -1,20 +1,19 @@ using System.Dynamic; -namespace SqlDatabase.Scripts.PowerShellInternal +namespace SqlDatabase.Scripts.PowerShellInternal; + +internal sealed class VariablesProxy : DynamicObject { - internal sealed class VariablesProxy : DynamicObject - { - private readonly IVariables _variables; + private readonly IVariables _variables; - public VariablesProxy(IVariables variables) - { - _variables = variables; - } + public VariablesProxy(IVariables variables) + { + _variables = variables; + } - public override bool TryGetMember(GetMemberBinder binder, out object result) - { - result = _variables.GetValue(binder.Name); - return result != null; - } + public override bool TryGetMember(GetMemberBinder binder, out object result) + { + result = _variables.GetValue(binder.Name); + return result != null; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/PowerShellScript.cs b/Sources/SqlDatabase/Scripts/PowerShellScript.cs index d15ee01a..dc9274b3 100644 --- a/Sources/SqlDatabase/Scripts/PowerShellScript.cs +++ b/Sources/SqlDatabase/Scripts/PowerShellScript.cs @@ -5,86 +5,85 @@ using System.Linq; using SqlDatabase.Scripts.PowerShellInternal; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +internal sealed class PowerShellScript : IScript { - internal sealed class PowerShellScript : IScript - { - public const string ParameterCommand = "Command"; - public const string ParameterVariables = "Variables"; - public const string ParameterWhatIf = "WhatIf"; + public const string ParameterCommand = "Command"; + public const string ParameterVariables = "Variables"; + public const string ParameterWhatIf = "WhatIf"; - public string DisplayName { get; set; } + public string DisplayName { get; set; } - public Func ReadScriptContent { get; set; } + public Func ReadScriptContent { get; set; } - public Func ReadDescriptionContent { get; set; } + public Func ReadDescriptionContent { get; set; } - public IPowerShellFactory PowerShellFactory { get; set; } + public IPowerShellFactory PowerShellFactory { get; set; } - public void Execute(IDbCommand command, IVariables variables, ILogger logger) + public void Execute(IDbCommand command, IVariables variables, ILogger logger) + { + string script; + using (var stream = ReadScriptContent()) + using (var reader = new StreamReader(stream)) { - string script; - using (var stream = ReadScriptContent()) - using (var reader = new StreamReader(stream)) - { - script = reader.ReadToEnd(); - } - - var powerShell = PowerShellFactory.Create(); - if (command == null) - { - InvokeWhatIf(powerShell, script, variables, logger); - } - else - { - Invoke(powerShell, script, command, variables, logger, false); - } + script = reader.ReadToEnd(); } - public IEnumerable ExecuteReader(IDbCommand command, IVariables variables, ILogger logger) + var powerShell = PowerShellFactory.Create(); + if (command == null) + { + InvokeWhatIf(powerShell, script, variables, logger); + } + else { - throw new NotSupportedException("PowerShell script does not support readers."); + Invoke(powerShell, script, command, variables, logger, false); } + } - public IList GetDependencies() + public IEnumerable ExecuteReader(IDbCommand command, IVariables variables, ILogger logger) + { + throw new NotSupportedException("PowerShell script does not support readers."); + } + + public IList GetDependencies() + { + using (var description = ReadDescriptionContent()) { - using (var description = ReadDescriptionContent()) + if (description == null) { - if (description == null) - { - return new ScriptDependency[0]; - } - - using (var reader = new StreamReader(description)) - { - return DependencyParser.ExtractDependencies(reader, DisplayName).ToArray(); - } + return new ScriptDependency[0]; } - } - private static void Invoke(IPowerShell powerShell, string script, IDbCommand command, IVariables variables, ILogger logger, bool whatIf) - { - var parameters = new KeyValuePair[2 + (whatIf ? 1 : 0)]; - parameters[0] = new KeyValuePair(ParameterCommand, command); - parameters[1] = new KeyValuePair(ParameterVariables, new VariablesProxy(variables)); - if (whatIf) + using (var reader = new StreamReader(description)) { - parameters[2] = new KeyValuePair(ParameterWhatIf, null); + return DependencyParser.ExtractDependencies(reader, DisplayName).ToArray(); } + } + } - powerShell.Invoke(script, logger, parameters); + private static void Invoke(IPowerShell powerShell, string script, IDbCommand command, IVariables variables, ILogger logger, bool whatIf) + { + var parameters = new KeyValuePair[2 + (whatIf ? 1 : 0)]; + parameters[0] = new KeyValuePair(ParameterCommand, command); + parameters[1] = new KeyValuePair(ParameterVariables, new VariablesProxy(variables)); + if (whatIf) + { + parameters[2] = new KeyValuePair(ParameterWhatIf, null); } - private static void InvokeWhatIf(IPowerShell powerShell, string script, IVariables variables, ILogger logger) + powerShell.Invoke(script, logger, parameters); + } + + private static void InvokeWhatIf(IPowerShell powerShell, string script, IVariables variables, ILogger logger) + { + if (powerShell.SupportsShouldProcess(script)) { - if (powerShell.SupportsShouldProcess(script)) - { - Invoke(powerShell, script, null, variables, logger, true); - } - else - { - logger.Info("script does not support -WhatIf."); - } + Invoke(powerShell, script, null, variables, logger, true); + } + else + { + logger.Info("script does not support -WhatIf."); } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/ScriptDependency.cs b/Sources/SqlDatabase/Scripts/ScriptDependency.cs index ac0921b8..937f4daf 100644 --- a/Sources/SqlDatabase/Scripts/ScriptDependency.cs +++ b/Sources/SqlDatabase/Scripts/ScriptDependency.cs @@ -1,38 +1,37 @@ using System; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +public readonly struct ScriptDependency : IEquatable { - public readonly struct ScriptDependency : IEquatable + public ScriptDependency(string moduleName, Version version) { - public ScriptDependency(string moduleName, Version version) - { - ModuleName = moduleName; - Version = version; - } - - public string ModuleName { get; } + ModuleName = moduleName; + Version = version; + } - public Version Version { get; } + public string ModuleName { get; } - public bool Equals(ScriptDependency other) - { - return StringComparer.OrdinalIgnoreCase.Equals(ModuleName, other.ModuleName) - && Version == other.Version; - } + public Version Version { get; } - public override bool Equals(object obj) - { - return obj is ScriptDependency d && Equals(d); - } + public bool Equals(ScriptDependency other) + { + return StringComparer.OrdinalIgnoreCase.Equals(ModuleName, other.ModuleName) + && Version == other.Version; + } - public override int GetHashCode() - { - var h1 = StringComparer.OrdinalIgnoreCase.GetHashCode(ModuleName); - var h2 = Version.GetHashCode(); + public override bool Equals(object obj) + { + return obj is ScriptDependency d && Equals(d); + } - return (int)((uint)(h1 << 5) | (uint)h1 >> 27) + h1 ^ h2; - } + public override int GetHashCode() + { + var h1 = StringComparer.OrdinalIgnoreCase.GetHashCode(ModuleName); + var h2 = Version.GetHashCode(); - public override string ToString() => "{0} {1}".FormatWith(ModuleName, Version); + return (int)((uint)(h1 << 5) | (uint)h1 >> 27) + h1 ^ h2; } + + public override string ToString() => "{0} {1}".FormatWith(ModuleName, Version); } \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/ScriptFactory.cs b/Sources/SqlDatabase/Scripts/ScriptFactory.cs index 10deffd7..892f0455 100644 --- a/Sources/SqlDatabase/Scripts/ScriptFactory.cs +++ b/Sources/SqlDatabase/Scripts/ScriptFactory.cs @@ -4,104 +4,103 @@ using SqlDatabase.Configuration; using SqlDatabase.IO; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +internal sealed class ScriptFactory : IScriptFactory { - internal sealed class ScriptFactory : IScriptFactory + public AssemblyScriptConfiguration AssemblyScriptConfiguration { get; set; } + + public IPowerShellFactory PowerShellFactory { get; set; } + + public ISqlTextReader TextReader { get; set; } + + public bool IsSupported(string fileName) { - public AssemblyScriptConfiguration AssemblyScriptConfiguration { get; set; } + var ext = Path.GetExtension(fileName); - public IPowerShellFactory PowerShellFactory { get; set; } + return ".sql".Equals(ext, StringComparison.OrdinalIgnoreCase) + || ".exe".Equals(ext, StringComparison.OrdinalIgnoreCase) + || ".dll".Equals(ext, StringComparison.OrdinalIgnoreCase) + || (PowerShellFactory != null && ".ps1".Equals(ext, StringComparison.OrdinalIgnoreCase)); + } - public ISqlTextReader TextReader { get; set; } + public IScript FromFile(IFile file) + { + var ext = Path.GetExtension(file.Name); - public bool IsSupported(string fileName) + if (".sql".Equals(ext, StringComparison.OrdinalIgnoreCase)) { - var ext = Path.GetExtension(fileName); - - return ".sql".Equals(ext, StringComparison.OrdinalIgnoreCase) - || ".exe".Equals(ext, StringComparison.OrdinalIgnoreCase) - || ".dll".Equals(ext, StringComparison.OrdinalIgnoreCase) - || (PowerShellFactory != null && ".ps1".Equals(ext, StringComparison.OrdinalIgnoreCase)); + return new TextScript + { + DisplayName = file.Name, + ReadSqlContent = file.OpenRead, + TextReader = TextReader + }; } - public IScript FromFile(IFile file) + if (".exe".Equals(ext, StringComparison.OrdinalIgnoreCase) + || ".dll".Equals(ext, StringComparison.OrdinalIgnoreCase)) { - var ext = Path.GetExtension(file.Name); - - if (".sql".Equals(ext, StringComparison.OrdinalIgnoreCase)) + return new AssemblyScript { - return new TextScript - { - DisplayName = file.Name, - ReadSqlContent = file.OpenRead, - TextReader = TextReader - }; - } + DisplayName = file.Name, + Configuration = AssemblyScriptConfiguration, + ReadAssemblyContent = CreateBinaryReader(file), + ReadDescriptionContent = CreateScriptDescriptionReader(file) + }; + } - if (".exe".Equals(ext, StringComparison.OrdinalIgnoreCase) - || ".dll".Equals(ext, StringComparison.OrdinalIgnoreCase)) + if (".ps1".Equals(ext, StringComparison.OrdinalIgnoreCase)) + { + if (PowerShellFactory == null) { - return new AssemblyScript - { - DisplayName = file.Name, - Configuration = AssemblyScriptConfiguration, - ReadAssemblyContent = CreateBinaryReader(file), - ReadDescriptionContent = CreateScriptDescriptionReader(file) - }; + throw new NotSupportedException(".ps1 scripts are not supported in this context."); } - if (".ps1".Equals(ext, StringComparison.OrdinalIgnoreCase)) - { - if (PowerShellFactory == null) - { - throw new NotSupportedException(".ps1 scripts are not supported in this context."); - } - - PowerShellFactory.Request(); - - return new PowerShellScript - { - DisplayName = file.Name, - ReadScriptContent = file.OpenRead, - ReadDescriptionContent = CreateScriptDescriptionReader(file), - PowerShellFactory = PowerShellFactory - }; - } + PowerShellFactory.Request(); - throw new NotSupportedException("File [{0}] cannot be used as script.".FormatWith(file.Name)); + return new PowerShellScript + { + DisplayName = file.Name, + ReadScriptContent = file.OpenRead, + ReadDescriptionContent = CreateScriptDescriptionReader(file), + PowerShellFactory = PowerShellFactory + }; } - private static Func CreateBinaryReader(IFile file) - { - return () => BinaryRead(file); - } + throw new NotSupportedException("File [{0}] cannot be used as script.".FormatWith(file.Name)); + } + + private static Func CreateBinaryReader(IFile file) + { + return () => BinaryRead(file); + } - private static Func CreateScriptDescriptionReader(IFile file) + private static Func CreateScriptDescriptionReader(IFile file) + { + return () => { - return () => + var parent = file.GetParent(); + if (parent == null) { - var parent = file.GetParent(); - if (parent == null) - { - return null; - } + return null; + } - var descriptionName = Path.GetFileNameWithoutExtension(file.Name) + ".txt"; - var description = parent.GetFiles().FirstOrDefault(i => string.Equals(descriptionName, i.Name, StringComparison.OrdinalIgnoreCase)); + var descriptionName = Path.GetFileNameWithoutExtension(file.Name) + ".txt"; + var description = parent.GetFiles().FirstOrDefault(i => string.Equals(descriptionName, i.Name, StringComparison.OrdinalIgnoreCase)); - return description?.OpenRead(); - }; - } + return description?.OpenRead(); + }; + } - private static byte[] BinaryRead(IFile file) + private static byte[] BinaryRead(IFile file) + { + using (var source = file.OpenRead()) + using (var dest = new MemoryStream()) { - using (var source = file.OpenRead()) - using (var dest = new MemoryStream()) - { - source.CopyTo(dest); + source.CopyTo(dest); - return dest.ToArray(); - } + return dest.ToArray(); } } } \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/ScriptStep.cs b/Sources/SqlDatabase/Scripts/ScriptStep.cs index 3dced2ee..4c816aef 100644 --- a/Sources/SqlDatabase/Scripts/ScriptStep.cs +++ b/Sources/SqlDatabase/Scripts/ScriptStep.cs @@ -1,25 +1,24 @@ using System; using System.Diagnostics; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +[DebuggerDisplay("{Script.DisplayName}")] +public readonly struct ScriptStep { - [DebuggerDisplay("{Script.DisplayName}")] - public readonly struct ScriptStep + public ScriptStep(string moduleName, Version from, Version to, IScript script) { - public ScriptStep(string moduleName, Version from, Version to, IScript script) - { - ModuleName = moduleName; - From = from; - To = to; - Script = script; - } + ModuleName = moduleName; + From = from; + To = to; + Script = script; + } - public string ModuleName { get; } + public string ModuleName { get; } - public Version From { get; } + public Version From { get; } - public Version To { get; } + public Version To { get; } - public IScript Script { get; } - } + public IScript Script { get; } } \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/SqlScriptVariableParser.cs b/Sources/SqlDatabase/Scripts/SqlScriptVariableParser.cs index ee4d9562..114a9524 100644 --- a/Sources/SqlDatabase/Scripts/SqlScriptVariableParser.cs +++ b/Sources/SqlDatabase/Scripts/SqlScriptVariableParser.cs @@ -2,76 +2,75 @@ using System.Collections.Generic; using System.Text.RegularExpressions; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +internal sealed class SqlScriptVariableParser { - internal sealed class SqlScriptVariableParser - { - internal const string ValueIsHidden = "[value is hidden]"; + internal const string ValueIsHidden = "[value is hidden]"; - // {{var}} - private const string Pattern1 = @"\{\{(?'name'\w+)\}\}"; + // {{var}} + private const string Pattern1 = @"\{\{(?'name'\w+)\}\}"; - // $(var) - private const string Pattern2 = @"\$\((?'name'\w+)\)"; + // $(var) + private const string Pattern2 = @"\$\((?'name'\w+)\)"; - public SqlScriptVariableParser(IVariables variables) - { - Variables = variables; - ValueByName = new Dictionary(StringComparer.OrdinalIgnoreCase); - } + public SqlScriptVariableParser(IVariables variables) + { + Variables = variables; + ValueByName = new Dictionary(StringComparer.OrdinalIgnoreCase); + } - public IVariables Variables { get; } + public IVariables Variables { get; } - public IDictionary ValueByName { get; } + public IDictionary ValueByName { get; } - public static bool IsValidVariableName(string name) + public static bool IsValidVariableName(string name) + { + var match = Regex.Match("{{" + name + "}}", Pattern1, RegexOptions.Compiled); + if (!match.Success && !name.Equals(match.Groups["name"].Value, StringComparison.OrdinalIgnoreCase)) { - var match = Regex.Match("{{" + name + "}}", Pattern1, RegexOptions.Compiled); - if (!match.Success && !name.Equals(match.Groups["name"].Value, StringComparison.OrdinalIgnoreCase)) - { - return false; - } - - match = Regex.Match("$(" + name + ")", Pattern2, RegexOptions.Compiled); - return match.Success && name.Equals(match.Groups["name"].Value, StringComparison.OrdinalIgnoreCase); + return false; } - public string ApplyVariables(string script) - { - if (string.IsNullOrWhiteSpace(script)) - { - return script; - } - - var result = Regex.Replace(script, Pattern1, Evaluator, RegexOptions.Compiled); - return Regex.Replace(result, Pattern2, Evaluator, RegexOptions.Compiled); - } + match = Regex.Match("$(" + name + ")", Pattern2, RegexOptions.Compiled); + return match.Success && name.Equals(match.Groups["name"].Value, StringComparison.OrdinalIgnoreCase); + } - private static bool HideValueFromOutput(string name) + public string ApplyVariables(string script) + { + if (string.IsNullOrWhiteSpace(script)) { - return name[0] == '_'; + return script; } - private string Evaluator(Match match) - { - var name = match.Groups["name"].Value; + var result = Regex.Replace(script, Pattern1, Evaluator, RegexOptions.Compiled); + return Regex.Replace(result, Pattern2, Evaluator, RegexOptions.Compiled); + } - var value = Variables.GetValue(name); - if (value == null) - { - throw new InvalidOperationException("Variable [{0}] not defined.".FormatWith(name)); - } + private static bool HideValueFromOutput(string name) + { + return name[0] == '_'; + } - OnVariablesReplace(name, value); - return value; + private string Evaluator(Match match) + { + var name = match.Groups["name"].Value; + + var value = Variables.GetValue(name); + if (value == null) + { + throw new InvalidOperationException("Variable [{0}] not defined.".FormatWith(name)); } - private void OnVariablesReplace(string name, string value) + OnVariablesReplace(name, value); + return value; + } + + private void OnVariablesReplace(string name, string value) + { + if (!ValueByName.ContainsKey(name)) { - if (!ValueByName.ContainsKey(name)) - { - ValueByName.Add(name, HideValueFromOutput(name) ? ValueIsHidden : value); - } + ValueByName.Add(name, HideValueFromOutput(name) ? ValueIsHidden : value); } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/TextScript.cs b/Sources/SqlDatabase/Scripts/TextScript.cs index 14c69bbc..e428f06a 100644 --- a/Sources/SqlDatabase/Scripts/TextScript.cs +++ b/Sources/SqlDatabase/Scripts/TextScript.cs @@ -5,180 +5,179 @@ using System.IO; using System.Linq; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +internal sealed class TextScript : IScript { - internal sealed class TextScript : IScript - { - public string DisplayName { get; set; } + public string DisplayName { get; set; } - public Func ReadSqlContent { get; set; } + public Func ReadSqlContent { get; set; } - public ISqlTextReader TextReader { get; set; } + public ISqlTextReader TextReader { get; set; } - public void Execute(IDbCommand command, IVariables variables, ILogger logger) - { - var batches = ResolveBatches(variables, logger); + public void Execute(IDbCommand command, IVariables variables, ILogger logger) + { + var batches = ResolveBatches(variables, logger); - if (command == null) + if (command == null) + { + foreach (var batch in batches) { - foreach (var batch in batches) - { - // what-if: just read to the end - } - - return; + // what-if: just read to the end } - foreach (var batch in batches) + return; + } + + foreach (var batch in batches) + { + command.CommandText = batch; + using (var reader = command.ExecuteReader()) { - command.CommandText = batch; - using (var reader = command.ExecuteReader()) + var identOutput = false; + do { - var identOutput = false; - do + var columns = GetReaderColumns(reader); + if (columns == null) { - var columns = GetReaderColumns(reader); - if (columns == null) - { - ReadEmpty(reader); - } - else - { - ReadWithOutput(reader, columns, logger, identOutput); - identOutput = true; - } + ReadEmpty(reader); + } + else + { + ReadWithOutput(reader, columns, logger, identOutput); + identOutput = true; } - while (reader.NextResult()); } + while (reader.NextResult()); } } + } - public IEnumerable ExecuteReader(IDbCommand command, IVariables variables, ILogger logger) - { - var batches = ResolveBatches(variables, logger); + public IEnumerable ExecuteReader(IDbCommand command, IVariables variables, ILogger logger) + { + var batches = ResolveBatches(variables, logger); - foreach (var batch in batches) + foreach (var batch in batches) + { + command.CommandText = batch; + using (var reader = command.ExecuteReader()) { - command.CommandText = batch; - using (var reader = command.ExecuteReader()) - { - yield return reader; - } + yield return reader; } } + } - public IList GetDependencies() + public IList GetDependencies() + { + string batch; + using (var sql = ReadSqlContent()) { - string batch; - using (var sql = ReadSqlContent()) - { - batch = TextReader.ReadFirstBatch(sql); - } + batch = TextReader.ReadFirstBatch(sql); + } - if (string.IsNullOrWhiteSpace(batch)) - { - return new ScriptDependency[0]; - } + if (string.IsNullOrWhiteSpace(batch)) + { + return new ScriptDependency[0]; + } - return DependencyParser.ExtractDependencies(new StringReader(batch), DisplayName).ToArray(); + return DependencyParser.ExtractDependencies(new StringReader(batch), DisplayName).ToArray(); + } + + private static string[] GetReaderColumns(IDataReader reader) + { + using (var metadata = reader.GetSchemaTable()) + { + // mssql: ColumnName is string.Empty if not defined + // pgsql: ColumnName is DbNull if not defined + return metadata + ?.Rows + .Cast() + .OrderBy(i => (int)i["ColumnOrdinal"]) + .Select(i => i["ColumnName"]?.ToString()) + .ToArray(); } + } - private static string[] GetReaderColumns(IDataReader reader) + private static void ReadEmpty(IDataReader reader) + { + while (reader.Read()) { - using (var metadata = reader.GetSchemaTable()) - { - // mssql: ColumnName is string.Empty if not defined - // pgsql: ColumnName is DbNull if not defined - return metadata - ?.Rows - .Cast() - .OrderBy(i => (int)i["ColumnOrdinal"]) - .Select(i => i["ColumnName"]?.ToString()) - .ToArray(); - } } + } - private static void ReadEmpty(IDataReader reader) + private static void ReadWithOutput(IDataReader reader, string[] columns, ILogger logger, bool identOutput) + { + if (identOutput) { - while (reader.Read()) - { - } + logger.Info(string.Empty); } - private static void ReadWithOutput(IDataReader reader, string[] columns, ILogger logger, bool identOutput) + var maxNameLength = 0; + for (var i = 0; i < columns.Length; i++) { - if (identOutput) + var columnName = columns[i]; + if (string.IsNullOrEmpty(columnName)) { - logger.Info(string.Empty); + columnName = "(no name)"; } - var maxNameLength = 0; - for (var i = 0; i < columns.Length; i++) - { - var columnName = columns[i]; - if (string.IsNullOrEmpty(columnName)) - { - columnName = "(no name)"; - } + columns[i] = columnName; + maxNameLength = Math.Max(maxNameLength, columnName.Length); + } - columns[i] = columnName; - maxNameLength = Math.Max(maxNameLength, columnName.Length); - } + logger.Info("output: " + string.Join("; ", columns)); - logger.Info("output: " + string.Join("; ", columns)); + for (var i = 0; i < columns.Length; i++) + { + var name = columns[i]; + var spaces = maxNameLength - name.Length + 1; + columns[i] = name + new string(' ', spaces) + ": "; + } - for (var i = 0; i < columns.Length; i++) - { - var name = columns[i]; - var spaces = maxNameLength - name.Length + 1; - columns[i] = name + new string(' ', spaces) + ": "; - } + var rowsCount = 0; + while (reader.Read()) + { + rowsCount++; - var rowsCount = 0; - while (reader.Read()) + logger.Info("row " + rowsCount.ToString(CultureInfo.CurrentCulture)); + using (logger.Indent()) { - rowsCount++; - - logger.Info("row " + rowsCount.ToString(CultureInfo.CurrentCulture)); - using (logger.Indent()) + for (var i = 0; i < columns.Length; i++) { - for (var i = 0; i < columns.Length; i++) - { - var value = reader.IsDBNull(i) ? "NULL" : Convert.ToString(reader.GetValue(i), CultureInfo.CurrentCulture); - logger.Info(columns[i] + value); - } + var value = reader.IsDBNull(i) ? "NULL" : Convert.ToString(reader.GetValue(i), CultureInfo.CurrentCulture); + logger.Info(columns[i] + value); } } - - logger.Info("{0} row{1} selected".FormatWith( - rowsCount.ToString(CultureInfo.CurrentCulture), - rowsCount == 1 ? null : "s")); } - private IEnumerable ResolveBatches(IVariables variables, ILogger logger) - { - var scriptParser = new SqlScriptVariableParser(variables); + logger.Info("{0} row{1} selected".FormatWith( + rowsCount.ToString(CultureInfo.CurrentCulture), + rowsCount == 1 ? null : "s")); + } + + private IEnumerable ResolveBatches(IVariables variables, ILogger logger) + { + var scriptParser = new SqlScriptVariableParser(variables); - var batches = new List(); - using (var sql = ReadSqlContent()) + var batches = new List(); + using (var sql = ReadSqlContent()) + { + foreach (var batch in TextReader.ReadBatches(sql)) { - foreach (var batch in TextReader.ReadBatches(sql)) + var script = scriptParser.ApplyVariables(batch); + if (!string.IsNullOrWhiteSpace(script)) { - var script = scriptParser.ApplyVariables(batch); - if (!string.IsNullOrWhiteSpace(script)) - { - batches.Add(script); - } + batches.Add(script); } } + } - var report = scriptParser.ValueByName.OrderBy(i => i.Key); - foreach (var entry in report) - { - logger.Info("variable {0} was replaced with {1}".FormatWith(entry.Key, entry.Value)); - } - - return batches; + var report = scriptParser.ValueByName.OrderBy(i => i.Key); + foreach (var entry in report) + { + logger.Info("variable {0} was replaced with {1}".FormatWith(entry.Key, entry.Value)); } + + return batches; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/UpgradeInternal/IModuleVersionResolver.cs b/Sources/SqlDatabase/Scripts/UpgradeInternal/IModuleVersionResolver.cs index 9596f275..0d656f96 100644 --- a/Sources/SqlDatabase/Scripts/UpgradeInternal/IModuleVersionResolver.cs +++ b/Sources/SqlDatabase/Scripts/UpgradeInternal/IModuleVersionResolver.cs @@ -1,10 +1,9 @@ using System; -namespace SqlDatabase.Scripts.UpgradeInternal +namespace SqlDatabase.Scripts.UpgradeInternal; + +internal interface IModuleVersionResolver { - internal interface IModuleVersionResolver - { - // => InvalidOperationException fail to determine dependent module [{1}] version - Version GetCurrentVersion(string moduleName); - } -} + // => InvalidOperationException fail to determine dependent module [{1}] version + Version GetCurrentVersion(string moduleName); +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/UpgradeInternal/ModuleVersionResolver.cs b/Sources/SqlDatabase/Scripts/UpgradeInternal/ModuleVersionResolver.cs index f5042a0b..712d3fee 100644 --- a/Sources/SqlDatabase/Scripts/UpgradeInternal/ModuleVersionResolver.cs +++ b/Sources/SqlDatabase/Scripts/UpgradeInternal/ModuleVersionResolver.cs @@ -1,46 +1,45 @@ using System; using System.Collections.Generic; -namespace SqlDatabase.Scripts.UpgradeInternal +namespace SqlDatabase.Scripts.UpgradeInternal; + +internal sealed class ModuleVersionResolver : IModuleVersionResolver { - internal sealed class ModuleVersionResolver : IModuleVersionResolver - { - private readonly IDictionary _versionByModule = new Dictionary(StringComparer.OrdinalIgnoreCase); + private readonly IDictionary _versionByModule = new Dictionary(StringComparer.OrdinalIgnoreCase); - public ILogger Log { get; set; } + public ILogger Log { get; set; } - public IDatabase Database { get; set; } + public IDatabase Database { get; set; } - public Version GetCurrentVersion(string moduleName) + public Version GetCurrentVersion(string moduleName) + { + if (moduleName == null) { - if (moduleName == null) - { - moduleName = string.Empty; - } - - if (!_versionByModule.TryGetValue(moduleName, out var version)) - { - version = LoadVersion(moduleName); - _versionByModule.Add(moduleName, version); - } - - return version; + moduleName = string.Empty; } - private Version LoadVersion(string moduleName) + if (!_versionByModule.TryGetValue(moduleName, out var version)) { - var version = Database.GetCurrentVersion(moduleName); - - if (moduleName.Length == 0) - { - Log.Info("database version: {0}".FormatWith(version)); - } - else - { - Log.Info("module [{0}] version: {1}".FormatWith(moduleName, version)); - } - - return version; + version = LoadVersion(moduleName); + _versionByModule.Add(moduleName, version); } + + return version; + } + + private Version LoadVersion(string moduleName) + { + var version = Database.GetCurrentVersion(moduleName); + + if (moduleName.Length == 0) + { + Log.Info("database version: {0}".FormatWith(version)); + } + else + { + Log.Info("module [{0}] version: {1}".FormatWith(moduleName, version)); + } + + return version; } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/UpgradeInternal/UpgradeScriptCollection.cs b/Sources/SqlDatabase/Scripts/UpgradeInternal/UpgradeScriptCollection.cs index 09747179..649bc621 100644 --- a/Sources/SqlDatabase/Scripts/UpgradeInternal/UpgradeScriptCollection.cs +++ b/Sources/SqlDatabase/Scripts/UpgradeInternal/UpgradeScriptCollection.cs @@ -4,314 +4,313 @@ using System.Linq; using SqlDatabase.IO; -namespace SqlDatabase.Scripts.UpgradeInternal +namespace SqlDatabase.Scripts.UpgradeInternal; + +internal sealed class UpgradeScriptCollection { - internal sealed class UpgradeScriptCollection + private readonly IDictionary> _stepsByModule = new Dictionary>(StringComparer.OrdinalIgnoreCase); + private readonly IDictionary> _dependencyByStep = new Dictionary>(); + + public UpgradeScriptCollection(bool folderAsModuleName) { - private readonly IDictionary> _stepsByModule = new Dictionary>(StringComparer.OrdinalIgnoreCase); - private readonly IDictionary> _dependencyByStep = new Dictionary>(); + FolderAsModuleName = folderAsModuleName; + } - public UpgradeScriptCollection(bool folderAsModuleName) - { - FolderAsModuleName = folderAsModuleName; - } + public bool FolderAsModuleName { get; } + + public ICollection ModuleNames => _stepsByModule.Keys; - public bool FolderAsModuleName { get; } + public IList GetSteps(string moduleName) => _stepsByModule[moduleName]; - public ICollection ModuleNames => _stepsByModule.Keys; + public void LoadFrom(IEnumerable sources, IScriptFactory scriptFactory) + { + LoadFrom(sources, scriptFactory, 0, null); + } - public IList GetSteps(string moduleName) => _stepsByModule[moduleName]; + public void BuildModuleSequence(string moduleName, Version moduleVersion) + { + var files = _stepsByModule[moduleName]; + _stepsByModule.Remove(moduleName); - public void LoadFrom(IEnumerable sources, IScriptFactory scriptFactory) + var maxVersion = files.Select(i => i.To).Max(); + if (maxVersion == moduleVersion) { - LoadFrom(sources, scriptFactory, 0, null); + // up to date + return; } - public void BuildModuleSequence(string moduleName, Version moduleVersion) + if (maxVersion < moduleVersion) { - var files = _stepsByModule[moduleName]; - _stepsByModule.Remove(moduleName); - - var maxVersion = files.Select(i => i.To).Max(); - if (maxVersion == moduleVersion) + if (string.IsNullOrEmpty(moduleName)) { - // up to date - return; + throw new InvalidOperationException("The current version [{0}] is greater then latest upgrade [{1}].".FormatWith(moduleVersion, maxVersion)); } - if (maxVersion < moduleVersion) - { - if (string.IsNullOrEmpty(moduleName)) - { - throw new InvalidOperationException("The current version [{0}] is greater then latest upgrade [{1}].".FormatWith(moduleVersion, maxVersion)); - } + throw new InvalidOperationException("Module [{0}], the current version [{1}] is greater then latest upgrade [{2}].".FormatWith(moduleName, moduleVersion, maxVersion)); + } - throw new InvalidOperationException("Module [{0}], the current version [{1}] is greater then latest upgrade [{2}].".FormatWith(moduleName, moduleVersion, maxVersion)); - } + files = files + .Where(i => i.From >= moduleVersion) + .OrderBy(i => i.From) + .ThenByDescending(i => i.To) + .ToList(); - files = files - .Where(i => i.From >= moduleVersion) - .OrderBy(i => i.From) - .ThenByDescending(i => i.To) - .ToList(); + var sequence = new List(); + var version = moduleVersion; + while (files.Count > 0) + { + var file = files[0]; + files.RemoveAt(0); - var sequence = new List(); - var version = moduleVersion; - while (files.Count > 0) + if (version != file.From) { - var file = files[0]; - files.RemoveAt(0); - - if (version != file.From) - { - continue; - } - - if (files.Count > 0 && files[0].From == version && files[0].To == file.To) - { - if (string.IsNullOrEmpty(moduleName)) - { - throw new InvalidOperationException("Duplicated step found [{0}] and [{1}].".FormatWith(file.Script.DisplayName, files[0].Script.DisplayName)); - } - - throw new InvalidOperationException("Module [{0}], duplicated step found [{1}] and [{2}].".FormatWith(moduleName, file.Script.DisplayName, files[0].Script.DisplayName)); - } - - sequence.Add(file); - version = file.To; + continue; } - if (version != maxVersion) + if (files.Count > 0 && files[0].From == version && files[0].To == file.To) { if (string.IsNullOrEmpty(moduleName)) { - throw new InvalidOperationException("Upgrade step from [{0}] to a next not found.".FormatWith(version)); + throw new InvalidOperationException("Duplicated step found [{0}] and [{1}].".FormatWith(file.Script.DisplayName, files[0].Script.DisplayName)); } - throw new InvalidOperationException("Module [{0}], upgrade step from [{1}] to a next not found.".FormatWith(moduleName, version)); + throw new InvalidOperationException("Module [{0}], duplicated step found [{1}] and [{2}].".FormatWith(moduleName, file.Script.DisplayName, files[0].Script.DisplayName)); } - _stepsByModule[moduleName] = sequence; + sequence.Add(file); + version = file.To; } - public void LoadDependencies() + if (version != maxVersion) { - foreach (var steps in _stepsByModule.Values) + if (string.IsNullOrEmpty(moduleName)) { - foreach (var step in steps) - { - var dependencies = step.Script.GetDependencies(); - _dependencyByStep.Add(step.Script, dependencies); - } + throw new InvalidOperationException("Upgrade step from [{0}] to a next not found.".FormatWith(version)); } + + throw new InvalidOperationException("Module [{0}], upgrade step from [{1}] to a next not found.".FormatWith(moduleName, version)); } - public void ShowWithDependencies(ILogger logger) + _stepsByModule[moduleName] = sequence; + } + + public void LoadDependencies() + { + foreach (var steps in _stepsByModule.Values) { - foreach (var moduleName in _stepsByModule.Keys.OrderBy(i => i)) + foreach (var step in steps) { - var steps = _stepsByModule[moduleName]; - logger.Info("module [{0}], {1} step{2}:".FormatWith( - moduleName, - steps.Count, - steps.Count == 1 ? null : "s")); + var dependencies = step.Script.GetDependencies(); + _dependencyByStep.Add(step.Script, dependencies); + } + } + } - using (logger.Indent()) + public void ShowWithDependencies(ILogger logger) + { + foreach (var moduleName in _stepsByModule.Keys.OrderBy(i => i)) + { + var steps = _stepsByModule[moduleName]; + logger.Info("module [{0}], {1} step{2}:".FormatWith( + moduleName, + steps.Count, + steps.Count == 1 ? null : "s")); + + using (logger.Indent()) + { + foreach (var step in steps) { - foreach (var step in steps) + var dependencies = GetDependencies(step); + if (dependencies.Count == 0) + { + logger.Info("{0}, no dependencies".FormatWith(step.Script.DisplayName)); + } + else { - var dependencies = GetDependencies(step); - if (dependencies.Count == 0) - { - logger.Info("{0}, no dependencies".FormatWith(step.Script.DisplayName)); - } - else - { - logger.Info("{0}, depends on {1}".FormatWith( - step.Script.DisplayName, - string.Join("; ", dependencies.OrderBy(i => i.ModuleName)))); - } + logger.Info("{0}, depends on {1}".FormatWith( + step.Script.DisplayName, + string.Join("; ", dependencies.OrderBy(i => i.ModuleName)))); } } } } + } - public void ValidateModuleDependencies(string moduleName, IModuleVersionResolver versionResolver) + public void ValidateModuleDependencies(string moduleName, IModuleVersionResolver versionResolver) + { + foreach (var step in _stepsByModule[moduleName]) { - foreach (var step in _stepsByModule[moduleName]) + foreach (var dependency in GetDependencies(step)) { - foreach (var dependency in GetDependencies(step)) + var currentVersion = versionResolver.GetCurrentVersion(dependency.ModuleName); + if (currentVersion > dependency.Version) { - var currentVersion = versionResolver.GetCurrentVersion(dependency.ModuleName); - if (currentVersion > dependency.Version) + throw new InvalidOperationException("Migration step [{0}] requires module [{1}] to be version [{2}], but current is [{3}].".FormatWith( + step.Script.DisplayName, + dependency.ModuleName, + dependency.Version, + currentVersion)); + } + + if (currentVersion != dependency.Version) + { + var contains = _stepsByModule.ContainsKey(dependency.ModuleName) + && _stepsByModule[dependency.ModuleName].Any(i => i.To == dependency.Version); + + if (!contains) { - throw new InvalidOperationException("Migration step [{0}] requires module [{1}] to be version [{2}], but current is [{3}].".FormatWith( + throw new InvalidOperationException("Migration step [{0}] depends on module [{1}] version [{2}], but upgrade for this module not found.".FormatWith( step.Script.DisplayName, dependency.ModuleName, - dependency.Version, - currentVersion)); - } - - if (currentVersion != dependency.Version) - { - var contains = _stepsByModule.ContainsKey(dependency.ModuleName) - && _stepsByModule[dependency.ModuleName].Any(i => i.To == dependency.Version); - - if (!contains) - { - throw new InvalidOperationException("Migration step [{0}] depends on module [{1}] version [{2}], but upgrade for this module not found.".FormatWith( - step.Script.DisplayName, - dependency.ModuleName, - dependency.Version)); - } + dependency.Version)); } } } } + } - public ScriptStep GetNextStep(string moduleName) => _stepsByModule[moduleName][0]; + public ScriptStep GetNextStep(string moduleName) => _stepsByModule[moduleName][0]; - public void RemoveNextStep(string moduleName) - { - var steps = _stepsByModule[moduleName]; - steps.RemoveAt(0); + public void RemoveNextStep(string moduleName) + { + var steps = _stepsByModule[moduleName]; + steps.RemoveAt(0); - if (steps.Count == 0) - { - _stepsByModule.Remove(moduleName); - } + if (steps.Count == 0) + { + _stepsByModule.Remove(moduleName); } + } - public bool TestStep(IDictionary versionByModule, string stepModule, ScriptStep step) + public bool TestStep(IDictionary versionByModule, string stepModule, ScriptStep step) + { + // can be step executed now + foreach (var dependency in GetDependencies(step)) { - // can be step executed now - foreach (var dependency in GetDependencies(step)) + // skip external module => already tested in ValidateModuleDependencies + if (versionByModule.TryGetValue(dependency.ModuleName, out var version)) { - // skip external module => already tested in ValidateModuleDependencies - if (versionByModule.TryGetValue(dependency.ModuleName, out var version)) + if (dependency.Version != version) { - if (dependency.Version != version) - { - return false; - } + return false; } } + } + + var objections = _stepsByModule + .Values + .SelectMany(i => i) + .Where(i => i.Script != step.Script) // skip this + .SelectMany(GetDependencies) + .Where(i => string.Equals(i.ModuleName, stepModule, StringComparison.OrdinalIgnoreCase)) + .Any(i => i.Version < step.To); + + return !objections; + } - var objections = _stepsByModule - .Values - .SelectMany(i => i) - .Where(i => i.Script != step.Script) // skip this - .SelectMany(GetDependencies) - .Where(i => string.Equals(i.ModuleName, stepModule, StringComparison.OrdinalIgnoreCase)) - .Any(i => i.Version < step.To); + internal static bool TryParseFileName(string name, out string moduleName, out Version from, out Version to) + { + moduleName = null; + from = null; + to = null; - return !objections; + var index = name.LastIndexOf(".", StringComparison.OrdinalIgnoreCase); + if (index > 0) + { + name = name.Substring(0, index); } - internal static bool TryParseFileName(string name, out string moduleName, out Version from, out Version to) + index = name.LastIndexOf("_", StringComparison.InvariantCultureIgnoreCase); + if (index <= 0 || index == name.Length) { - moduleName = null; - from = null; - to = null; + return false; + } - var index = name.LastIndexOf(".", StringComparison.OrdinalIgnoreCase); - if (index > 0) - { - name = name.Substring(0, index); - } + var versionTo = name.Substring(index + 1); + var versionFrom = name = name.Substring(0, index); - index = name.LastIndexOf("_", StringComparison.InvariantCultureIgnoreCase); - if (index <= 0 || index == name.Length) - { - return false; - } + index = name.LastIndexOf("_", StringComparison.InvariantCultureIgnoreCase); + if (index == 0) + { + return false; + } - var versionTo = name.Substring(index + 1); - var versionFrom = name = name.Substring(0, index); + if (index > 0) + { + versionFrom = name.Substring(index + 1); + moduleName = name.Substring(0, index); + } + else + { + moduleName = string.Empty; + } - index = name.LastIndexOf("_", StringComparison.InvariantCultureIgnoreCase); - if (index == 0) - { - return false; - } + from = ParseVersion(versionFrom); + to = ParseVersion(versionTo); + return from != null && to != null && from < to; + } - if (index > 0) - { - versionFrom = name.Substring(index + 1); - moduleName = name.Substring(0, index); - } - else - { - moduleName = string.Empty; - } + private static Version ParseVersion(string value) + { + if (Version.TryParse(value, out var ver)) + { + return ver; + } - from = ParseVersion(versionFrom); - to = ParseVersion(versionTo); - return from != null && to != null && from < to; + if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var major) && major >= 0) + { + return new Version(major, 0); } - private static Version ParseVersion(string value) + return null; + } + + private void LoadFrom(IEnumerable sources, IScriptFactory scriptFactory, int depth, string rootFolderName) + { + foreach (var source in sources) { - if (Version.TryParse(value, out var ver)) + if (source is IFolder folder) { - return ver; - } + if (FolderAsModuleName && depth == 1) + { + rootFolderName = folder.Name; + } - if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var major) && major >= 0) - { - return new Version(major, 0); + var children = folder.GetFolders().Cast().Concat(folder.GetFiles()); + LoadFrom(children, scriptFactory, depth + 1, rootFolderName); } - - return null; - } - - private void LoadFrom(IEnumerable sources, IScriptFactory scriptFactory, int depth, string rootFolderName) - { - foreach (var source in sources) + else { - if (source is IFolder folder) + var file = (IFile)source; + if (scriptFactory.IsSupported(file.Name) && TryParseFileName(file.Name, out var moduleName, out var from, out var to)) { - if (FolderAsModuleName && depth == 1) + if (FolderAsModuleName && string.IsNullOrEmpty(rootFolderName)) { - rootFolderName = folder.Name; + throw new InvalidOperationException("File [{0}] is not expected in the root folder.".FormatWith(file.Name)); } - var children = folder.GetFolders().Cast().Concat(folder.GetFiles()); - LoadFrom(children, scriptFactory, depth + 1, rootFolderName); - } - else - { - var file = (IFile)source; - if (scriptFactory.IsSupported(file.Name) && TryParseFileName(file.Name, out var moduleName, out var from, out var to)) + if (FolderAsModuleName && !string.IsNullOrEmpty(moduleName) && !moduleName.Equals(rootFolderName, StringComparison.OrdinalIgnoreCase)) { - if (FolderAsModuleName && string.IsNullOrEmpty(rootFolderName)) - { - throw new InvalidOperationException("File [{0}] is not expected in the root folder.".FormatWith(file.Name)); - } - - if (FolderAsModuleName && !string.IsNullOrEmpty(moduleName) && !moduleName.Equals(rootFolderName, StringComparison.OrdinalIgnoreCase)) - { - throw new InvalidOperationException("File [{0}] with module name [{1}] is not expected in the folder [{2}].".FormatWith(file.Name, moduleName, rootFolderName)); - } - - if (FolderAsModuleName) - { - moduleName = rootFolderName; - } - - if (!_stepsByModule.TryGetValue(moduleName, out var steps)) - { - steps = new List(); - _stepsByModule.Add(moduleName, steps); - } - - var script = scriptFactory.FromFile(file); - steps.Add(new ScriptStep(moduleName, from, to, script)); + throw new InvalidOperationException("File [{0}] with module name [{1}] is not expected in the folder [{2}].".FormatWith(file.Name, moduleName, rootFolderName)); } + + if (FolderAsModuleName) + { + moduleName = rootFolderName; + } + + if (!_stepsByModule.TryGetValue(moduleName, out var steps)) + { + steps = new List(); + _stepsByModule.Add(moduleName, steps); + } + + var script = scriptFactory.FromFile(file); + steps.Add(new ScriptStep(moduleName, from, to, script)); } } } - - private IList GetDependencies(ScriptStep step) => _dependencyByStep[step.Script]; } -} + + private IList GetDependencies(ScriptStep step) => _dependencyByStep[step.Script]; +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/UpgradeScriptSequence.cs b/Sources/SqlDatabase/Scripts/UpgradeScriptSequence.cs index 2cba39e7..4aebc59f 100644 --- a/Sources/SqlDatabase/Scripts/UpgradeScriptSequence.cs +++ b/Sources/SqlDatabase/Scripts/UpgradeScriptSequence.cs @@ -5,153 +5,152 @@ using SqlDatabase.IO; using SqlDatabase.Scripts.UpgradeInternal; -namespace SqlDatabase.Scripts -{ - internal sealed class UpgradeScriptSequence : IUpgradeScriptSequence - { - public IList Sources { get; set; } = new List(); - - public IScriptFactory ScriptFactory { get; set; } +namespace SqlDatabase.Scripts; - public IModuleVersionResolver VersionResolver { get; set; } - - public ILogger Log { get; set; } +internal sealed class UpgradeScriptSequence : IUpgradeScriptSequence +{ + public IList Sources { get; set; } = new List(); - public bool FolderAsModuleName { get; set; } + public IScriptFactory ScriptFactory { get; set; } - public bool WhatIf { get; set; } + public IModuleVersionResolver VersionResolver { get; set; } - public IList BuildSequence() - { - var scripts = new UpgradeScriptCollection(FolderAsModuleName); - scripts.LoadFrom(Sources, ScriptFactory); + public ILogger Log { get; set; } - // folder is empty - if (scripts.ModuleNames.Count == 0) - { - return new ScriptStep[0]; - } + public bool FolderAsModuleName { get; set; } - foreach (var moduleName in scripts.ModuleNames.ToArray()) - { - scripts.BuildModuleSequence(moduleName, VersionResolver.GetCurrentVersion(moduleName)); - } + public bool WhatIf { get; set; } - // no updates - if (scripts.ModuleNames.Count == 0) - { - return new ScriptStep[0]; - } + public IList BuildSequence() + { + var scripts = new UpgradeScriptCollection(FolderAsModuleName); + scripts.LoadFrom(Sources, ScriptFactory); - // no modules - if (scripts.ModuleNames.Count == 1 && string.IsNullOrEmpty(scripts.ModuleNames.First())) - { - return scripts.GetSteps(scripts.ModuleNames.First()); - } + // folder is empty + if (scripts.ModuleNames.Count == 0) + { + return new ScriptStep[0]; + } - scripts.LoadDependencies(); + foreach (var moduleName in scripts.ModuleNames.ToArray()) + { + scripts.BuildModuleSequence(moduleName, VersionResolver.GetCurrentVersion(moduleName)); + } - if (WhatIf) - { - scripts.ShowWithDependencies(Log); - } + // no updates + if (scripts.ModuleNames.Count == 0) + { + return new ScriptStep[0]; + } - foreach (var moduleName in scripts.ModuleNames) - { - scripts.ValidateModuleDependencies(moduleName, VersionResolver); - } + // no modules + if (scripts.ModuleNames.Count == 1 && string.IsNullOrEmpty(scripts.ModuleNames.First())) + { + return scripts.GetSteps(scripts.ModuleNames.First()); + } - // only one module to update - if (scripts.ModuleNames.Count == 1) - { - return scripts.GetSteps(scripts.ModuleNames.First()); - } + scripts.LoadDependencies(); - return BuildSequence(scripts); + if (WhatIf) + { + scripts.ShowWithDependencies(Log); } - private IList BuildSequence(UpgradeScriptCollection scripts) + foreach (var moduleName in scripts.ModuleNames) { - var sequence = new List(); - - var versionByModule = new Dictionary(StringComparer.OrdinalIgnoreCase); - foreach (var moduleName in scripts.ModuleNames) - { - versionByModule.Add(moduleName, VersionResolver.GetCurrentVersion(moduleName)); - } + scripts.ValidateModuleDependencies(moduleName, VersionResolver); + } - while (scripts.ModuleNames.Count > 0) - { - var nextStep = default(ScriptStep); - string nextStepModuleName = null; + // only one module to update + if (scripts.ModuleNames.Count == 1) + { + return scripts.GetSteps(scripts.ModuleNames.First()); + } - foreach (var moduleName in scripts.ModuleNames) - { - nextStep = scripts.GetNextStep(moduleName); - if (scripts.TestStep(versionByModule, moduleName, nextStep)) - { - nextStepModuleName = moduleName; - break; - } - } + return BuildSequence(scripts); + } - if (nextStepModuleName == null) - { - ThrowSequenceNotFound(scripts, sequence); - } - else - { - sequence.Add(nextStep); - scripts.RemoveNextStep(nextStepModuleName); - versionByModule[nextStepModuleName] = nextStep.To; - } - } + private IList BuildSequence(UpgradeScriptCollection scripts) + { + var sequence = new List(); - return sequence; + var versionByModule = new Dictionary(StringComparer.OrdinalIgnoreCase); + foreach (var moduleName in scripts.ModuleNames) + { + versionByModule.Add(moduleName, VersionResolver.GetCurrentVersion(moduleName)); } - private void ThrowSequenceNotFound(UpgradeScriptCollection scripts, IList sequence) + while (scripts.ModuleNames.Count > 0) { - var message = new StringBuilder("Not possible to build upgrade sequence. Current sequence: "); + var nextStep = default(ScriptStep); + string nextStepModuleName = null; - if (sequence.Count == 0) - { - message.Append("is empty"); - } - else + foreach (var moduleName in scripts.ModuleNames) { - message.Append(sequence[0].From); - foreach (var step in sequence) + nextStep = scripts.GetNextStep(moduleName); + if (scripts.TestStep(versionByModule, moduleName, nextStep)) { - message.AppendFormat(" => {0}", step.To); + nextStepModuleName = moduleName; + break; } } - message.Append(". Next candidate"); - if (scripts.ModuleNames.Count > 1) + if (nextStepModuleName == null) { - message.Append("s: "); + ThrowSequenceNotFound(scripts, sequence); } else { - message.Append(": "); + sequence.Add(nextStep); + scripts.RemoveNextStep(nextStepModuleName); + versionByModule[nextStepModuleName] = nextStep.To; } + } - var comma = false; - foreach (var moduleName in scripts.ModuleNames) - { - if (comma) - { - message.Append(", "); - } + return sequence; + } - message.Append(scripts.GetNextStep(moduleName).Script.DisplayName); - comma = true; + private void ThrowSequenceNotFound(UpgradeScriptCollection scripts, IList sequence) + { + var message = new StringBuilder("Not possible to build upgrade sequence. Current sequence: "); + + if (sequence.Count == 0) + { + message.Append("is empty"); + } + else + { + message.Append(sequence[0].From); + foreach (var step in sequence) + { + message.AppendFormat(" => {0}", step.To); } + } - message.Append("."); + message.Append(". Next candidate"); + if (scripts.ModuleNames.Count > 1) + { + message.Append("s: "); + } + else + { + message.Append(": "); + } - throw new InvalidOperationException(message.ToString()); + var comma = false; + foreach (var moduleName in scripts.ModuleNames) + { + if (comma) + { + message.Append(", "); + } + + message.Append(scripts.GetNextStep(moduleName).Script.DisplayName); + comma = true; } + + message.Append("."); + + throw new InvalidOperationException(message.ToString()); } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/VariableSource.cs b/Sources/SqlDatabase/Scripts/VariableSource.cs index 9d628dee..f0bb804e 100644 --- a/Sources/SqlDatabase/Scripts/VariableSource.cs +++ b/Sources/SqlDatabase/Scripts/VariableSource.cs @@ -1,13 +1,12 @@ -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +public enum VariableSource { - public enum VariableSource - { - Runtime, + Runtime, - CommandLine, + CommandLine, - Environment, + Environment, - ConfigurationFile - } -} + ConfigurationFile +} \ No newline at end of file diff --git a/Sources/SqlDatabase/Scripts/Variables.cs b/Sources/SqlDatabase/Scripts/Variables.cs index 39f3023f..69621de0 100644 --- a/Sources/SqlDatabase/Scripts/Variables.cs +++ b/Sources/SqlDatabase/Scripts/Variables.cs @@ -1,96 +1,95 @@ using System; using System.Collections.Generic; -namespace SqlDatabase.Scripts +namespace SqlDatabase.Scripts; + +internal sealed class Variables : IVariables { - internal sealed class Variables : IVariables - { - private readonly IDictionary _valueByName = new Dictionary(StringComparer.OrdinalIgnoreCase); + private readonly IDictionary _valueByName = new Dictionary(StringComparer.OrdinalIgnoreCase); - public string DatabaseName + public string DatabaseName + { + get => GetValue(nameof(DatabaseName)); + set { - get => GetValue(nameof(DatabaseName)); - set - { - SetValue(VariableSource.Runtime, nameof(DatabaseName), value); - SetValue(VariableSource.Runtime, "DbName", value); - } + SetValue(VariableSource.Runtime, nameof(DatabaseName), value); + SetValue(VariableSource.Runtime, "DbName", value); } + } - public string CurrentVersion - { - get => GetValue(nameof(CurrentVersion)); - set => SetValue(VariableSource.Runtime, nameof(CurrentVersion), value); - } + public string CurrentVersion + { + get => GetValue(nameof(CurrentVersion)); + set => SetValue(VariableSource.Runtime, nameof(CurrentVersion), value); + } - public string TargetVersion - { - get => GetValue(nameof(TargetVersion)); - set => SetValue(VariableSource.Runtime, nameof(TargetVersion), value); - } + public string TargetVersion + { + get => GetValue(nameof(TargetVersion)); + set => SetValue(VariableSource.Runtime, nameof(TargetVersion), value); + } - public string ModuleName - { - get => GetValue(nameof(ModuleName)); - set => SetValue(VariableSource.Runtime, nameof(ModuleName), value); - } + public string ModuleName + { + get => GetValue(nameof(ModuleName)); + set => SetValue(VariableSource.Runtime, nameof(ModuleName), value); + } - public IEnumerable GetNames() - { - return _valueByName.Keys; - } + public IEnumerable GetNames() + { + return _valueByName.Keys; + } - public string GetValue(string name) + public string GetValue(string name) + { + if (_valueByName.TryGetValue(name, out var value)) { - if (_valueByName.TryGetValue(name, out var value)) + if (value.Source != VariableSource.ConfigurationFile) { - if (value.Source != VariableSource.ConfigurationFile) - { - return value.Value; - } + return value.Value; } - - var environmentValue = Environment.GetEnvironmentVariable(name); - return string.IsNullOrEmpty(environmentValue) ? value.Value : environmentValue; } - internal void SetValue(VariableSource source, string name, string value) + var environmentValue = Environment.GetEnvironmentVariable(name); + return string.IsNullOrEmpty(environmentValue) ? value.Value : environmentValue; + } + + internal void SetValue(VariableSource source, string name, string value) + { + if (!_valueByName.TryGetValue(name, out var oldValue) + || source <= oldValue.Source) { - if (!_valueByName.TryGetValue(name, out var oldValue) - || source <= oldValue.Source) + if (value == null) + { + _valueByName.Remove(name); + } + else { - if (value == null) - { - _valueByName.Remove(name); - } - else - { - _valueByName[name] = new VariableValue(source, value); - } + _valueByName[name] = new VariableValue(source, value); } } + } - private readonly struct VariableValue + private readonly struct VariableValue + { + public VariableValue(VariableSource source, string value) { - public VariableValue(VariableSource source, string value) - { - Source = source; - Value = value; - } + Source = source; + Value = value; + } - public VariableSource Source { get; } + public VariableSource Source { get; } - public string Value { get; } + public string Value { get; } - public override bool Equals(object obj) - { - throw new NotSupportedException(); - } + public override bool Equals(object obj) + { + throw new NotSupportedException(); + } - public override int GetHashCode() - { - throw new NotSupportedException(); - } + public override int GetHashCode() + { + throw new NotSupportedException(); } } -} +} \ No newline at end of file diff --git a/Sources/SqlDatabase/SqlDatabase.csproj b/Sources/SqlDatabase/SqlDatabase.csproj index 1354249a..4ca88f4f 100644 --- a/Sources/SqlDatabase/SqlDatabase.csproj +++ b/Sources/SqlDatabase/SqlDatabase.csproj @@ -1,8 +1,8 @@  - net452;netcoreapp3.1;net5.0;net6.0;netstandard2.0 - netcoreapp3.1;net5.0;net6.0 + net452;netcoreapp3.1;net5.0;net6.0;net7.0;netstandard2.0 + netcoreapp3.1;net5.0;net6.0;net7.0 @@ -75,9 +75,13 @@ + + + + - + diff --git a/Sources/SqlDatabase/StringExtensions.cs b/Sources/SqlDatabase/StringExtensions.cs index 2276255b..e5d98b5b 100644 --- a/Sources/SqlDatabase/StringExtensions.cs +++ b/Sources/SqlDatabase/StringExtensions.cs @@ -1,12 +1,11 @@ using System.Globalization; -namespace SqlDatabase +namespace SqlDatabase; + +internal static class StringExtensions { - internal static class StringExtensions + public static string FormatWith(this string format, params object[] args) { - public static string FormatWith(this string format, params object[] args) - { - return string.Format(CultureInfo.InvariantCulture, format, args); - } + return string.Format(CultureInfo.InvariantCulture, format, args); } } \ No newline at end of file