@@ -81,12 +81,13 @@ public void Constructor_String_Parameter_Ok(int length) {
8181 public void FromCharArray_Null_CharArray_ArgumentNullException ( ) {
8282 // Arrange
8383 char [ ] value = null ! ;
84+ static Polyline New ( char [ ] value ) => Polyline . FromCharArray ( value ) ;
8485
8586 // Act
86- static Polyline New ( char [ ] value ) => Polyline . FromCharArray ( value ) ;
87+ var exception = Assert . ThrowsExactly < ArgumentNullException > ( ( ) => New ( value ) ) ;
8788
8889 // Assert
89- Assert . ThrowsExactly < ArgumentNullException > ( ( ) => New ( value ) ) ;
90+
9091 }
9192
9293 /// <summary>
@@ -210,7 +211,7 @@ public void ToString_Equals_Constructor_Parameter(int size) {
210211 /// <param name="value">The string value.</param>
211212 [ TestMethod ]
212213 [ DynamicData ( nameof ( LengthParameters ) ) ]
213- public void ToCharArray_Equals_Constructor_Parameter ( int size ) {
214+ public void CopyTo_Equals_Expected_Value ( int size ) {
214215 // Arrange
215216 Polyline polyline = Polyline . FromString ( RandomValueProvider . GetPolyline ( size ) ) ;
216217 char [ ] expected = RandomValueProvider . GetPolyline ( size ) . ToCharArray ( ) ;
@@ -222,4 +223,42 @@ public void ToCharArray_Equals_Constructor_Parameter(int size) {
222223 // Assert
223224 CollectionAssert . AreEqual ( expected , result ) ;
224225 }
226+
227+ /// <summary>
228+ /// Tests the <see cref="Polyline.ToCharArray"/> method.
229+ /// </summary>
230+ /// <param name="value">The string value.</param>
231+ [ TestMethod ]
232+ [ DynamicData ( nameof ( LengthParameters ) ) ]
233+ public void CopyTo_Smaller_Array_Destination_Parameter_Throws_ArgumentException ( int size ) {
234+ // Arrange
235+ Polyline polyline = Polyline . FromString ( RandomValueProvider . GetPolyline ( size ) ) ;
236+ char [ ] destination = new char [ polyline . Length - 1 ] ;
237+ void CopyTo ( ) => polyline . CopyTo ( destination ) ;
238+
239+ // Act
240+ var exception = Assert . ThrowsExactly < ArgumentException > ( CopyTo ) ;
241+
242+ // Assert
243+ Assert . IsFalse ( string . IsNullOrWhiteSpace ( exception . Message ) ) ;
244+ }
245+
246+ /// <summary>
247+ /// Tests the <see cref="Polyline.ToCharArray"/> method.
248+ /// </summary>
249+ /// <param name="value">The string value.</param>
250+ [ TestMethod ]
251+ [ DynamicData ( nameof ( LengthParameters ) ) ]
252+ public void CopyTo_Null_Destination_Parameter_Throws_ArgumentNullException ( int size ) {
253+ // Arrange
254+ Polyline polyline = Polyline . FromString ( RandomValueProvider . GetPolyline ( size ) ) ;
255+ char [ ] destination = null ! ;
256+ void CopyTo ( ) => polyline . CopyTo ( destination ) ;
257+
258+ // Act
259+ var exception = Assert . ThrowsExactly < ArgumentNullException > ( CopyTo ) ;
260+
261+ // Assert
262+ Assert . IsFalse ( string . IsNullOrWhiteSpace ( exception . Message ) ) ;
263+ }
225264}
0 commit comments