Skip to content

Commit ab30642

Browse files
committed
refactor: Suppress compiler warnings in test assertions and mock setups using discard assignments.
1 parent 8e99e22 commit ab30642

2 files changed

Lines changed: 21 additions & 21 deletions

File tree

src/ApiService/BookStore.ApiService.Tests/Handlers/BookHandlerTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ public async Task CreateBookHandler_ShouldStartStreamWithBookAddedEvent()
2929
[Guid.CreateVersion7()]);
3030

3131
var session = Substitute.For<IDocumentSession>();
32-
session.CorrelationId.Returns("test-correlation-id");
32+
_ = session.CorrelationId.Returns("test-correlation-id");
3333

3434
// Act
3535
var result = BookHandlers.Handle(command, session);
3636

3737
// Assert
38-
await Assert.That(result.Item1).IsNotNull();
39-
session.Events.Received(1).StartStream<BookAggregate>(
38+
_ = await Assert.That(result.Item1).IsNotNull();
39+
_ = session.Events.Received(1).StartStream<BookAggregate>(
4040
command.Id,
4141
Arg.Is<BookAdded>(e =>
4242
e.Title == "Clean Code" &&
@@ -62,13 +62,13 @@ public async Task UpdateBookHandler_WithMissingBook_ShouldReturnNotFound()
6262
var context = new DefaultHttpContext();
6363

6464
// Stream doesn't exist
65-
session.Events.FetchStreamStateAsync(command.Id)
65+
_ = session.Events.FetchStreamStateAsync(command.Id)
6666
.Returns(Task.FromResult<Marten.Events.StreamState?>(null));
6767

6868
// Act
6969
var result = await BookHandlers.Handle(command, session, context);
7070

7171
// Assert
72-
await Assert.That(result).IsTypeOf<Microsoft.AspNetCore.Http.HttpResults.NotFound>();
72+
_ = await Assert.That(result).IsTypeOf<Microsoft.AspNetCore.Http.HttpResults.NotFound>();
7373
}
7474
}

src/ApiService/BookStore.ApiService.Tests/JsonSerializationTests.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public async Task DateTimeOffset_Should_Serialize_As_ISO8601_With_UTC()
3232
var json = JsonSerializer.Serialize(testObject, _options.Value);
3333

3434
// Assert
35-
await Assert.That(json).Contains("\"timestamp\":\"2025-12-26T17:16:09.123+00:00\"");
35+
_ = await Assert.That(json).Contains("\"timestamp\":\"2025-12-26T17:16:09.123+00:00\"");
3636
}
3737

3838
[Test]
@@ -46,7 +46,7 @@ public async Task DateTimeOffset_UtcNow_Should_End_With_Z_Or_UTC_Offset()
4646
var json = JsonSerializer.Serialize(testObject, _options.Value);
4747

4848
// Assert - Should match ISO 8601 format with UTC indicator
49-
await Assert.That(json).Matches(@"""timestamp"":""(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d+)?\+00:00""");
49+
_ = await Assert.That(json).Matches(@"""timestamp"":""(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d+)?\+00:00\""");
5050
}
5151

5252
[Test]
@@ -60,7 +60,7 @@ public async Task DateOnly_Should_Serialize_As_ISO8601_Date()
6060
var json = JsonSerializer.Serialize(testObject, _options.Value);
6161

6262
// Assert
63-
await Assert.That(json).Contains("\"publicationDate\":\"2008-08-01\"");
63+
_ = await Assert.That(json).Contains("\"publicationDate\":\"2008-08-01\"");
6464
}
6565

6666
[Test]
@@ -74,8 +74,8 @@ public async Task Enum_Should_Serialize_As_String_Not_Integer()
7474
var json = JsonSerializer.Serialize(testObject, _options.Value);
7575

7676
// Assert
77-
await Assert.That(json).Contains("\"status\":\"active\""); // camelCase enum value
78-
await Assert.That(json).DoesNotContain("\"status\":0");
77+
_ = await Assert.That(json).Contains("\"status\":\"active\""); // camelCase enum value
78+
_ = await Assert.That(json).DoesNotContain("\"status\":0");
7979
}
8080

8181
[Test]
@@ -95,14 +95,14 @@ public async Task Properties_Should_Use_CamelCase()
9595
var json = JsonSerializer.Serialize(testObject, _options.Value);
9696

9797
// Assert
98-
await Assert.That(json).Contains("\"bookId\":");
99-
await Assert.That(json).Contains("\"bookTitle\":");
100-
await Assert.That(json).Contains("\"publicationDate\":");
101-
await Assert.That(json).Contains("\"lastModified\":");
98+
_ = await Assert.That(json).Contains("\"bookId\":");
99+
_ = await Assert.That(json).Contains("\"bookTitle\":");
100+
_ = await Assert.That(json).Contains("\"publicationDate\":");
101+
_ = await Assert.That(json).Contains("\"lastModified\":");
102102

103103
// Should NOT contain PascalCase
104-
await Assert.That(json).DoesNotContain("\"BookId\":");
105-
await Assert.That(json).DoesNotContain("\"BookTitle\":");
104+
_ = await Assert.That(json).DoesNotContain("\"BookId\":");
105+
_ = await Assert.That(json).DoesNotContain("\"BookTitle\":");
106106
}
107107

108108
[Test]
@@ -124,15 +124,15 @@ public async Task Complex_Object_Should_Follow_All_Standards()
124124

125125
// Assert
126126
// camelCase properties
127-
await Assert.That(json).Contains("\"bookId\":");
128-
await Assert.That(json).Contains("\"bookTitle\":");
127+
_ = await Assert.That(json).Contains("\"bookId\":");
128+
_ = await Assert.That(json).Contains("\"bookTitle\":");
129129

130130
// ISO 8601 dates
131-
await Assert.That(json).Contains("\"publicationDate\":\"2008-08-01\"");
132-
await Assert.That(json).Contains("\"lastModified\":\"2025-12-26T17:16:09+00:00\"");
131+
_ = await Assert.That(json).Contains("\"publicationDate\":\"2008-08-01\"");
132+
_ = await Assert.That(json).Contains("\"lastModified\":\"2025-12-26T17:16:09+00:00\"");
133133

134134
// Enum as string
135-
await Assert.That(json).Contains("\"status\":\"active\"");
135+
_ = await Assert.That(json).Contains("\"status\":\"active\"");
136136
}
137137

138138
// Test DTOs

0 commit comments

Comments
 (0)