-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
94 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
tests/MySqlConnector.NativeAot.Tests/MySqlConnector.NativeAot.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFrameworks>net8.0;net9.0</TargetFrameworks> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<PublishAot>true</PublishAot> | ||
<InvariantGlobalization>true</InvariantGlobalization> | ||
<StripSymbols>true</StripSymbols> | ||
<UseSystemResourceKeys>true</UseSystemResourceKeys> | ||
<IlcFoldIdenticalMethodBodies>true</IlcFoldIdenticalMethodBodies> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\MySqlConnector\MySqlConnector.csproj" /> | ||
<ProjectReference Include="..\..\src\MySqlConnector.DependencyInjection\MySqlConnector.DependencyInjection.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using MySqlConnector; | ||
|
||
var connectionString = Environment.GetEnvironmentVariable("CONNECTION_STRING") ?? "Server=localhost;Username=root;Password=pass"; | ||
|
||
await using var dataSource = new MySqlDataSourceBuilder(connectionString).Build(); | ||
|
||
await using var conn = dataSource.CreateConnection(); | ||
await conn.OpenAsync(); | ||
await using var cmd = new MySqlCommand("SELECT 'Hello World'", conn); | ||
await using var reader = await cmd.ExecuteReaderAsync(); | ||
if (!await reader.ReadAsync()) | ||
throw new Exception("ReadAsync returned false"); | ||
|
||
var value = reader.GetFieldValue<string>(0); | ||
if (value != "Hello World") | ||
throw new Exception($"Expected 'Hello World'; got '{value}'"); | ||
|
||
var schema = reader.GetColumnSchema(); | ||
if (schema.Count != 1) | ||
throw new Exception($"Expected 1 column, got {schema.Count}"); | ||
if (((MySqlDbColumn) schema[0]).ProviderType != MySqlDbType.VarChar) | ||
throw new Exception($"Expected column type to be MySqlDbType.VarChar, got {((MySqlDbColumn) schema[0]).ProviderType}"); | ||
if (reader.GetFieldType(0) != typeof(string)) | ||
throw new Exception($"Expected column type to be System.String, got {reader.GetFieldType(0)}"); | ||
|
||
Console.WriteLine("Success"); |