@@ -67,7 +67,7 @@ public class BookHandlerTests
6767 var result = BookHandlers .Handle (command , session );
6868
6969 // Assert
70- await Assert .That (result ).IsNotNull ();
70+ _ = await Assert .That (result ).IsNotNull ();
7171 session .Events .Received (1 ).StartStream <BookAggregate >(.. .);
7272 }
7373}
@@ -81,50 +81,50 @@ TUnit uses a fluent, async-first assertion syntax:
8181
8282``` csharp
8383// Equality
84- await Assert .That (actual ).IsEqualTo (expected );
85- await Assert .That (actual ).IsNotEqualTo (unexpected );
84+ _ = await Assert .That (actual ).IsEqualTo (expected );
85+ _ = await Assert .That (actual ).IsNotEqualTo (unexpected );
8686
8787// Null checks
88- await Assert .That (value ).IsNotNull ();
89- await Assert .That (value ).IsNull ();
88+ _ = await Assert .That (value ).IsNotNull ();
89+ _ = await Assert .That (value ).IsNull ();
9090
9191// Boolean
92- await Assert .That (condition ).IsTrue ();
93- await Assert .That (condition ).IsFalse ();
92+ _ = await Assert .That (condition ).IsTrue ();
93+ _ = await Assert .That (condition ).IsFalse ();
9494
9595// Type checks
96- await Assert .That (result ).IsTypeOf <ExpectedType >();
97- await Assert .That (result ).IsNotTypeOf <UnexpectedType >();
96+ _ = await Assert .That (result ).IsTypeOf <ExpectedType >();
97+ _ = await Assert .That (result ).IsNotTypeOf <UnexpectedType >();
9898```
9999
100100### Collection Assertions
101101
102102``` csharp
103103// Contains
104- await Assert .That (collection ).Contains (item );
105- await Assert .That (collection ).DoesNotContain (item );
104+ _ = await Assert .That (collection ).Contains (item );
105+ _ = await Assert .That (collection ).DoesNotContain (item );
106106
107107// Empty/Not Empty
108- await Assert .That (collection ).IsEmpty ();
109- await Assert .That (collection ).IsNotEmpty ();
108+ _ = await Assert .That (collection ).IsEmpty ();
109+ _ = await Assert .That (collection ).IsNotEmpty ();
110110
111111// Count
112- await Assert .That (collection ).Count ().IsEqualTo (3 );
112+ _ = await Assert .That (collection ).Count ().IsEqualTo (3 );
113113```
114114
115115### String Assertions
116116
117117``` csharp
118118// Contains
119- await Assert .That (text ).Contains (" substring" );
120- await Assert .That (text ).DoesNotContain (" missing" );
119+ _ = await Assert .That (text ).Contains (" substring" );
120+ _ = await Assert .That (text ).DoesNotContain (" missing" );
121121
122122// Starts/Ends With
123- await Assert .That (text ).StartsWith (" prefix" );
124- await Assert .That (text ).EndsWith (" suffix" );
123+ _ = await Assert .That (text ).StartsWith (" prefix" );
124+ _ = await Assert .That (text ).EndsWith (" suffix" );
125125
126126// Regex
127- await Assert .That (text ).Matches (@" pattern" );
127+ _ = await Assert .That (text ).Matches (@" pattern" );
128128```
129129
130130### Exception Assertions
@@ -163,7 +163,7 @@ public async Task UpdateBookHandler_WithMissingBook_ShouldReturnNotFound()
163163 var result = await BookHandlers .Handle (command , session , context );
164164
165165 // Assert
166- await Assert .That (result ).IsTypeOf <NotFound >();
166+ _ = await Assert .That (result ).IsTypeOf <NotFound >();
167167}
168168```
169169
@@ -180,7 +180,7 @@ public async Task DateTimeOffset_Should_Serialize_As_ISO8601_With_UTC()
180180 var testObject = new { Timestamp = new DateTimeOffset (2025 , 12 , 26 , 17 , 16 , 9 , 123 , TimeSpan .Zero ) };
181181 var json = JsonSerializer .Serialize (testObject , _options );
182182
183- await Assert .That (json ).Contains (" \" timestamp\" :\" 2025-12-26T17:16:09.123+00:00\" " );
183+ _ = await Assert .That (json ).Contains (" \" timestamp\" :\" 2025-12-26T17:16:09.123+00:00\" " );
184184}
185185```
186186
@@ -203,7 +203,7 @@ public async Task GetWebResourceRootReturnsOkStatusCode(CancellationToken cancel
203203 var httpClient = app .CreateHttpClient (" webfrontend" );
204204 var response = await httpClient .GetAsync (" /" , cancellationToken );
205205
206- await Assert .That (response .StatusCode ).IsEqualTo (HttpStatusCode .OK );
206+ _ = await Assert .That (response .StatusCode ).IsEqualTo (HttpStatusCode .OK );
207207}
208208```
209209
@@ -378,7 +378,7 @@ All TUnit assertions are async, so tests should be `async Task`:
378378[Test]
379379public async Task MyTest() // ✓ Correct
380380{
381- await Assert.That(result).IsNotNull();
381+ _ = await Assert.That(result).IsNotNull();
382382}
383383
384384[Test]
@@ -394,7 +394,7 @@ TUnit's fluent syntax is more readable:
394394
395395` ` ` csharp
396396// ✓ TUnit style
397- await Assert.That(result).IsEqualTo(expected);
397+ _ = await Assert.That(result).IsEqualTo(expected);
398398
399399// ✗ Old xUnit style (don't use)
400400Assert.Equal(expected, result);
@@ -442,7 +442,7 @@ public async Task Updates_configuration_file()
442442{
443443 await ConfigurationManager.SetAsync("key", "value");
444444 var result = await ConfigurationManager.GetAsync("key");
445- await Assert.That(result).IsEqualTo("value");
445+ _ = await Assert.That(result).IsEqualTo("value");
446446}
447447` ` `
448448
@@ -547,7 +547,7 @@ public class BadTests
547547 public async Task Test1()
548548 {
549549 counter++;
550- await Assert.That(counter).IsEqualTo(1); // May fail if tests run in parallel
550+ _ = await Assert.That(counter).IsEqualTo(1); // May fail if tests run in parallel
551551 }
552552}
553553
@@ -559,7 +559,7 @@ public class GoodTests
559559 {
560560 var counter = 0; // Local state
561561 counter++;
562- await Assert.That(counter).IsEqualTo(1);
562+ _ = await Assert.That(counter).IsEqualTo(1);
563563 }
564564}
565565` ` `
@@ -582,7 +582,7 @@ public async Task CreateBook_PersistsBookToDatabase()
582582{
583583 var book = await bookService.CreateBook(...);
584584 var retrieved = await bookService.GetBook(book.Id);
585- await Assert.That(retrieved).IsNotNull();
585+ _ = await Assert.That(retrieved).IsNotNull();
586586}
587587` ` `
588588
@@ -789,13 +789,13 @@ public void StoreResult()
789789
790790` ` ` csharp
791791// ✗ Bad: Expensive operation in assertion
792- await Assert.That(await GetAllUsersFromDatabase())
792+ _ = await Assert.That(await GetAllUsersFromDatabase())
793793 .Count()
794794 .IsEqualTo(1000);
795795
796796// ✓ Good: Use efficient queries
797797var userCount = await GetUserCountFromDatabase();
798- await Assert.That(userCount).IsEqualTo(1000);
798+ _ = await Assert.That(userCount).IsEqualTo(1000);
799799` ` `
800800
801801# ## CI/CD Performance
@@ -853,10 +853,10 @@ If you're familiar with xUnit, here are the key differences:
853853| `[Fact]` | `[Test]` |
854854| `[Theory]` | `[Test]` |
855855| `[InlineData(...)]` | `[Arguments(...)]` |
856- | `Assert.Equal(expected, actual)` | `await Assert.That(actual).IsEqualTo(expected)` |
857- | `Assert.NotNull(value)` | `await Assert.That(value).IsNotNull()` |
858- | `Assert.True(condition)` | `await Assert.That(condition).IsTrue()` |
859- | `Assert.Contains(item, collection)` | `await Assert.That(collection).Contains(item)` |
856+ | `Assert.Equal(expected, actual)` | `_ = await Assert.That(actual).IsEqualTo(expected)` |
857+ | `Assert.NotNull(value)` | `_ = await Assert.That(value).IsNotNull()` |
858+ | `Assert.True(condition)` | `_ = await Assert.That(condition).IsTrue()` |
859+ | `Assert.Contains(item, collection)` | `_ = await Assert.That(collection).Contains(item)` |
860860
861861See the [TUnit migration guide](https://tunit.dev/docs/migration/xunit/) for more details.
862862
0 commit comments