@@ -701,6 +701,104 @@ public async Task Deserialize_FlattenedCollection_CollectsAllMatchingNodes()
701701 await Assert . That ( result . FlattenedServers [ 1 ] . Host ) . IsEqualTo ( "remote" ) ;
702702 }
703703
704+ [ Test ]
705+ public async Task Serialize_WithSimpleCollectionNodeNames_True_UseDashNodeNames ( )
706+ {
707+ // Arrange
708+ var model = new CollectionModel
709+ {
710+ WrappedPlugins = [ new ( ) { Name = "Auth" } ] ,
711+ FlattenedServers = [ new ( ) { Host = "localhost" } ] ,
712+ } ;
713+
714+ var options = new KdlSerializerOptions { SimpleCollectionNodeNames = true } ;
715+
716+ // Act
717+ var kdl = KdlSerializer . Serialize ( model , options ) ;
718+
719+ // Assert - should use dash (-) for collection items
720+ await Assert . That ( kdl ) . Contains ( "plugins {" ) ;
721+ await Assert . That ( kdl ) . Contains ( "- Auth" ) ;
722+ }
723+
724+ [ Test ]
725+ public async Task Serialize_WithSimpleCollectionNodeNames_False_UseTypedNodeNames ( )
726+ {
727+ // Arrange
728+ var model = new CollectionModel
729+ {
730+ WrappedPlugins = [ new ( ) { Name = "Auth" } ] ,
731+ FlattenedServers = [ new ( ) { Host = "localhost" } ] ,
732+ } ;
733+
734+ var options = new KdlSerializerOptions { SimpleCollectionNodeNames = false } ;
735+
736+ // Act
737+ var kdl = KdlSerializer . Serialize ( model , options ) ;
738+
739+ // Assert - should use typed node names
740+ await Assert . That ( kdl ) . Contains ( "plugins {" ) ;
741+ await Assert . That ( kdl ) . Contains ( "plugin-info Auth" ) ;
742+ }
743+
744+ [ Test ]
745+ public async Task RoundTrip_SerializeAndDeserialize_WithSimpleCollectionNodeNames_True ( )
746+ {
747+ // Arrange
748+ var originalModel = new CollectionModel
749+ {
750+ WrappedPlugins = [ new ( ) { Name = "Auth" } , new ( ) { Name = "Logging" } ] ,
751+ FlattenedServers = [ new ( ) { Host = "localhost" } , new ( ) { Host = "remote" } ] ,
752+ } ;
753+
754+ var options = new KdlSerializerOptions
755+ {
756+ SimpleCollectionNodeNames = true ,
757+ UnwrapRoot = true ,
758+ } ;
759+
760+ // Act
761+ var kdl = KdlSerializer . Serialize ( originalModel , options ) ;
762+ var deserializedModel = KdlSerializer . Deserialize < CollectionModel > ( kdl , options ) ;
763+
764+ // Assert
765+ await Assert . That ( deserializedModel . WrappedPlugins ) . Count ( ) . IsEqualTo ( 2 ) ;
766+ await Assert . That ( deserializedModel . WrappedPlugins [ 0 ] . Name ) . IsEqualTo ( "Auth" ) ;
767+ await Assert . That ( deserializedModel . WrappedPlugins [ 1 ] . Name ) . IsEqualTo ( "Logging" ) ;
768+ await Assert . That ( deserializedModel . FlattenedServers ) . Count ( ) . IsEqualTo ( 2 ) ;
769+ await Assert . That ( deserializedModel . FlattenedServers [ 0 ] . Host ) . IsEqualTo ( "localhost" ) ;
770+ await Assert . That ( deserializedModel . FlattenedServers [ 1 ] . Host ) . IsEqualTo ( "remote" ) ;
771+ }
772+
773+ [ Test ]
774+ public async Task RoundTrip_SerializeAndDeserialize_WithSimpleCollectionNodeNames_False ( )
775+ {
776+ // Arrange
777+ var originalModel = new CollectionModel
778+ {
779+ WrappedPlugins = [ new ( ) { Name = "Auth" } , new ( ) { Name = "Logging" } ] ,
780+ FlattenedServers = [ new ( ) { Host = "localhost" } , new ( ) { Host = "remote" } ] ,
781+ } ;
782+
783+ var options = new KdlSerializerOptions
784+ {
785+ SimpleCollectionNodeNames = false ,
786+ UnwrapRoot = false ,
787+ } ;
788+
789+ // Act
790+ var kdl = KdlSerializer . Serialize ( originalModel , options ) ;
791+ var deserializedModel = KdlSerializer . Deserialize < CollectionModel > ( kdl , options ) ;
792+
793+ // Assert
794+ await Assert . That ( deserializedModel . WrappedPlugins ) . Count ( ) . IsEqualTo ( 2 ) ;
795+ await Assert . That ( deserializedModel . WrappedPlugins [ 0 ] . Name ) . IsEqualTo ( "Auth" ) ;
796+ await Assert . That ( deserializedModel . WrappedPlugins [ 1 ] . Name ) . IsEqualTo ( "Logging" ) ;
797+ await Assert . That ( deserializedModel . FlattenedServers ) . Count ( ) . IsEqualTo ( 2 ) ;
798+ await Assert . That ( deserializedModel . FlattenedServers [ 0 ] . Host ) . IsEqualTo ( "localhost" ) ;
799+ await Assert . That ( deserializedModel . FlattenedServers [ 1 ] . Host ) . IsEqualTo ( "remote" ) ;
800+ }
801+
704802 #endregion
705803
706804 #region Test Models
0 commit comments