File tree Expand file tree Collapse file tree 3 files changed +50
-1
lines changed
src/DendroDocs.Shared/Descriptions
tests/DendroDocs.Shared.Tests/Serialization Expand file tree Collapse file tree 3 files changed +50
-1
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,8 @@ public TypeDescription(
16
16
IReadOnlyList < MethodDescription > methods ,
17
17
IReadOnlyList < EnumMemberDescription > enumMembers ,
18
18
IReadOnlyList < EventDescription > events ,
19
- List < AttributeDescription > attributes
19
+ List < AttributeDescription > attributes ,
20
+ List < string > baseTypes
20
21
)
21
22
: this ( type , fullName )
22
23
{
@@ -27,6 +28,7 @@ List<AttributeDescription> attributes
27
28
if ( enumMembers is not null ) this . enumMembers = [ .. enumMembers ] ;
28
29
if ( events is not null ) this . events = [ .. events ] ;
29
30
if ( attributes is not null ) this . Attributes . AddRange ( attributes ) ;
31
+ if ( baseTypes is not null ) this . BaseTypes . AddRange ( baseTypes ) ;
30
32
}
31
33
32
34
[ Newtonsoft . Json . JsonProperty ( Order = 1 , PropertyName = nameof ( Fields ) ) ]
Original file line number Diff line number Diff line change @@ -369,4 +369,26 @@ public void AStatementInASwitchSectionShouldHaveTheSwitchSectionAsParent()
369
369
var @switch = ( Switch ) types [ 0 ] . Methods [ 0 ] . Statements [ 0 ] ;
370
370
@switch . Sections [ 0 ] . Statements [ 0 ] . Parent . ShouldBe ( @switch . Sections [ 0 ] ) ;
371
371
}
372
+
373
+ [ TestMethod ]
374
+ public void BaseTypes_Should_BeDeserializedCorrectly ( )
375
+ {
376
+ // Assign
377
+ var json = @"[{
378
+ ""FullName"": ""Pitstop.TimeService.Events.DayHasPassed"",
379
+ ""BaseTypes"": [
380
+ ""Pitstop.Infrastructure.Messaging.Event"",
381
+ ""System.Object""
382
+ ]
383
+ }]" ;
384
+
385
+ // Act
386
+ var types = JsonConvert . DeserializeObject < List < TypeDescription > > ( json , JsonDefaults . DeserializerSettings ( ) ) ! ;
387
+
388
+ // Assert
389
+ types . Count . ShouldBe ( 1 ) ;
390
+ types [ 0 ] . BaseTypes . Count . ShouldBe ( 2 ) ;
391
+ types [ 0 ] . BaseTypes . ShouldContain ( "Pitstop.Infrastructure.Messaging.Event" ) ;
392
+ types [ 0 ] . BaseTypes . ShouldContain ( "System.Object" ) ;
393
+ }
372
394
}
Original file line number Diff line number Diff line change @@ -455,4 +455,29 @@ public void MethodWithoutReturnTypeInJson_Should_DefaultToVoid()
455
455
types [ 0 ] . Methods [ 0 ] . Name . ShouldBe ( "VoidMethod" ) ;
456
456
types [ 0 ] . Methods [ 0 ] . ReturnType . ShouldBe ( "void" ) ;
457
457
}
458
+
459
+ [ TestMethod ]
460
+ public void BaseTypes_Should_BeDeserializedCorrectly ( )
461
+ {
462
+ // Assign
463
+ var json =
464
+ """
465
+ [{
466
+ "FullName": "Pitstop.TimeService.Events.DayHasPassed",
467
+ "BaseTypes": [
468
+ "Pitstop.Infrastructure.Messaging.Event",
469
+ "System.Object"
470
+ ]
471
+ }]
472
+ """ ;
473
+
474
+ // Act
475
+ var types = JsonSerializer . Deserialize < List < TypeDescription > > ( json , JsonDefaults . DeserializerOptions ( ) ) ! ;
476
+
477
+ // Assert
478
+ types . Count . ShouldBe ( 1 ) ;
479
+ types [ 0 ] . BaseTypes . Count . ShouldBe ( 2 ) ;
480
+ types [ 0 ] . BaseTypes . ShouldContain ( "Pitstop.Infrastructure.Messaging.Event" ) ;
481
+ types [ 0 ] . BaseTypes . ShouldContain ( "System.Object" ) ;
482
+ }
458
483
}
You can’t perform that action at this time.
0 commit comments