Skip to content

Commit 32d4593

Browse files
committed
polyline tests
1 parent 20f83dd commit 32d4593

1 file changed

Lines changed: 148 additions & 148 deletions

File tree

tests/PolylineAlgorithm.Tests/PolylineTest.cs

Lines changed: 148 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -74,152 +74,152 @@ public void Constructor_String_Parameter_Ok(int length) {
7474
Assert.AreEqual(value, result.ToString());
7575
}
7676

77-
///// <summary>
78-
///// Tests the <see cref="Polyline"/> constructor with a null character array, expecting an <see cref="ArgumentNullException"/>.
79-
///// </summary>
80-
//[TestMethod]
81-
//public void Constructor_Null_CharArray_ArgumentNullException() {
82-
// // Arrange
83-
// char[] value = null!;
84-
85-
// // Act
86-
// static Polyline New(char[] value) => Polyline.FromCharArray(value);
87-
88-
// // Assert
89-
// Assert.ThrowsExactly<ArgumentNullException>(() => New(value));
90-
//}
91-
92-
///// <summary>
93-
///// Tests the <see cref="Polyline"/> constructor with a character array parameter.
94-
///// </summary>
95-
///// <param name="value">The string value.</param>
96-
//[TestMethod]
97-
//[DynamicData(nameof(SizeParameters))]
98-
//public void Constructor_CharArray_Parameter_Ok(int size) {
99-
// // Arrange
100-
// var polyline = ValueProvider.GetPolyline(size);
101-
// bool empty = polyline.IsEmpty;
102-
// long length = polyline.Length;
103-
104-
// // Act
105-
// Polyline polyline = Polyline.FromString(value);
106-
107-
// // Assert
108-
// Assert.AreEqual(empty, polyline.IsEmpty);
109-
// Assert.AreEqual(length, polyline.Length);
110-
// //Assert.IsTrue(span.Span.SequenceEqual(polyline.Span.Span));
111-
//}
112-
113-
///// <summary>
114-
///// Tests the <see cref="Polyline"/> constructor with a memory parameter.
115-
///// </summary>
116-
///// <param name="value">The string value.</param>
117-
//[TestMethod]
118-
//[DynamicData(nameof(SizeParameters))]
119-
//public void Constructor_Memory_Parameter_Ok(int size) {
120-
// // Arrange
121-
// var polyline = ValueProvider.GetPolyline(size);
122-
// bool empty = polyline.IsEmpty;
123-
// long length = polyline.Length;
124-
125-
// // Act
126-
// Polyline polyline = Polyline.FromString(value);
127-
128-
// // Assert
129-
// Assert.AreEqual(empty, polyline.IsEmpty);
130-
// Assert.AreEqual(length, polyline.Length);
131-
// //Assert.IsTrue(span.Span.SequenceEqual(polyline.Span.Span));
132-
//}
133-
134-
///// <summary>
135-
///// Tests the <see cref="Polyline.FromString(string)"/> method.
136-
///// </summary>
137-
///// <param name="value">The string value.</param>
138-
//[TestMethod]
139-
//[DynamicData(nameof(SizeParameters))]
140-
//public void FromString_Equals_New(int size) {
141-
// // Arrange
142-
// var polyline = ValueProvider.GetPolyline(size);
143-
// bool empty = polyline.IsEmpty;
144-
// long length = polyline.Length;
145-
146-
// // Act
147-
// Polyline result = Polyline.FromString(value);
148-
149-
// // Assert
150-
// Assert.IsTrue(polyline.Equals(result));
151-
//}
152-
153-
///// <summary>
154-
///// Tests the <see cref="Polyline.FromCharArray(char[])"/> method.
155-
///// </summary>
156-
///// <param name="value">The string value.</param>
157-
//[TestMethod]
158-
//[DynamicData(nameof(SizeParameters))]
159-
//public void FromCharArray_Equals_New(int size) {
160-
// // Arrange
161-
// char[] array = value.ToCharArray();
162-
// Polyline polyline = Polyline.FromCharArray(array);
163-
164-
// // Act
165-
// Polyline result = Polyline.FromCharArray(array);
166-
167-
// // Assert
168-
// Assert.IsTrue(polyline.Equals(result));
169-
//}
170-
171-
///// <summary>
172-
///// Tests the <see cref="Polyline.FromMemory(ReadOnlyMemory{char})"/> method.
173-
///// </summary>
174-
///// <param name="value">The string value.</param>
175-
//[TestMethod]
176-
//[DynamicData(nameof(SizeParameters))]
177-
//public void FromMemory_Equals_New(int size) {
178-
// // Arrange
179-
// ReadOnlyMemory<char> memory = value.AsMemory();
180-
// Polyline polyline = Polyline.FromString(value);
181-
182-
// // Act
183-
// Polyline result = Polyline.FromMemory(memory);
184-
185-
// // Assert
186-
// Assert.IsTrue(polyline.Equals(result));
187-
//}
188-
189-
///// <summary>
190-
///// Tests the <see cref="Polyline.ToString"/> method.
191-
///// </summary>
192-
///// <param name="value">The string value.</param>
193-
//[TestMethod]
194-
//[DynamicData(nameof(SizeParameters))]
195-
//public void ToString_Equals_Constructor_Parameter(int size) {
196-
// // Arrange
197-
// Polyline polyline = Polyline.FromString(value);
198-
// string expected = value;
199-
200-
// // Act
201-
// string result = polyline.ToString();
202-
203-
// // Assert
204-
// Assert.AreEqual(expected, result);
205-
//}
206-
207-
///// <summary>
208-
///// Tests the <see cref="Polyline.ToCharArray"/> method.
209-
///// </summary>
210-
///// <param name="value">The string value.</param>
211-
//[TestMethod]
212-
//[DynamicData(nameof(SizeParameters))]
213-
//public void ToCharArray_Equals_Constructor_Parameter(int size) {
214-
// // Arrange
215-
// Polyline polyline = Polyline.FromString(value);
216-
// char[] expected = value.ToCharArray();
217-
// char[] result = new char[polyline.Length];
218-
219-
// // Act
220-
// polyline.CopyTo(result);
221-
222-
// // Assert
223-
// CollectionAssert.AreEqual(expected, result);
224-
//}
77+
/// <summary>
78+
/// Tests the <see cref="Polyline"/> constructor with a null character array, expecting an <see cref="ArgumentNullException"/>.
79+
/// </summary>
80+
[TestMethod]
81+
public void FromCharArray_Null_CharArray_ArgumentNullException() {
82+
// Arrange
83+
char[] value = null!;
84+
85+
// Act
86+
static Polyline New(char[] value) => Polyline.FromCharArray(value);
87+
88+
// Assert
89+
Assert.ThrowsExactly<ArgumentNullException>(() => New(value));
90+
}
91+
92+
/// <summary>
93+
/// Tests the <see cref="Polyline"/> constructor with a character array parameter.
94+
/// </summary>
95+
/// <param name="value">The string value.</param>
96+
[TestMethod]
97+
[DynamicData(nameof(LengthParameters))]
98+
public void FromCharArray_CharArray_Parameter_Ok(int size) {
99+
// Arrange
100+
var polyline = RandomValueProvider.GetPolyline(size).ToCharArray();
101+
bool isEmpty = polyline.Length == 0;
102+
long length = polyline.Length;
103+
104+
// Act
105+
Polyline result = Polyline.FromCharArray(polyline);
106+
107+
// Assert
108+
Assert.AreEqual(isEmpty, result.IsEmpty);
109+
Assert.AreEqual(length, result.Length);
110+
Assert.AreEqual(new string(polyline), result.ToString());
111+
}
112+
113+
/// <summary>
114+
/// Tests the <see cref="Polyline"/> constructor with a memory parameter.
115+
/// </summary>
116+
/// <param name="value">The string value.</param>
117+
[TestMethod]
118+
[DynamicData(nameof(LengthParameters))]
119+
public void FromMemory_Memory_Parameter_Ok(int size) {
120+
// Arrange
121+
var polyline = RandomValueProvider.GetPolyline(size).AsMemory();
122+
bool isEmpty = polyline.Length == 0;
123+
long length = polyline.Length;
124+
125+
// Act
126+
Polyline result = Polyline.FromMemory(polyline);
127+
128+
// Assert
129+
Assert.AreEqual(isEmpty, result.IsEmpty);
130+
Assert.AreEqual(length, result.Length);
131+
Assert.AreEqual(polyline.ToString(), result.ToString());
132+
}
133+
134+
/// <summary>
135+
/// Tests the <see cref="Polyline.FromString(string)"/> method.
136+
/// </summary>
137+
/// <param name="value">The string value.</param>
138+
[TestMethod]
139+
[DynamicData(nameof(LengthParameters))]
140+
public void FromString_Equals_New(int size) {
141+
// Arrange
142+
var polyline = RandomValueProvider.GetPolyline(size);
143+
bool isEmpty = polyline.Length == 0;
144+
long length = polyline.Length;
145+
146+
// Act
147+
Polyline result = Polyline.FromString(polyline);
148+
149+
// Assert
150+
Assert.AreEqual(polyline, result.ToString());
151+
}
152+
153+
/// <summary>
154+
/// Tests the <see cref="Polyline.FromCharArray(char[])"/> method.
155+
/// </summary>
156+
/// <param name="value">The string value.</param>
157+
[TestMethod]
158+
[DynamicData(nameof(LengthParameters))]
159+
public void FromCharArray_Equals_New(int size) {
160+
// Arrange
161+
char[] array = RandomValueProvider.GetPolyline(size).ToCharArray();
162+
Polyline polyline = Polyline.FromCharArray(array);
163+
164+
// Act
165+
Polyline result = Polyline.FromCharArray(array);
166+
167+
// Assert
168+
Assert.IsTrue(polyline.Equals(result));
169+
}
170+
171+
/// <summary>
172+
/// Tests the <see cref="Polyline.FromMemory(ReadOnlyMemory{char})"/> method.
173+
/// </summary>
174+
/// <param name="value">The string value.</param>
175+
[TestMethod]
176+
[DynamicData(nameof(LengthParameters))]
177+
public void FromMemory_Equals_New(int size) {
178+
// Arrange
179+
ReadOnlyMemory<char> memory = RandomValueProvider.GetPolyline(size).AsMemory();
180+
Polyline polyline = Polyline.FromMemory(memory);
181+
182+
// Act
183+
Polyline result = Polyline.FromMemory(memory);
184+
185+
// Assert
186+
Assert.IsTrue(polyline.Equals(result));
187+
}
188+
189+
/// <summary>
190+
/// Tests the <see cref="Polyline.ToString"/> method.
191+
/// </summary>
192+
/// <param name="value">The string value.</param>
193+
[TestMethod]
194+
[DynamicData(nameof(LengthParameters))]
195+
public void ToString_Equals_Constructor_Parameter(int size) {
196+
// Arrange
197+
Polyline polyline = Polyline.FromString(RandomValueProvider.GetPolyline(size));
198+
string expected = RandomValueProvider.GetPolyline(size);
199+
200+
// Act
201+
string result = polyline.ToString();
202+
203+
// Assert
204+
Assert.AreEqual(expected, result);
205+
}
206+
207+
/// <summary>
208+
/// Tests the <see cref="Polyline.ToCharArray"/> method.
209+
/// </summary>
210+
/// <param name="value">The string value.</param>
211+
[TestMethod]
212+
[DynamicData(nameof(LengthParameters))]
213+
public void ToCharArray_Equals_Constructor_Parameter(int size) {
214+
// Arrange
215+
Polyline polyline = Polyline.FromString(RandomValueProvider.GetPolyline(size));
216+
char[] expected = RandomValueProvider.GetPolyline(size).ToCharArray();
217+
char[] result = new char[polyline.Length];
218+
219+
// Act
220+
polyline.CopyTo(result);
221+
222+
// Assert
223+
CollectionAssert.AreEqual(expected, result);
224+
}
225225
}

0 commit comments

Comments
 (0)