You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: end2end/EndToEndScaffold/Templates/MySqlTests.cs
+33Lines changed: 33 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -523,6 +523,39 @@ public async Task TestBinaryCopyFrom(
523
523
}
524
524
"""
525
525
},
526
+
[KnownTestType.MySqlTransaction]=newTestImpl
527
+
{
528
+
Impl=$$"""
529
+
[Test]
530
+
public async Task TestMySqlTransaction()
531
+
{
532
+
var connection = new MySqlConnector.MySqlConnection(Environment.GetEnvironmentVariable(EndToEndCommon.MySqlConnectionStringEnv)!);
533
+
await connection.OpenAsync();
534
+
var transaction = connection.BeginTransaction();
535
+
536
+
var sqlQueryWithTx = new QuerySql(transaction);
537
+
await sqlQueryWithTx.CreateAuthor(new QuerySql.CreateAuthorArgs { Id = 1111, Name = "Bojack Horseman", Bio = "Back in the 90s he was in a very famous TV show" });
538
+
539
+
// The GetAuthor method in MySqlConnectorExampleGen (non-Dapper) returns QuerySql.GetAuthorRow (non-nullable struct/record)
540
+
// if it were a non-nullable struct/record, actualNull == null would always be false.
541
+
// However, MySqlConnectorTester.generated.cs uses actual.Value, implying it's nullable.
542
+
// Let's assume QuerySql.GetAuthor returns QuerySql.GetAuthorRow? (nullable record struct) for MySqlConnectorExampleGen.
543
+
var actualNull = await this.QuerySql.GetAuthor(new QuerySql.GetAuthorArgs { Name = "Bojack Horseman" });
544
+
Assert.That(actualNull == null, "there is author"); // This is correct for nullable types
545
+
546
+
await transaction.CommitAsync();
547
+
548
+
var expected = new QuerySql.GetAuthorRow
549
+
{
550
+
Id = 1111,
551
+
Name = "Bojack Horseman",
552
+
Bio = "Back in the 90s he was in a very famous TV show"
553
+
};
554
+
var actual = await this.QuerySql.GetAuthor(new QuerySql.GetAuthorArgs { Name = "Bojack Horseman" });
555
+
Assert.That(SingularEquals(expected, actual{{Consts.UnknownRecordValuePlaceholder}})); // Apply placeholder here
0 commit comments