Skip to content

Commit 6893a5a

Browse files
committed
.Net 10
1 parent cc7bd17 commit 6893a5a

4 files changed

Lines changed: 69 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"Street": "123 Main St",
3+
"xxx": {
4+
"Lat": 40.7128,
5+
"Lng": -74.006
6+
}
7+
}
8+
{
9+
"JsonComplexOwnedTypeOrderId": null,
10+
"Street": "123 Main St",
11+
"xxx": {
12+
"OwnedTypeAddressJsonComplexOwnedTypeOrderId": null,
13+
"Lat": 40.7128,
14+
"Lng": -74.006
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"Street": "123 Main St",
3+
"xxx": {
4+
"Lat": 40.7128,
5+
"Lng": -74.006
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"JsonOwnedTypeOrderId": null,
3+
"Street": "123 Main St",
4+
"xxx": {
5+
"OwnedTypeAddressJsonOwnedTypeOrderId": null,
6+
"Lat": 40.7128,
7+
"Lng": -74.006
8+
}
9+
}

src/EntityFrameworkCore.SqlServer.SimpleBulks.Tests/DbContextExtensions/GetPropertiesTests.cs

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public void GetProperties_ComplexOwnedType_ReturnsCorrectColumnInformation()
253253
}
254254

255255
[Fact]
256-
public void GetProperties_JsonComplexType_ReturnsCorrectColumnInformation()
256+
public Task GetProperties_JsonComplexType_ReturnsCorrectColumnInformation()
257257
{
258258
// Arrange
259259
var dbContext = new TestDbContext("", "");
@@ -335,19 +335,21 @@ public void GetProperties_JsonComplexType_ReturnsCorrectColumnInformation()
335335
}
336336
};
337337

338-
var json = JsonPropertyWriter.Write(testOrder, flattenedJsonProperties);
338+
var json = JsonPropertyWriter.Write(testOrder, flattenedJsonProperties, indented: true);
339339
Assert.NotNull(json);
340340
Assert.Contains("Street", json);
341341
Assert.Contains("123 Main St", json);
342342
Assert.Contains("xxx", json); // Location is mapped to "xxx"
343343
Assert.Contains("Lat", json);
344344
Assert.Contains("Lng", json);
345+
346+
return Verify(json);
345347
}
346348

347349

348350

349351
[Fact]
350-
public void GetProperties_JsonOwnedType_ReturnsCorrectColumnInformation()
352+
public Task GetProperties_JsonOwnedType_ReturnsCorrectColumnInformation()
351353
{
352354
// Arrange
353355
var dbContext = new TestDbContext("", "");
@@ -428,17 +430,19 @@ public void GetProperties_JsonOwnedType_ReturnsCorrectColumnInformation()
428430
}
429431
};
430432

431-
var json = JsonPropertyWriter.Write(testOrder, flattenedJsonProperties);
433+
var json = JsonPropertyWriter.Write(testOrder, flattenedJsonProperties, indented: true);
432434
Assert.NotNull(json);
433435
Assert.Contains("Street", json);
434436
Assert.Contains("123 Main St", json);
435437
Assert.Contains("xxx", json); // Location is mapped to "xxx"
436438
Assert.Contains("Lat", json);
437439
Assert.Contains("Lng", json);
440+
441+
return Verify(json);
438442
}
439443

440444
[Fact]
441-
public void GetProperties_JsonComplexOwnedType_ReturnsCorrectColumnInformation()
445+
public Task GetProperties_JsonComplexOwnedType_ReturnsCorrectColumnInformation()
442446
{
443447
// Arrange
444448
var dbContext = new TestDbContext("", "");
@@ -504,28 +508,6 @@ public void GetProperties_JsonComplexOwnedType_ReturnsCorrectColumnInformation()
504508
Assert.Equal("ComplexShippingAddress.Location.Lng", lngWriter.FullClrPropertyName);
505509
Assert.Equal(typeof(double), lngWriter.PropertyType);
506510

507-
// Verify serialization using JsonProperties
508-
var testOrder = new JsonComplexOwnedTypeOrder
509-
{
510-
Id = 1,
511-
ComplexShippingAddress = new ComplexTypeAddress
512-
{
513-
Street = "123 Main St",
514-
Location = new ComplexTypeLocation
515-
{
516-
Lat = 40.7128,
517-
Lng = -74.0060
518-
}
519-
}
520-
};
521-
522-
var json = JsonPropertyWriter.Write(testOrder, flattenedJsonProperties);
523-
Assert.NotNull(json);
524-
Assert.Contains("Street", json);
525-
Assert.Contains("123 Main St", json);
526-
Assert.Contains("xxx", json); // Location is mapped to "xxx"
527-
Assert.Contains("Lat", json);
528-
Assert.Contains("Lng", json);
529511

530512
property = properties.First(p => p.PropertyName == "OwnedShippingAddress");
531513
Assert.Equal(typeof(OwnedTypeAddress), property.PropertyType);
@@ -573,10 +555,20 @@ public void GetProperties_JsonComplexOwnedType_ReturnsCorrectColumnInformation()
573555
Assert.Equal("OwnedShippingAddress.Location.Lng", lngWriter.FullClrPropertyName);
574556
Assert.Equal(typeof(double), lngWriter.PropertyType);
575557

558+
576559
// Verify serialization using JsonProperties
577-
testOrder = new JsonComplexOwnedTypeOrder
560+
var testOrder = new JsonComplexOwnedTypeOrder
578561
{
579562
Id = 1,
563+
ComplexShippingAddress = new ComplexTypeAddress
564+
{
565+
Street = "123 Main St",
566+
Location = new ComplexTypeLocation
567+
{
568+
Lat = 40.7128,
569+
Lng = -74.0060
570+
}
571+
},
580572
OwnedShippingAddress = new OwnedTypeAddress
581573
{
582574
Street = "123 Main St",
@@ -588,12 +580,22 @@ public void GetProperties_JsonComplexOwnedType_ReturnsCorrectColumnInformation()
588580
}
589581
};
590582

591-
json = JsonPropertyWriter.Write(testOrder, flattenedJsonProperties);
592-
Assert.NotNull(json);
593-
Assert.Contains("Street", json);
594-
Assert.Contains("123 Main St", json);
595-
Assert.Contains("xxx", json); // Location is mapped to "xxx"
596-
Assert.Contains("Lat", json);
597-
Assert.Contains("Lng", json);
583+
var json1 = JsonPropertyWriter.Write(testOrder, properties.First(p => p.PropertyName == "ComplexShippingAddress").FlattenedJsonProperties, indented: true);
584+
Assert.NotNull(json1);
585+
Assert.Contains("Street", json1);
586+
Assert.Contains("123 Main St", json1);
587+
Assert.Contains("xxx", json1); // Location is mapped to "xxx"
588+
Assert.Contains("Lat", json1);
589+
Assert.Contains("Lng", json1);
590+
591+
var json2 = JsonPropertyWriter.Write(testOrder, properties.First(p => p.PropertyName == "OwnedShippingAddress").FlattenedJsonProperties, indented: true);
592+
Assert.NotNull(json2);
593+
Assert.Contains("Street", json2);
594+
Assert.Contains("123 Main St", json2);
595+
Assert.Contains("xxx", json2); // Location is mapped to "xxx"
596+
Assert.Contains("Lat", json2);
597+
Assert.Contains("Lng", json2);
598+
599+
return Verify(json1 + Environment.NewLine + json2);
598600
}
599601
}

0 commit comments

Comments
 (0)