Skip to content
代码片段 群组 项目
未验证 提交 93c37701 编辑于 作者: Matt Mitchell's avatar Matt Mitchell 提交者: GitHub
浏览文件

More line ending renormalization (#35301)

上级 05cb69ff
No related branches found
No related tags found
无相关合并请求
{
"solution": {
"path": "..\\..\\AspNetCore.sln",
"projects": [
"src\\Caching\\SqlServer\\src\\Microsoft.Extensions.Caching.SqlServer.csproj",
"src\\Caching\\SqlServer\\test\\Microsoft.Extensions.Caching.SqlServer.Tests.csproj",
"src\\Caching\\StackExchangeRedis\\src\\Microsoft.Extensions.Caching.StackExchangeRedis.csproj",
"src\\Caching\\StackExchangeRedis\\test\\Microsoft.Extensions.Caching.StackExchangeRedis.Tests.csproj"
]
}
}
{
"solution": {
"path": "..\\..\\AspNetCore.sln",
"projects": [
"src\\Caching\\SqlServer\\src\\Microsoft.Extensions.Caching.SqlServer.csproj",
"src\\Caching\\SqlServer\\test\\Microsoft.Extensions.Caching.SqlServer.Tests.csproj",
"src\\Caching\\StackExchangeRedis\\src\\Microsoft.Extensions.Caching.StackExchangeRedis.csproj",
"src\\Caching\\StackExchangeRedis\\test\\Microsoft.Extensions.Caching.StackExchangeRedis.Tests.csproj"
]
}
}
# Microsoft.Extensions.Caching.SqlServer Tests
These tests include functional tests that run against a real SQL Server. Since these are flaky on CI, they should be run manually when changing this code.
## Pre-requisites
1. A functional SQL Server, Local DB included with VS is sufficient
1. An empty database named `CacheTestDb` in that SQL Server
## Running the tests
1. Install the latest version of the `dotnet-sql-cache` too: `dotnet tool install --global dotnet-sql-cache` (make sure to specify a version if it's a pre-release tool you want!)
1. Run `dotnet sql-cache [connectionstring] dbo CacheTest`
* `[connectionstring]` must be a SQL Connection String **for an empty database named `CacheTestDb` that already exists**
* If using Local DB, this string should work: `"Server=(localdb)\MSSQLLocalDB;Database=CacheTestDb;Trusted_Connection=True;"`
1. Unskip the tests by changing the `SqlServerCacheWithDatabaseTest.SkipReason` field to `null`.
# Microsoft.Extensions.Caching.SqlServer Tests
These tests include functional tests that run against a real SQL Server. Since these are flaky on CI, they should be run manually when changing this code.
## Pre-requisites
1. A functional SQL Server, Local DB included with VS is sufficient
1. An empty database named `CacheTestDb` in that SQL Server
## Running the tests
1. Install the latest version of the `dotnet-sql-cache` too: `dotnet tool install --global dotnet-sql-cache` (make sure to specify a version if it's a pre-release tool you want!)
1. Run `dotnet sql-cache [connectionstring] dbo CacheTest`
* `[connectionstring]` must be a SQL Connection String **for an empty database named `CacheTestDb` that already exists**
* If using Local DB, this string should work: `"Server=(localdb)\MSSQLLocalDB;Database=CacheTestDb;Trusted_Connection=True;"`
1. Unskip the tests by changing the `SqlServerCacheWithDatabaseTest.SkipReason` field to `null`.
1. Run the tests.
\ No newline at end of file
param(
[Parameter(Mandatory = $false)][string]$ConnectionString = "Server=(localdb)\MSSQLLocalDB;Database=CacheTestDb;Trusted_Connection=True;",
[Parameter(Mandatory = $false)][string]$SchemaName = "dbo",
[Parameter(Mandatory = $false)][string]$TableName = "CacheTest")
function ExecuteScalar($Connection, $Script) {
$cmd = New-Object System.Data.SqlClient.SqlCommand
$cmd.Connection = $Connection
$cmd.CommandText = $Script
$cmd.ExecuteScalar()
}
# Check if the database exists
Write-Host "Checking for database..."
$ServerConnectionBuilder = New-Object System.Data.SqlClient.SqlConnectionStringBuilder $ConnectionString
if (!$ServerConnectionBuilder.InitialCatalog) {
throw "An 'Initial Catalog' or 'Database' value must be provided in the connection string!"
}
$DatabaseName = $ServerConnectionBuilder.InitialCatalog
if (!$ServerConnectionBuilder.DataSource -eq "(localdb)\MSSQLLocalDB") {
Write-Warning "This script is really only designed for running against your local instance of SQL Local DB. Continue at your own risk!"
}
$ServerConnectionBuilder.Remove("Initial Catalog") | Out-Null;
$ServerConnection = New-Object System.Data.SqlClient.SqlConnection $ServerConnectionBuilder.ConnectionString
$ServerConnection.Open();
# Yes, this is SQL Injectable, but you're using it on your local machine with the intent of connecting to your local db.
$dbid = ExecuteScalar $ServerConnection "SELECT database_id FROM sys.databases WHERE Name = '$DatabaseName'"
if (!$dbid) {
Write-Host "Database not found, creating..."
# Create the database
ExecuteScalar $ServerConnection "CREATE DATABASE $DatabaseName"
}
# Close the server connection
$ServerConnection.Close()
# Check for the table
$DbConnection = New-Object System.Data.SqlClient.SqlConnection $ConnectionString
$DbConnection.Open();
$tableid = ExecuteScalar $DbConnection "SELECT object_id FROM sys.objects WHERE type = 'U' AND name = '$TableName'"
if ($tableid) {
Write-Host "Table exists, dropping it..."
ExecuteScalar $DbConnection "DROP TABLE $TableName"
}
$DbConnection.Close()
# Fill the database with sql cache goodies
dotnet sql-cache create $ConnectionString $SchemaName $TableName
# Set environment variables and launch tests
$oldConnectionString = $env:SQLCACHETESTS_ConnectionString
$oldSchemaName = $env:SQLCACHETESTS_SchemaName
$oldTableName = $env:SQLCACHETESTS_TableName
$oldEnabled = $env:SQLCACHETESTS_ENABLED
try {
$env:SQLCACHETESTS_ConnectionString = $ConnectionString
$env:SQLCACHETESTS_SchemaName = $SchemaName
$env:SQLCACHETESTS_TableName = $TableName
$env:SQLCACHETESTS_ENABLED = "1"
Write-Host "Launching Tests..."
dotnet test "$PSScriptRoot/Microsoft.Extensions.Caching.SqlServer.Tests.csproj"
}
finally {
if ($oldConnectionString) {
$env:SQLCACHETESTS_ConnectionString = $oldConnectionString
}
else {
Remove-Item env:\SQLCACHETESTS_ConnectionString
}
if ($oldSchemaName) {
$env:SQLCACHETESTS_SchemaName = $oldSchemaName
}
else {
Remove-Item env:\SQLCACHETESTS_SchemaName
}
if ($oldTableName) {
$env:SQLCACHETESTS_TableName = $oldTableName
}
else {
Remove-Item env:\SQLCACHETESTS_TableName
}
if ($oldEnabled) {
$env:SQLCACHETESTS_ENABLED = $oldEnabled
}
else {
Remove-Item env:\SQLCACHETESTS_ENABLED
}
}
param(
[Parameter(Mandatory = $false)][string]$ConnectionString = "Server=(localdb)\MSSQLLocalDB;Database=CacheTestDb;Trusted_Connection=True;",
[Parameter(Mandatory = $false)][string]$SchemaName = "dbo",
[Parameter(Mandatory = $false)][string]$TableName = "CacheTest")
function ExecuteScalar($Connection, $Script) {
$cmd = New-Object System.Data.SqlClient.SqlCommand
$cmd.Connection = $Connection
$cmd.CommandText = $Script
$cmd.ExecuteScalar()
}
# Check if the database exists
Write-Host "Checking for database..."
$ServerConnectionBuilder = New-Object System.Data.SqlClient.SqlConnectionStringBuilder $ConnectionString
if (!$ServerConnectionBuilder.InitialCatalog) {
throw "An 'Initial Catalog' or 'Database' value must be provided in the connection string!"
}
$DatabaseName = $ServerConnectionBuilder.InitialCatalog
if (!$ServerConnectionBuilder.DataSource -eq "(localdb)\MSSQLLocalDB") {
Write-Warning "This script is really only designed for running against your local instance of SQL Local DB. Continue at your own risk!"
}
$ServerConnectionBuilder.Remove("Initial Catalog") | Out-Null;
$ServerConnection = New-Object System.Data.SqlClient.SqlConnection $ServerConnectionBuilder.ConnectionString
$ServerConnection.Open();
# Yes, this is SQL Injectable, but you're using it on your local machine with the intent of connecting to your local db.
$dbid = ExecuteScalar $ServerConnection "SELECT database_id FROM sys.databases WHERE Name = '$DatabaseName'"
if (!$dbid) {
Write-Host "Database not found, creating..."
# Create the database
ExecuteScalar $ServerConnection "CREATE DATABASE $DatabaseName"
}
# Close the server connection
$ServerConnection.Close()
# Check for the table
$DbConnection = New-Object System.Data.SqlClient.SqlConnection $ConnectionString
$DbConnection.Open();
$tableid = ExecuteScalar $DbConnection "SELECT object_id FROM sys.objects WHERE type = 'U' AND name = '$TableName'"
if ($tableid) {
Write-Host "Table exists, dropping it..."
ExecuteScalar $DbConnection "DROP TABLE $TableName"
}
$DbConnection.Close()
# Fill the database with sql cache goodies
dotnet sql-cache create $ConnectionString $SchemaName $TableName
# Set environment variables and launch tests
$oldConnectionString = $env:SQLCACHETESTS_ConnectionString
$oldSchemaName = $env:SQLCACHETESTS_SchemaName
$oldTableName = $env:SQLCACHETESTS_TableName
$oldEnabled = $env:SQLCACHETESTS_ENABLED
try {
$env:SQLCACHETESTS_ConnectionString = $ConnectionString
$env:SQLCACHETESTS_SchemaName = $SchemaName
$env:SQLCACHETESTS_TableName = $TableName
$env:SQLCACHETESTS_ENABLED = "1"
Write-Host "Launching Tests..."
dotnet test "$PSScriptRoot/Microsoft.Extensions.Caching.SqlServer.Tests.csproj"
}
finally {
if ($oldConnectionString) {
$env:SQLCACHETESTS_ConnectionString = $oldConnectionString
}
else {
Remove-Item env:\SQLCACHETESTS_ConnectionString
}
if ($oldSchemaName) {
$env:SQLCACHETESTS_SchemaName = $oldSchemaName
}
else {
Remove-Item env:\SQLCACHETESTS_SchemaName
}
if ($oldTableName) {
$env:SQLCACHETESTS_TableName = $oldTableName
}
else {
Remove-Item env:\SQLCACHETESTS_TableName
}
if ($oldEnabled) {
$env:SQLCACHETESTS_ENABLED = $oldEnabled
}
else {
Remove-Item env:\SQLCACHETESTS_ENABLED
}
}
<Project>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.props))\Directory.Build.props" />
<PropertyGroup>
<PackageId>@microsoft/dotnet-js-interop</PackageId>
<IsPackable>true</IsPackable>
<IsTestProject>false</IsTestProject>
<IsShipping>true</IsShipping>
</PropertyGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.targets))\Directory.Build.targets" />
</Project>
<Project>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.props))\Directory.Build.props" />
<PropertyGroup>
<PackageId>@microsoft/dotnet-js-interop</PackageId>
<IsPackable>true</IsPackable>
<IsTestProject>false</IsTestProject>
<IsShipping>true</IsShipping>
</PropertyGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.targets))\Directory.Build.targets" />
</Project>
@using TagHelpersWebSite.Models
@using Microsoft.AspNetCore.Mvc.Razor
@model WebsiteContext
@{
ViewBag.Title = "Home Page";
}
@addTagHelper *, TagHelpersWebSite
@section css {
<style condition="!Model.Approved">
h1 {
color:red;
font-size:2em;
}
</style>
}
@functions {
public void RenderTemplate(string title, Func<string, HelperResult> template)
{
Output.WriteLine("<br /><p><em>Rendering Template:</em></p>");
var helperResult = template(title);
helperResult.WriteTo(Output, HtmlEncoder);
}
}
<div condition="!Model.Approved">
<p>This website has <strong surround="em">not</strong> been approved yet. Visit www.contoso.com for <strong make-pretty="false">more</strong> information.</p>
</div>
<div>
<h3>Current Tag Cloud from Tag Helper</h3>
<tag-cloud count="Model.TagsToShow" surround="div" />
<h3>Current Tag Cloud from ViewComponentHelper:</h3>
<section bold>@await Component.InvokeAsync("Tags", new { count = 15 })</section>
@{
RenderTemplate(
"Tag Cloud from Template: ",
@<div condition="true"><h3>@item</h3><tag-cloud count="Model.TagsToShow"></tag-cloud></div>);
}
</div>
<div>
<h3>Dictionary Valued Model Expression</h3>
<div prefix-test1="@Model.TagsToShow" prefix-test2="@Model.Version.Build"></div>
</div>
@section footerContent {
<p condition="Model.Approved" bold surround="section">&copy; @Model.CopyrightYear - My ASP.NET Application</p>
@using TagHelpersWebSite.Models
@using Microsoft.AspNetCore.Mvc.Razor
@model WebsiteContext
@{
ViewBag.Title = "Home Page";
}
@addTagHelper *, TagHelpersWebSite
@section css {
<style condition="!Model.Approved">
h1 {
color:red;
font-size:2em;
}
</style>
}
@functions {
public void RenderTemplate(string title, Func<string, HelperResult> template)
{
Output.WriteLine("<br /><p><em>Rendering Template:</em></p>");
var helperResult = template(title);
helperResult.WriteTo(Output, HtmlEncoder);
}
}
<div condition="!Model.Approved">
<p>This website has <strong surround="em">not</strong> been approved yet. Visit www.contoso.com for <strong make-pretty="false">more</strong> information.</p>
</div>
<div>
<h3>Current Tag Cloud from Tag Helper</h3>
<tag-cloud count="Model.TagsToShow" surround="div" />
<h3>Current Tag Cloud from ViewComponentHelper:</h3>
<section bold>@await Component.InvokeAsync("Tags", new { count = 15 })</section>
@{
RenderTemplate(
"Tag Cloud from Template: ",
@<div condition="true"><h3>@item</h3><tag-cloud count="Model.TagsToShow"></tag-cloud></div>);
}
</div>
<div>
<h3>Dictionary Valued Model Expression</h3>
<div prefix-test1="@Model.TagsToShow" prefix-test2="@Model.Version.Build"></div>
</div>
@section footerContent {
<p condition="Model.Approved" bold surround="section">&copy; @Model.CopyrightYear - My ASP.NET Application</p>
}
\ No newline at end of file
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册