@@ -104,9 +104,9 @@ public void MultipleHashSetsAtSameLevelShouldBeClonedCorrectly()
104104 // Arrange
105105 HashSetContainer container = new HashSetContainer
106106 {
107- Set1 = new HashSet < KeyClass > ( ) ,
108- Set2 = new HashSet < KeyClass > ( ) ,
109- Set3 = new HashSet < KeyClass > ( )
107+ Set1 = [ ] ,
108+ Set2 = [ ] ,
109+ Set3 = [ ]
110110 } ;
111111
112112 KeyClass item1 = new KeyClass { Value = "Item1" } ;
@@ -211,7 +211,7 @@ public void NestedDictionariesShouldBeClonedCorrectly()
211211 public void SetBrokenAfterCloningTest ( )
212212 {
213213 // Arrange
214- HashSet < KeyClass > originalSet = new HashSet < KeyClass > ( ) ;
214+ HashSet < KeyClass > originalSet = [ ] ;
215215 KeyClass key = new KeyClass { Value = "TestKey" } ;
216216 originalSet . Add ( key ) ;
217217
@@ -229,6 +229,14 @@ public void SetBrokenAfterCloningTest()
229229 Assert . That ( clonedKey . Value is "TestKey" , Is . True ) ;
230230 } ) ;
231231 }
232+
233+ [ Test ]
234+ public void CanCopyTypes ( )
235+ {
236+ Type original = typeof ( string ) ;
237+ Type result = original . DeepClone ( ) ;
238+ Assert . That ( original , Is . EqualTo ( result ) ) ;
239+ }
232240
233241 [ Test ]
234242 public void OrderedDictionaryBrokenAfterCloningTest ( )
@@ -307,14 +315,14 @@ public void SingleGenericDictionaryCloneTest()
307315 // Assert
308316 Assert . Multiple ( ( ) =>
309317 {
310- Assert . That ( ReferenceEquals ( key , clonedKey ) , Is . False , "Klíč by měl být nová instance" ) ;
311- Assert . That ( key . Value , Is . EqualTo ( clonedKey . Value ) , "Hodnota klíče by měla být zachována" ) ;
318+ Assert . That ( ReferenceEquals ( key , clonedKey ) , Is . False ) ;
319+ Assert . That ( key . Value , Is . EqualTo ( clonedKey . Value ) ) ;
312320
313- Assert . That ( originalDict . Count , Is . EqualTo ( clonedDict . Count ) , "Počet položek by měl být stejný" ) ;
314- Assert . That ( clonedDict . Contains ( clonedKvp ) , Is . True , "Naklonovaný slovník by měl obsahovat naklonovanou KeyValuePair" ) ;
321+ Assert . That ( originalDict . Count , Is . EqualTo ( clonedDict . Count ) ) ;
322+ Assert . That ( clonedDict . Contains ( clonedKvp ) , Is . True ) ;
315323
316- Assert . That ( clonedKey . Value , Is . EqualTo ( "TestKey" ) , "Hodnota klíče by měla být zachována" ) ;
317- Assert . That ( clonedKvp . Value , Is . EqualTo ( "TestValue" ) , "Hodnota by měla být zachována" ) ;
324+ Assert . That ( clonedKey . Value , Is . EqualTo ( "TestKey" ) ) ;
325+ Assert . That ( clonedKvp . Value , Is . EqualTo ( "TestValue" ) ) ;
318326 } ) ;
319327 }
320328
@@ -463,14 +471,12 @@ public void Descendant_Class_Should_Be_Cloned(bool isDeep)
463471 D = 42.3m
464472 } ;
465473
466- C2 cToRef = cTo ;
467-
468474 if ( isDeep )
469475 cFrom . DeepCloneTo ( cTo ) ;
470476 else
471477 cFrom . ShallowCloneTo ( cTo ) ;
472478
473- Assert . That ( ReferenceEquals ( cTo , cToRef ) , Is . True ) ;
479+ Assert . That ( ReferenceEquals ( cTo , cTo ) , Is . True ) ;
474480 Assert . That ( cTo . A , Is . EqualTo ( 11 ) ) ;
475481 Assert . That ( ( ( C1 ) cTo ) . A , Is . EqualTo ( 12 ) ) ;
476482 Assert . That ( cTo . D , Is . EqualTo ( 42.3m ) ) ;
@@ -545,7 +551,7 @@ public void Struct_As_Interface_ShouldNot_Be_Cloned(bool isDeep)
545551 {
546552 S1 sFrom = new S1 { A = 42 } ;
547553 S1 sTo = new S1 ( ) ;
548- I1 ? objTo = ( I1 ) sTo ;
554+ I1 ? objTo = sTo ;
549555 objTo . A = 23 ;
550556 if ( isDeep )
551557 // ReSharper disable once ExpressionIsAlwaysNull
@@ -568,8 +574,8 @@ public void String_Should_Not_Be_Cloned()
568574 [ TestCase ( true ) ]
569575 public void Array_Should_Be_Cloned_Correct_Size ( bool isDeep )
570576 {
571- int [ ] arrFrom = new [ ] { 1 , 2 , 3 } ;
572- int [ ] arrTo = new [ ] { 4 , 5 , 6 } ;
577+ int [ ] arrFrom = [ 1 , 2 , 3 ] ;
578+ int [ ] arrTo = [ 4 , 5 , 6 ] ;
573579 if ( isDeep ) arrFrom . DeepCloneTo ( arrTo ) ;
574580 else arrFrom . ShallowCloneTo ( arrTo ) ;
575581 Assert . That ( arrTo . Length , Is . EqualTo ( 3 ) ) ;
@@ -583,8 +589,8 @@ public void Array_Should_Be_Cloned_Correct_Size(bool isDeep)
583589 [ TestCase ( true ) ]
584590 public void Array_Should_Be_Cloned_From_Is_Bigger ( bool isDeep )
585591 {
586- int [ ] arrFrom = new [ ] { 1 , 2 , 3 } ;
587- int [ ] arrTo = new [ ] { 4 , 5 } ;
592+ int [ ] arrFrom = [ 1 , 2 , 3 ] ;
593+ int [ ] arrTo = [ 4 , 5 ] ;
588594 if ( isDeep ) arrFrom . DeepCloneTo ( arrTo ) ;
589595 else arrFrom . ShallowCloneTo ( arrTo ) ;
590596 Assert . That ( arrTo . Length , Is . EqualTo ( 2 ) ) ;
@@ -597,8 +603,8 @@ public void Array_Should_Be_Cloned_From_Is_Bigger(bool isDeep)
597603 [ TestCase ( true ) ]
598604 public void Array_Should_Be_Cloned_From_Is_Smaller ( bool isDeep )
599605 {
600- int [ ] arrFrom = new [ ] { 1 , 2 } ;
601- int [ ] arrTo = new [ ] { 4 , 5 , 6 } ;
606+ int [ ] arrFrom = [ 1 , 2 ] ;
607+ int [ ] arrTo = [ 4 , 5 , 6 ] ;
602608 if ( isDeep ) arrFrom . DeepCloneTo ( arrTo ) ;
603609 else arrFrom . ShallowCloneTo ( arrTo ) ;
604610 Assert . That ( arrTo . Length , Is . EqualTo ( 3 ) ) ;
@@ -611,7 +617,7 @@ public void Array_Should_Be_Cloned_From_Is_Smaller(bool isDeep)
611617 public void Shallow_Array_Should_Be_Cloned ( )
612618 {
613619 C1 c1 = new C1 ( ) ;
614- C1 [ ] arrFrom = new [ ] { c1 , c1 , c1 } ;
620+ C1 [ ] arrFrom = [ c1 , c1 , c1 ] ;
615621 C1 [ ] arrTo = new C1 [ 4 ] ;
616622 arrFrom . ShallowCloneTo ( arrTo ) ;
617623 Assert . That ( arrTo . Length , Is . EqualTo ( 4 ) ) ;
@@ -626,7 +632,7 @@ public void Deep_Array_Should_Be_Cloned()
626632 {
627633 C4 c1 = new C4 ( ) ;
628634 C3 c3 = new C3 { A = c1 , B = c1 } ;
629- C3 [ ] arrFrom = new [ ] { c3 , c3 , c3 } ;
635+ C3 [ ] arrFrom = [ c3 , c3 , c3 ] ;
630636 C3 [ ] arrTo = new C3 [ 4 ] ;
631637 arrFrom . DeepCloneTo ( arrTo ) ;
632638 Assert . That ( arrTo . Length , Is . EqualTo ( 4 ) ) ;
@@ -686,7 +692,7 @@ public void MultiDim_Array_Should_Be_Cloned(bool isDeep)
686692 [ TestCase ( true ) ]
687693 public void TwoDim_Array_Should_Be_Cloned ( bool isDeep )
688694 {
689- int [ , ] arrFrom = new [ , ] { { 1 , 2 } , { 3 , 4 } } ;
695+ int [ , ] arrFrom = { { 1 , 2 } , { 3 , 4 } } ;
690696 // with offset. its ok
691697 int [ , ] arrTo = new int [ 3 , 1 ] ;
692698 if ( isDeep ) arrFrom . DeepCloneTo ( arrTo ) ;
@@ -741,7 +747,7 @@ public void MultiDimensional_Array_Should_Be_Cloned()
741747 public void Shallow_Clone_Of_MultiDim_Array_Should_Not_Perform_Deep ( )
742748 {
743749 C1 c1 = new C1 ( ) ;
744- C1 [ , ] arrFrom = new [ , ] { { c1 , c1 } , { c1 , c1 } } ;
750+ C1 [ , ] arrFrom = { { c1 , c1 } , { c1 , c1 } } ;
745751 // with offset. its ok
746752 C1 [ , ] arrTo = new C1 [ 3 , 1 ] ;
747753 arrFrom . ShallowCloneTo ( arrTo ) ;
@@ -759,7 +765,7 @@ public void Shallow_Clone_Of_MultiDim_Array_Should_Not_Perform_Deep()
759765 public void Deep_Clone_Of_MultiDim_Array_Should_Perform_Deep ( )
760766 {
761767 C1 c1 = new C1 ( ) ;
762- C1 [ , ] arrFrom = new [ , ] { { c1 , c1 } , { c1 , c1 } } ;
768+ C1 [ , ] arrFrom = { { c1 , c1 } , { c1 , c1 } } ;
763769 // with offset. its ok
764770 C1 [ , ] arrTo = new C1 [ 3 , 1 ] ;
765771 arrFrom . DeepCloneTo ( arrTo ) ;
0 commit comments