Skip to content

Commit 274e78c

Browse files
Undo bad merge conflict resolution
1 parent 989eebf commit 274e78c

1 file changed

Lines changed: 39 additions & 39 deletions

File tree

EssentialCSharp.Web.Tests/ListingSourceCodeControllerTests.cs

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,104 +4,104 @@
44

55
namespace EssentialCSharp.Web.Tests;
66

7-
public class ListingSourceCodeControllerTests
7+
[ClassDataSource<WebApplicationFactory>(Shared = SharedType.PerClass)]
8+
public class ListingSourceCodeControllerTests(WebApplicationFactory factory)
89
{
9-
[Fact]
10+
[Test]
1011
public async Task GetListing_WithValidChapterAndListing_Returns200WithContent()
1112
{
1213
// Arrange
13-
using WebApplicationFactory factory = new();
1414
HttpClient client = factory.CreateClient();
1515

1616
// Act
1717
using HttpResponseMessage response = await client.GetAsync("/api/ListingSourceCode/chapter/1/listing/1");
1818

1919
// Assert
20-
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
21-
20+
await Assert.That(response.StatusCode).IsEqualTo(HttpStatusCode.OK);
21+
2222
ListingSourceCodeResponse? result = await response.Content.ReadFromJsonAsync<ListingSourceCodeResponse>();
23-
Assert.NotNull(result);
24-
Assert.Equal(1, result.ChapterNumber);
25-
Assert.Equal(1, result.ListingNumber);
26-
Assert.NotEmpty(result.FileExtension);
27-
Assert.NotEmpty(result.Content);
23+
await Assert.That(result).IsNotNull();
24+
using (Assert.Multiple())
25+
{
26+
await Assert.That(result.ChapterNumber).IsEqualTo(1);
27+
await Assert.That(result.ListingNumber).IsEqualTo(1);
28+
await Assert.That(result.FileExtension).IsNotEmpty();
29+
await Assert.That(result.Content).IsNotEmpty();
30+
}
2831
}
2932

3033

31-
[Fact]
34+
[Test]
3235
public async Task GetListing_WithInvalidChapter_Returns404()
3336
{
3437
// Arrange
35-
using WebApplicationFactory factory = new();
3638
HttpClient client = factory.CreateClient();
3739

3840
// Act
3941
using HttpResponseMessage response = await client.GetAsync("/api/ListingSourceCode/chapter/999/listing/1");
4042

4143
// Assert
42-
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
44+
await Assert.That(response.StatusCode).IsEqualTo(HttpStatusCode.NotFound);
4345
}
4446

45-
[Fact]
47+
[Test]
4648
public async Task GetListing_WithInvalidListing_Returns404()
4749
{
4850
// Arrange
49-
using WebApplicationFactory factory = new();
5051
HttpClient client = factory.CreateClient();
5152

5253
// Act
5354
using HttpResponseMessage response = await client.GetAsync("/api/ListingSourceCode/chapter/1/listing/999");
5455

5556
// Assert
56-
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
57+
await Assert.That(response.StatusCode).IsEqualTo(HttpStatusCode.NotFound);
5758
}
5859

59-
[Fact]
60+
[Test]
6061
public async Task GetListingsByChapter_WithValidChapter_ReturnsMultipleListings()
6162
{
6263
// Arrange
63-
using WebApplicationFactory factory = new();
6464
HttpClient client = factory.CreateClient();
6565

6666
// Act
6767
using HttpResponseMessage response = await client.GetAsync("/api/ListingSourceCode/chapter/1");
6868

6969
// Assert
70-
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
71-
70+
await Assert.That(response.StatusCode).IsEqualTo(HttpStatusCode.OK);
71+
7272
List<ListingSourceCodeResponse>? results = await response.Content.ReadFromJsonAsync<List<ListingSourceCodeResponse>>();
73-
Assert.NotNull(results);
74-
Assert.NotEmpty(results);
75-
76-
// Verify all results are from chapter 1
77-
Assert.All(results, r => Assert.Equal(1, r.ChapterNumber));
78-
73+
await Assert.That(results).IsNotNull();
74+
await Assert.That(results).IsNotEmpty();
75+
7976
// Verify results are ordered by listing number
80-
Assert.Equal(results.OrderBy(r => r.ListingNumber).ToList(), results);
81-
82-
// Verify each listing has required properties
83-
Assert.All(results, r =>
77+
await Assert.That(results).IsOrderedBy(r => r.ListingNumber);
78+
79+
// Verify all results are from chapter 1 and have required properties
80+
foreach (var r in results)
8481
{
85-
Assert.NotEmpty(r.FileExtension);
86-
Assert.NotEmpty(r.Content);
87-
});
82+
using (Assert.Multiple())
83+
{
84+
await Assert.That(r.ChapterNumber).IsEqualTo(1);
85+
await Assert.That(r.FileExtension).IsNotEmpty();
86+
await Assert.That(r.Content).IsNotEmpty();
87+
}
88+
}
8889
}
8990

90-
[Fact]
91+
[Test]
9192
public async Task GetListingsByChapter_WithInvalidChapter_ReturnsEmptyList()
9293
{
9394
// Arrange
94-
using WebApplicationFactory factory = new();
9595
HttpClient client = factory.CreateClient();
9696

9797
// Act
9898
using HttpResponseMessage response = await client.GetAsync("/api/ListingSourceCode/chapter/999");
9999

100100
// Assert
101-
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
102-
101+
await Assert.That(response.StatusCode).IsEqualTo(HttpStatusCode.OK);
102+
103103
List<ListingSourceCodeResponse>? results = await response.Content.ReadFromJsonAsync<List<ListingSourceCodeResponse>>();
104-
Assert.NotNull(results);
105-
Assert.Empty(results);
104+
await Assert.That(results).IsNotNull();
105+
await Assert.That(results).IsEmpty();
106106
}
107107
}

0 commit comments

Comments
 (0)