mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-21 16:28:47 +00:00
fix(test): use new NUnit constraint API
This commit is contained in:
parent
0b978f5cdf
commit
a433244799
@ -117,11 +117,11 @@ internal partial class EnumerableTests
|
||||
|
||||
IEnumerable<DummyClass> source = oneToTen.Select(i => new DummyClass {Value = i}).ToArray();
|
||||
IEnumerable<int> values = source.Select(o => o.Value);
|
||||
CollectionAssert.AreEqual(oneToTen, values.ToArray());
|
||||
Assert.That(values.ToArray(), Is.EqualTo(oneToTen).AsCollection);
|
||||
|
||||
source.For((i, o) => o.Value *= i);
|
||||
values = source.Select(o => o.Value);
|
||||
CollectionAssert.AreEqual(multipliedByIndex, values.ToArray());
|
||||
Assert.That(values.ToArray(), Is.EqualTo(multipliedByIndex).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -146,11 +146,11 @@ internal partial class EnumerableTests
|
||||
|
||||
IEnumerable<DummyClass> source = oneToTen.Select(i => new DummyClass {Value = i}).ToArray();
|
||||
IEnumerable<int> values = source.Select(o => o.Value);
|
||||
CollectionAssert.AreEqual(oneToTen, values.ToArray());
|
||||
Assert.That(values.ToArray(), Is.EqualTo(oneToTen).AsCollection);
|
||||
|
||||
source.ForEach(o => o.Value *= 2);
|
||||
values = source.Select(o => o.Value);
|
||||
CollectionAssert.AreEqual(oneToTenDoubled, values.ToArray());
|
||||
Assert.That(values.ToArray(), Is.EqualTo(oneToTenDoubled).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -245,10 +245,10 @@ internal partial class EnumerableTests
|
||||
int[] array = Enumerable.Range(1, 52).ToArray(); // 52! chance of being shuffled to the same order
|
||||
int[] shuffled = array[..];
|
||||
|
||||
CollectionAssert.AreEqual(array, shuffled);
|
||||
Assert.That(shuffled, Is.EqualTo(array).AsCollection);
|
||||
|
||||
shuffled = array.Shuffled().ToArray();
|
||||
CollectionAssert.AreNotEqual(array, shuffled);
|
||||
Assert.That(shuffled, Is.Not.EqualTo(array).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -256,7 +256,7 @@ internal partial class EnumerableTests
|
||||
{
|
||||
var enumerable = new[] {2, 4, 6, 7, 8, 9, 10};
|
||||
IEnumerable<int> result = enumerable.WhereNot(x => x % 2 == 0);
|
||||
CollectionAssert.AreEqual(new[] {7, 9}, result.ToArray());
|
||||
Assert.That(result.ToArray(), Is.EqualTo(new[] { 7, 9 }).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -285,7 +285,7 @@ internal partial class EnumerableTests
|
||||
|
||||
foreach (object o in array.WhereNotNull())
|
||||
{
|
||||
Assert.IsNotNull(o);
|
||||
Assert.That(o, Is.Not.Null);
|
||||
actualCount++;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ namespace X10D.Tests.Collections;
|
||||
[TestFixture]
|
||||
internal class ListTests
|
||||
{
|
||||
[Test]
|
||||
[Test]
|
||||
[TestCase(1)]
|
||||
[TestCase(1, 2, 3)]
|
||||
[TestCase(1, 2, 3, 4, 5)]
|
||||
@ -15,17 +15,17 @@ internal class ListTests
|
||||
int[] all42 = Enumerable.Repeat(42, args.Length).ToArray();
|
||||
var list = new List<int>(args);
|
||||
|
||||
CollectionAssert.AreEqual(args, list);
|
||||
Assert.That(list, Is.EqualTo(args).AsCollection);
|
||||
|
||||
args.Fill(42);
|
||||
list.Fill(42);
|
||||
|
||||
CollectionAssert.AreEqual(args, list);
|
||||
CollectionAssert.AreEqual(all42, args);
|
||||
CollectionAssert.AreEqual(all42, list);
|
||||
Assert.That(list, Is.EqualTo(args).AsCollection);
|
||||
Assert.That(args, Is.EqualTo(all42).AsCollection);
|
||||
Assert.That(list, Is.EqualTo(all42).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Test]
|
||||
[TestCase(1)]
|
||||
[TestCase(1, 2, 3)]
|
||||
[TestCase(1, 2, 3, 4, 5)]
|
||||
@ -36,7 +36,7 @@ internal class ListTests
|
||||
|
||||
int[] comparison = Enumerable.Repeat(1, args.Length - 1).ToArray();
|
||||
Assert.That(args[0], Is.EqualTo(first));
|
||||
CollectionAssert.AreEqual(comparison, args[1..]);
|
||||
Assert.That(args[1..], Is.EqualTo(comparison).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -80,7 +80,7 @@ internal class ListTests
|
||||
[Test]
|
||||
public void IndexOf_ShouldReturnCorrectValue_FromStartOfList()
|
||||
{
|
||||
int[] array = {0, 1, 2, 3, 4};
|
||||
int[] array = { 0, 1, 2, 3, 4 };
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(array.IndexOf(2), Is.EqualTo(2));
|
||||
@ -92,7 +92,7 @@ internal class ListTests
|
||||
[Test]
|
||||
public void IndexOf_ShouldReturnCorrectValue_GivenSubRange()
|
||||
{
|
||||
int[] array = {0, 1, 2, 3, 4, 0};
|
||||
int[] array = { 0, 1, 2, 3, 4, 0 };
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(array.IndexOf(0), Is.Zero);
|
||||
@ -149,7 +149,7 @@ internal class ListTests
|
||||
[Test]
|
||||
public void IndexOf_ShouldThrowArgumentOutOfRangeException_GivenInvalidStartIndexCountPair()
|
||||
{
|
||||
int[] array = {0, 1, 2};
|
||||
int[] array = { 0, 1, 2 };
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => array.IndexOf(0, 2, 4));
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ internal class ListTests
|
||||
public void RemoveRange_ShouldThrowArgumentOutOfRangeException_GivenEndIndexGreaterThanOrEqualToCount()
|
||||
{
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => new List<int>().RemoveRange(..0));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => new List<int> {1}.RemoveRange(..2));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => new List<int> { 1 }.RemoveRange(..2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -208,7 +208,7 @@ internal class ListTests
|
||||
list.RemoveRange(2..5);
|
||||
|
||||
Assert.That(list, Has.Count.EqualTo(6));
|
||||
CollectionAssert.AreEqual(new[] {1, 2, 7, 8, 9, 10}, list);
|
||||
Assert.That(list, Is.EqualTo(new[] { 1, 2, 7, 8, 9, 10 }).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -217,11 +217,11 @@ internal class ListTests
|
||||
var list = new List<int>(Enumerable.Range(1, 52)); // 52! chance of being shuffled to the same order
|
||||
var shuffled = new List<int>(list);
|
||||
|
||||
CollectionAssert.AreEqual(list, shuffled);
|
||||
Assert.That(shuffled, Is.EqualTo(list).AsCollection);
|
||||
|
||||
shuffled.Shuffle();
|
||||
|
||||
CollectionAssert.AreNotEqual(list, shuffled);
|
||||
Assert.That(shuffled, Is.Not.EqualTo(list).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -233,23 +233,23 @@ internal class ListTests
|
||||
[Test]
|
||||
public void Slice_ShouldReturnCorrectValue_GivenStartIndex()
|
||||
{
|
||||
int[] array = {0, 1, 2, 3, 4, 5};
|
||||
CollectionAssert.AreEqual(new[] {2, 3, 4, 5}, array.Slice(2).ToArray());
|
||||
int[] array = { 0, 1, 2, 3, 4, 5 };
|
||||
Assert.That(array.Slice(2).ToArray(), Is.EqualTo(new[] { 2, 3, 4, 5 }).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Slice_ShouldReturnCorrectValue_GivenStartIndexAndLength()
|
||||
{
|
||||
int[] array = {0, 1, 2, 3, 4, 5};
|
||||
CollectionAssert.AreEqual(new[] {2, 3, 4}, array.Slice(2, 3).ToArray());
|
||||
int[] array = { 0, 1, 2, 3, 4, 5 };
|
||||
Assert.That(array.Slice(2, 3).ToArray(), Is.EqualTo(new[] { 2, 3, 4 }).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Slice_ShouldReturnEmptyList_ForEmptyList()
|
||||
{
|
||||
int[] array = Array.Empty<int>();
|
||||
CollectionAssert.AreEqual(Array.Empty<int>(), array.Slice(0).ToArray());
|
||||
CollectionAssert.AreEqual(Array.Empty<int>(), array.Slice(0, 0).ToArray());
|
||||
Assert.That(array.Slice(0).ToArray(), Is.EqualTo(Array.Empty<int>()).AsCollection);
|
||||
Assert.That(array.Slice(0, 0).ToArray(), Is.EqualTo(Array.Empty<int>()).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -278,7 +278,7 @@ internal class ListTests
|
||||
[Test]
|
||||
public void Slice_ShouldThrowArgumentOutOfRangeException_GivenInvalidStartIndexCountPair()
|
||||
{
|
||||
int[] array = {0, 1, 2};
|
||||
int[] array = { 0, 1, 2 };
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => array.Slice(2, 4));
|
||||
}
|
||||
|
||||
@ -297,18 +297,18 @@ internal class ListTests
|
||||
[Test]
|
||||
public void Swap_ShouldSwapElements_GivenMatchingElementCount()
|
||||
{
|
||||
var first = new List<int> {1, 2, 3};
|
||||
var second = new List<int> {4, 5, 6};
|
||||
var first = new List<int> { 1, 2, 3 };
|
||||
var second = new List<int> { 4, 5, 6 };
|
||||
|
||||
first.Swap(second);
|
||||
|
||||
CollectionAssert.AreEqual(new[] {4, 5, 6}, first, string.Join(' ', first));
|
||||
CollectionAssert.AreEqual(new[] {1, 2, 3}, second, string.Join(' ', second));
|
||||
Assert.That(first, Is.EqualTo(new[] { 4, 5, 6 }).AsCollection, string.Join(' ', first));
|
||||
Assert.That(second, Is.EqualTo(new[] { 1, 2, 3 }).AsCollection, string.Join(' ', second));
|
||||
|
||||
first.Swap(second);
|
||||
|
||||
CollectionAssert.AreEqual(new[] {1, 2, 3}, first, string.Join(' ', first));
|
||||
CollectionAssert.AreEqual(new[] {4, 5, 6}, second, string.Join(' ', second));
|
||||
Assert.That(first, Is.EqualTo(new[] { 1, 2, 3 }).AsCollection, string.Join(' ', first));
|
||||
Assert.That(second, Is.EqualTo(new[] { 4, 5, 6 }).AsCollection, string.Join(' ', second));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -322,16 +322,16 @@ internal class ListTests
|
||||
4,
|
||||
5
|
||||
};
|
||||
var second = new List<int> {6, 7};
|
||||
var second = new List<int> { 6, 7 };
|
||||
|
||||
first.Swap(second);
|
||||
|
||||
CollectionAssert.AreEqual(new[] {6, 7}, first, string.Join(' ', first));
|
||||
CollectionAssert.AreEqual(new[] {1, 2, 3, 4, 5}, second, string.Join(' ', second));
|
||||
Assert.That(first, Is.EqualTo(new[] { 6, 7 }).AsCollection, string.Join(' ', first));
|
||||
Assert.That(second, Is.EqualTo(new[] { 1, 2, 3, 4, 5 }).AsCollection, string.Join(' ', second));
|
||||
|
||||
first.Swap(second);
|
||||
|
||||
CollectionAssert.AreEqual(new[] {1, 2, 3, 4, 5}, first, string.Join(' ', first));
|
||||
CollectionAssert.AreEqual(new[] {6, 7}, second, string.Join(' ', second));
|
||||
Assert.That(first, Is.EqualTo(new[] { 1, 2, 3, 4, 5 }).AsCollection, string.Join(' ', first));
|
||||
Assert.That(second, Is.EqualTo(new[] { 6, 7 }).AsCollection, string.Join(' ', second));
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ internal class SpanTest
|
||||
[Test]
|
||||
public void Count_ShouldReturn8_GivenSpanWith8MatchingElements()
|
||||
{
|
||||
Span<int> span = stackalloc int[16] {1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2};
|
||||
Span<int> span = stackalloc int[16] { 1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2 };
|
||||
|
||||
int count = span.Count(2);
|
||||
|
||||
@ -41,7 +41,7 @@ internal class SpanTest
|
||||
[Test]
|
||||
public void Count_ShouldReturn8_GivenReadOnlySpanWith8MatchingElements()
|
||||
{
|
||||
ReadOnlySpan<int> span = stackalloc int[16] {1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2};
|
||||
ReadOnlySpan<int> span = stackalloc int[16] { 1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2 };
|
||||
|
||||
int count = span.Count(2);
|
||||
|
||||
@ -51,25 +51,25 @@ internal class SpanTest
|
||||
[Test]
|
||||
public void Replace_ShouldReplaceAllElements_GivenSpanOfInt32()
|
||||
{
|
||||
Span<int> span = stackalloc int[16] {1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2};
|
||||
Span<int> span = stackalloc int[16] { 1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2 };
|
||||
span.Replace(2, 4);
|
||||
Assert.That(span.ToArray(), Is.EqualTo(new[] {1, 4, 3, 4, 5, 4, 7, 4, 9, 4, 11, 4, 13, 4, 15, 4}));
|
||||
Assert.That(span.ToArray(), Is.EqualTo(new[] { 1, 4, 3, 4, 5, 4, 7, 4, 9, 4, 11, 4, 13, 4, 15, 4 }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Replace_ShouldReplaceAllElements_GivenSpanOfChar()
|
||||
{
|
||||
Span<char> chars = stackalloc char[12] {'H', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!'};
|
||||
Span<char> chars = stackalloc char[12] { 'H', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!' };
|
||||
chars.Replace('l', 'w');
|
||||
CollectionAssert.AreEqual(chars.ToArray(), "Hewwo worwd!".ToCharArray());
|
||||
Assert.That("Hewwo worwd!".ToCharArray(), Is.EqualTo(chars.ToArray()).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Replace_ShouldDoNothing_GivenSpanWithNoMatchingElements()
|
||||
{
|
||||
Span<int> span = stackalloc int[16] {1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2};
|
||||
Span<int> span = stackalloc int[16] { 1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2 };
|
||||
span.Replace(4, 8);
|
||||
Assert.That(span.ToArray(), Is.EqualTo(new[] {1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2}));
|
||||
Assert.That(span.ToArray(), Is.EqualTo(new[] { 1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2 }));
|
||||
}
|
||||
|
||||
#if !NET9_0_OR_GREATER
|
||||
|
@ -63,7 +63,7 @@ internal class CoreTests
|
||||
// ReSharper disable once PossibleMultipleEnumeration
|
||||
object[] array = enumerable.ToArray();
|
||||
Assert.That(array, Has.Length.EqualTo(10));
|
||||
CollectionAssert.AreEqual(new[] {o, o, o, o, o, o, o, o, o, o}, array);
|
||||
Assert.That(array, Is.EqualTo(new[] { o, o, o, o, o, o, o, o, o, o }).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -1,4 +1,3 @@
|
||||
using System.Runtime.Intrinsics.Arm;
|
||||
using System.Runtime.Intrinsics.X86;
|
||||
using NUnit.Framework;
|
||||
using X10D.Core;
|
||||
|
@ -85,7 +85,7 @@ internal class PolygonFTests
|
||||
|
||||
// we cannot use CollectionAssert here for reasons I am not entirely sure of.
|
||||
// it seems to dislike casting from IReadOnlyList<Point> to ICollection. but okay.
|
||||
CollectionAssert.AreEqual(first.Vertices, second.Vertices);
|
||||
Assert.That(second.Vertices, Is.EqualTo(first.Vertices).AsCollection);
|
||||
|
||||
// assert that the empty polygon was not modified
|
||||
Assert.That(PolygonF.Empty.VertexCount, Is.Zero);
|
||||
@ -178,7 +178,7 @@ internal class PolygonFTests
|
||||
Assert.That(converted, Is.EqualTo((Polygon)polygon));
|
||||
Assert.That(converted.IsConvex, Is.EqualTo(polygon.IsConvex));
|
||||
Assert.That(converted.VertexCount, Is.EqualTo(polygon.VertexCount));
|
||||
CollectionAssert.AreEqual(polygon.Vertices, converted.Vertices.Select(p => (PointF)p));
|
||||
Assert.That(converted.Vertices.Select(p => (PointF)p), Is.EqualTo(polygon.Vertices).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
@ -194,7 +194,7 @@ internal class PolygonFTests
|
||||
Assert.That(converted == polygon);
|
||||
Assert.That(converted.IsConvex, Is.EqualTo(polygon.IsConvex));
|
||||
Assert.That(converted.VertexCount, Is.EqualTo(polygon.VertexCount));
|
||||
CollectionAssert.AreEqual(converted.Vertices, polygon.Vertices.Select(p => (PointF)p));
|
||||
Assert.That(polygon.Vertices.Select(p => (PointF)p), Is.EqualTo(converted.Vertices).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ internal class PolyhedronTests
|
||||
|
||||
// we cannot use CollectionAssert here for reasons I am not entirely sure of.
|
||||
// it seems to dislike casting from IReadOnlyList<Point> to ICollection. but okay.
|
||||
CollectionAssert.AreEqual(first.Vertices, second.Vertices);
|
||||
Assert.That(second.Vertices, Is.EqualTo(first.Vertices).AsCollection);
|
||||
|
||||
// assert that the empty polyhedron was not modified
|
||||
Assert.That(Polyhedron.Empty.VertexCount, Is.Zero);
|
||||
@ -148,11 +148,11 @@ internal class PolyhedronTests
|
||||
Assert.That(converted, Is.EqualTo((Polyhedron)polygon));
|
||||
Assert.That(converted.VertexCount, Is.EqualTo(polygon.VertexCount));
|
||||
|
||||
CollectionAssert.AreEqual(converted.Vertices, polygon.Vertices.Select(p =>
|
||||
Assert.That(polygon.Vertices.Select(p =>
|
||||
{
|
||||
var point = p.ToVector2();
|
||||
return new Vector3(point.X, point.Y, 0);
|
||||
}));
|
||||
}), Is.EqualTo(converted.Vertices).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
@ -166,11 +166,11 @@ internal class PolyhedronTests
|
||||
{
|
||||
Assert.That(converted, Is.EqualTo((Polyhedron)polygon));
|
||||
Assert.That(converted.VertexCount, Is.EqualTo(polygon.VertexCount));
|
||||
CollectionAssert.AreEqual(converted.Vertices, polygon.Vertices.Select(p =>
|
||||
Assert.That(converted.Vertices, Is.EqualTo(polygon.Vertices.Select(p =>
|
||||
{
|
||||
var point = p.ToVector2();
|
||||
return new Vector3(point.X, point.Y, 0);
|
||||
}));
|
||||
})).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,8 @@ internal class ServiceCollectionTests
|
||||
{
|
||||
Assert.That(service, Is.Not.Null);
|
||||
Assert.That(hostedService, Is.Not.Null);
|
||||
Assert.IsAssignableFrom<TestService>(service);
|
||||
Assert.IsAssignableFrom<TestService>(hostedService);
|
||||
Assert.That(service, Is.AssignableFrom<TestService>());
|
||||
Assert.That(hostedService, Is.AssignableFrom<TestService>());
|
||||
Assert.That(hostedService, Is.SameAs(service));
|
||||
});
|
||||
}
|
||||
@ -44,8 +44,8 @@ internal class ServiceCollectionTests
|
||||
{
|
||||
Assert.That(service, Is.Not.Null);
|
||||
Assert.That(hostedService, Is.Not.Null);
|
||||
Assert.IsAssignableFrom<TestService>(service);
|
||||
Assert.IsAssignableFrom<TestService>(hostedService);
|
||||
Assert.That(service, Is.AssignableFrom<TestService>());
|
||||
Assert.That(hostedService, Is.AssignableFrom<TestService>());
|
||||
Assert.That(hostedService, Is.SameAs(service));
|
||||
});
|
||||
}
|
||||
@ -65,8 +65,8 @@ internal class ServiceCollectionTests
|
||||
{
|
||||
Assert.That(service, Is.Not.Null);
|
||||
Assert.That(hostedService, Is.Not.Null);
|
||||
Assert.IsAssignableFrom<TestService>(service);
|
||||
Assert.IsAssignableFrom<TestService>(hostedService);
|
||||
Assert.That(service, Is.AssignableFrom<TestService>());
|
||||
Assert.That(hostedService, Is.AssignableFrom<TestService>());
|
||||
Assert.That(hostedService, Is.SameAs(service));
|
||||
});
|
||||
}
|
||||
@ -86,8 +86,8 @@ internal class ServiceCollectionTests
|
||||
{
|
||||
Assert.That(service, Is.Not.Null);
|
||||
Assert.That(hostedService, Is.Not.Null);
|
||||
Assert.IsAssignableFrom<TestService>(service);
|
||||
Assert.IsAssignableFrom<TestService>(hostedService);
|
||||
Assert.That(service, Is.AssignableFrom<TestService>());
|
||||
Assert.That(hostedService, Is.AssignableFrom<TestService>());
|
||||
Assert.That(hostedService, Is.SameAs(service));
|
||||
});
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ internal class BooleanTests
|
||||
public void GetBytes_ReturnsArrayContaining1()
|
||||
{
|
||||
const bool value = true;
|
||||
CollectionAssert.AreEqual(new byte[] {1}, value.GetBytes());
|
||||
Assert.That(value.GetBytes(), Is.EqualTo(new byte[] { 1 }).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -19,7 +19,7 @@ internal class BooleanTests
|
||||
const bool value = true;
|
||||
Span<byte> buffer = stackalloc byte[1];
|
||||
Assert.That(value.TryWriteBytes(buffer));
|
||||
CollectionAssert.AreEqual(new byte[] {1}, buffer.ToArray());
|
||||
Assert.That(buffer.ToArray(), Is.EqualTo(new byte[] { 1 }).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -10,16 +10,19 @@ internal class ByteTests
|
||||
public void GetBytes_ReturnsArrayContainingItself()
|
||||
{
|
||||
const byte value = 0xFF;
|
||||
CollectionAssert.AreEqual(new[] {value}, value.GetBytes());
|
||||
Assert.That(value.GetBytes(), Is.EqualTo(new[] { value }).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TryWriteBytes_ReturnsTrue_FillsSpanContainingItself_GivenLargeEnoughSpan()
|
||||
{
|
||||
const byte value = 0xFF;
|
||||
Span<byte> buffer = stackalloc byte[1];
|
||||
Assert.That(value.TryWriteBytes(buffer));
|
||||
CollectionAssert.AreEqual(new[] {value}, buffer.ToArray());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> buffer = stackalloc byte[1];
|
||||
Assert.That(value.TryWriteBytes(buffer));
|
||||
Assert.That(buffer.ToArray(), Is.EqualTo(new[] { value }).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -14,7 +14,7 @@ internal class DecimalTests
|
||||
|
||||
byte[] bytes = value.GetBigEndianBytes();
|
||||
|
||||
CollectionAssert.AreEqual(expected, bytes);
|
||||
Assert.That(bytes, Is.EqualTo(expected).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -25,7 +25,7 @@ internal class DecimalTests
|
||||
|
||||
byte[] bytes = value.GetLittleEndianBytes();
|
||||
|
||||
CollectionAssert.AreEqual(expected, bytes);
|
||||
Assert.That(bytes, Is.EqualTo(expected).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -34,10 +34,12 @@ internal class DecimalTests
|
||||
const decimal value = 1234m;
|
||||
byte[] expected = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 210];
|
||||
|
||||
Span<byte> bytes = stackalloc byte[16];
|
||||
Assert.That(value.TryWriteBigEndianBytes(bytes));
|
||||
|
||||
CollectionAssert.AreEqual(expected, bytes.ToArray());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> bytes = stackalloc byte[16];
|
||||
Assert.That(value.TryWriteBigEndianBytes(bytes));
|
||||
Assert.That(bytes.ToArray(), Is.EqualTo(expected).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -46,10 +48,12 @@ internal class DecimalTests
|
||||
const decimal value = 1234m;
|
||||
byte[] expected = [210, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||
|
||||
Span<byte> bytes = stackalloc byte[16];
|
||||
Assert.That(value.TryWriteLittleEndianBytes(bytes));
|
||||
|
||||
CollectionAssert.AreEqual(expected, bytes.ToArray());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> bytes = stackalloc byte[16];
|
||||
Assert.That(value.TryWriteLittleEndianBytes(bytes));
|
||||
Assert.That(bytes.ToArray(), Is.EqualTo(expected).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -13,7 +13,7 @@ internal class DoubleTests
|
||||
|
||||
var expected = new byte[] { 0x40, 0x45, 0x40, 0, 0, 0, 0, 0 };
|
||||
byte[] actual = value.GetBigEndianBytes();
|
||||
CollectionAssert.AreEqual(expected, actual);
|
||||
Assert.That(actual, Is.EqualTo(expected).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -23,7 +23,7 @@ internal class DoubleTests
|
||||
|
||||
var expected = new byte[] { 0, 0, 0, 0, 0, 0x40, 0x45, 0x40 };
|
||||
byte[] actual = value.GetLittleEndianBytes();
|
||||
CollectionAssert.AreEqual(expected, actual);
|
||||
Assert.That(actual, Is.EqualTo(expected).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -32,9 +32,12 @@ internal class DoubleTests
|
||||
const double value = 42.5;
|
||||
|
||||
var expected = new byte[] { 0x40, 0x45, 0x40, 0, 0, 0, 0, 0 };
|
||||
Span<byte> actual = stackalloc byte[8];
|
||||
Assert.That(value.TryWriteBigEndianBytes(actual));
|
||||
CollectionAssert.AreEqual(expected, actual.ToArray());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[8];
|
||||
Assert.That(value.TryWriteBigEndianBytes(actual));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -43,9 +46,12 @@ internal class DoubleTests
|
||||
const double value = 42.5;
|
||||
|
||||
var expected = new byte[] { 0, 0, 0, 0, 0, 0x40, 0x45, 0x40 };
|
||||
Span<byte> actual = stackalloc byte[8];
|
||||
Assert.That(value.TryWriteLittleEndianBytes(actual));
|
||||
CollectionAssert.AreEqual(expected, actual.ToArray());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[8];
|
||||
Assert.That(value.TryWriteLittleEndianBytes(actual));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -29,7 +29,7 @@ internal class FileInfoTests
|
||||
try
|
||||
{
|
||||
byte[] hash = new FileInfo(fileName).GetHash<SHA1>();
|
||||
CollectionAssert.AreEqual(expectedHash, hash);
|
||||
Assert.That(hash, Is.EqualTo(expectedHash).AsCollection);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -58,10 +58,14 @@ internal class FileInfoTests
|
||||
|
||||
try
|
||||
{
|
||||
Span<byte> hash = stackalloc byte[20];
|
||||
new FileInfo(fileName).TryWriteHash<SHA1>(hash, out int bytesWritten);
|
||||
Assert.That(bytesWritten, Is.EqualTo(expectedHash.Length));
|
||||
CollectionAssert.AreEqual(expectedHash, hash.ToArray());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> hash = stackalloc byte[20];
|
||||
new FileInfo(fileName).TryWriteHash<SHA1>(hash, out int bytesWritten);
|
||||
|
||||
Assert.That(bytesWritten, Is.EqualTo(expectedHash.Length));
|
||||
Assert.That(hash.ToArray(), Is.EqualTo(expectedHash).AsCollection);
|
||||
});
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ internal class Int16Tests
|
||||
|
||||
byte[] expected = { 0x0F, 0 };
|
||||
byte[] actual = value.GetLittleEndianBytes();
|
||||
CollectionAssert.AreEqual(expected, actual);
|
||||
Assert.That(actual, Is.EqualTo(expected).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -23,7 +23,7 @@ internal class Int16Tests
|
||||
|
||||
byte[] expected = { 0, 0x0F };
|
||||
byte[] actual = value.GetBigEndianBytes();
|
||||
CollectionAssert.AreEqual(expected, actual);
|
||||
Assert.That(actual, Is.EqualTo(expected).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -32,9 +32,12 @@ internal class Int16Tests
|
||||
const short value = 0x0F;
|
||||
|
||||
byte[] expected = { 0x0F, 0 };
|
||||
Span<byte> actual = stackalloc byte[2];
|
||||
Assert.That(value.TryWriteLittleEndianBytes(actual));
|
||||
CollectionAssert.AreEqual(expected, actual.ToArray());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[2];
|
||||
Assert.That(value.TryWriteLittleEndianBytes(actual));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -43,9 +46,12 @@ internal class Int16Tests
|
||||
const short value = 0x0F;
|
||||
|
||||
byte[] expected = { 0, 0x0F };
|
||||
Span<byte> actual = stackalloc byte[2];
|
||||
Assert.That(value.TryWriteBigEndianBytes(actual));
|
||||
CollectionAssert.AreEqual(expected, actual.ToArray());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[2];
|
||||
Assert.That(value.TryWriteBigEndianBytes(actual));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -13,7 +13,7 @@ internal class Int32Tests
|
||||
|
||||
var expected = new byte[] { 0, 0, 0, 0x0F };
|
||||
byte[] actual = value.GetBigEndianBytes();
|
||||
CollectionAssert.AreEqual(expected, actual);
|
||||
Assert.That(actual, Is.EqualTo(expected).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -23,7 +23,7 @@ internal class Int32Tests
|
||||
|
||||
var expected = new byte[] { 0x0F, 0, 0, 0 };
|
||||
byte[] actual = value.GetLittleEndianBytes();
|
||||
CollectionAssert.AreEqual(expected, actual);
|
||||
Assert.That(actual, Is.EqualTo(expected).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -32,9 +32,12 @@ internal class Int32Tests
|
||||
const int value = 0x0F;
|
||||
|
||||
var expected = new byte[] { 0, 0, 0, 0x0F };
|
||||
Span<byte> actual = stackalloc byte[4];
|
||||
Assert.That(value.TryWriteBigEndianBytes(actual));
|
||||
CollectionAssert.AreEqual(expected, actual.ToArray());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[4];
|
||||
Assert.That(value.TryWriteBigEndianBytes(actual));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -43,9 +46,12 @@ internal class Int32Tests
|
||||
const int value = 0x0F;
|
||||
|
||||
var expected = new byte[] { 0x0F, 0, 0, 0 };
|
||||
Span<byte> actual = stackalloc byte[4];
|
||||
Assert.That(value.TryWriteLittleEndianBytes(actual));
|
||||
CollectionAssert.AreEqual(expected, actual.ToArray());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[4];
|
||||
Assert.That(value.TryWriteLittleEndianBytes(actual));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -13,7 +13,7 @@ internal class Int64Tests
|
||||
|
||||
byte[] expected = { 0x0F, 0, 0, 0, 0, 0, 0, 0 };
|
||||
byte[] actual = value.GetLittleEndianBytes();
|
||||
CollectionAssert.AreEqual(expected, actual);
|
||||
Assert.That(actual, Is.EqualTo(expected).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -23,7 +23,7 @@ internal class Int64Tests
|
||||
|
||||
byte[] expected = { 0, 0, 0, 0, 0, 0, 0, 0x0F };
|
||||
byte[] actual = value.GetBigEndianBytes();
|
||||
CollectionAssert.AreEqual(expected, actual);
|
||||
Assert.That(actual, Is.EqualTo(expected).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -32,9 +32,12 @@ internal class Int64Tests
|
||||
const long value = 0x0F;
|
||||
|
||||
byte[] expected = { 0x0F, 0, 0, 0, 0, 0, 0, 0 };
|
||||
Span<byte> actual = stackalloc byte[8];
|
||||
Assert.That(value.TryWriteLittleEndianBytes(actual));
|
||||
CollectionAssert.AreEqual(expected, actual.ToArray());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[8];
|
||||
Assert.That(value.TryWriteLittleEndianBytes(actual));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -43,9 +46,12 @@ internal class Int64Tests
|
||||
const long value = 0x0F;
|
||||
|
||||
byte[] expected = { 0, 0, 0, 0, 0, 0, 0, 0x0F };
|
||||
Span<byte> actual = stackalloc byte[8];
|
||||
Assert.That(value.TryWriteBigEndianBytes(actual));
|
||||
CollectionAssert.AreEqual(expected, actual.ToArray());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[8];
|
||||
Assert.That(value.TryWriteBigEndianBytes(actual));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -10,16 +10,19 @@ internal class SByteTests
|
||||
public void GetBytes_ReturnsArrayContainingItself()
|
||||
{
|
||||
const sbyte value = 0x0F;
|
||||
CollectionAssert.AreEqual(new[] {(byte)value}, value.GetBytes());
|
||||
Assert.That(value.GetBytes(), Is.EqualTo(new[] { (byte)value }).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TryWriteBytes_ReturnsTrue_FillsSpanContainingItself_GivenLargeEnoughSpan()
|
||||
{
|
||||
const sbyte value = 0x0F;
|
||||
Span<byte> buffer = stackalloc byte[1];
|
||||
Assert.That(value.TryWriteBytes(buffer));
|
||||
CollectionAssert.AreEqual(new[] {(byte)value}, buffer.ToArray());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> buffer = stackalloc byte[1];
|
||||
Assert.That(value.TryWriteBytes(buffer));
|
||||
Assert.That(buffer.ToArray(), Is.EqualTo(new[] { (byte)value }).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -13,7 +13,7 @@ internal class SingleTests
|
||||
|
||||
var expected = new byte[] { 0x42, 0x2A, 0, 0 };
|
||||
byte[] actual = value.GetBigEndianBytes();
|
||||
CollectionAssert.AreEqual(expected, actual);
|
||||
Assert.That(actual, Is.EqualTo(expected).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -23,7 +23,7 @@ internal class SingleTests
|
||||
|
||||
var expected = new byte[] { 0, 0, 0x2A, 0x42 };
|
||||
byte[] actual = value.GetLittleEndianBytes();
|
||||
CollectionAssert.AreEqual(expected, actual);
|
||||
Assert.That(actual, Is.EqualTo(expected).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -32,9 +32,12 @@ internal class SingleTests
|
||||
const float value = 42.5f;
|
||||
|
||||
var expected = new byte[] { 0x42, 0x2A, 0, 0 };
|
||||
Span<byte> actual = stackalloc byte[4];
|
||||
Assert.That(value.TryWriteBigEndianBytes(actual));
|
||||
CollectionAssert.AreEqual(expected, actual.ToArray());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[4];
|
||||
Assert.That(value.TryWriteBigEndianBytes(actual));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -43,9 +46,12 @@ internal class SingleTests
|
||||
const float value = 42.5f;
|
||||
|
||||
var expected = new byte[] { 0, 0, 0x2A, 0x42 };
|
||||
Span<byte> actual = stackalloc byte[4];
|
||||
Assert.That(value.TryWriteLittleEndianBytes(actual));
|
||||
CollectionAssert.AreEqual(expected, actual.ToArray());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[4];
|
||||
Assert.That(value.TryWriteLittleEndianBytes(actual));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -45,16 +45,19 @@ internal partial class StreamTests
|
||||
Assert.That(stream.Position, Is.EqualTo(16));
|
||||
stream.Position = 0;
|
||||
|
||||
Span<byte> actual = stackalloc byte[16];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[]
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x68
|
||||
};
|
||||
int read = stream.Read(actual);
|
||||
Trace.WriteLine(string.Join(' ', actual.ToArray()));
|
||||
Span<byte> actual = stackalloc byte[16];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[]
|
||||
{
|
||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x68
|
||||
};
|
||||
int read = stream.Read(actual);
|
||||
Trace.WriteLine(string.Join(' ', actual.ToArray()));
|
||||
|
||||
Assert.That(read, Is.EqualTo(16));
|
||||
CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray());
|
||||
Assert.That(read, Is.EqualTo(16));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -65,16 +68,19 @@ internal partial class StreamTests
|
||||
Assert.That(stream.Position, Is.EqualTo(16));
|
||||
stream.Position = 0;
|
||||
|
||||
Span<byte> actual = stackalloc byte[16];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[]
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
0x68, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00
|
||||
};
|
||||
int read = stream.Read(actual);
|
||||
Span<byte> actual = stackalloc byte[16];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[]
|
||||
{
|
||||
0x68, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00
|
||||
};
|
||||
int read = stream.Read(actual);
|
||||
|
||||
Trace.WriteLine(string.Join(", ", actual.ToArray().Select(b => $"0x{b:X2}")));
|
||||
Trace.WriteLine(string.Join(", ", actual.ToArray().Select(b => $"0x{b:X2}")));
|
||||
|
||||
Assert.That(read, Is.EqualTo(16));
|
||||
CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray());
|
||||
Assert.That(read, Is.EqualTo(16));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -44,12 +44,15 @@ internal partial class StreamTests
|
||||
Assert.That(stream.Position, Is.EqualTo(8));
|
||||
stream.Position = 0;
|
||||
|
||||
Span<byte> actual = stackalloc byte[8];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x40, 0x7A, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
int read = stream.Read(actual);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[8];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x40, 0x7A, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
int read = stream.Read(actual);
|
||||
|
||||
Assert.That(read, Is.EqualTo(8));
|
||||
CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray());
|
||||
Assert.That(read, Is.EqualTo(8));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -60,11 +63,14 @@ internal partial class StreamTests
|
||||
Assert.That(stream.Position, Is.EqualTo(8));
|
||||
stream.Position = 0;
|
||||
|
||||
Span<byte> actual = stackalloc byte[8];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x7A, 0x40 };
|
||||
int read = stream.Read(actual);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[8];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x7A, 0x40 };
|
||||
int read = stream.Read(actual);
|
||||
|
||||
Assert.That(read, Is.EqualTo(8));
|
||||
CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray());
|
||||
Assert.That(read, Is.EqualTo(8));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -44,12 +44,15 @@ internal partial class StreamTests
|
||||
Assert.That(stream.Position, Is.EqualTo(2));
|
||||
stream.Position = 0;
|
||||
|
||||
Span<byte> actual = stackalloc byte[2];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x01, 0xA4 };
|
||||
int read = stream.Read(actual);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[2];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x01, 0xA4 };
|
||||
int read = stream.Read(actual);
|
||||
|
||||
Assert.That(read, Is.EqualTo(2));
|
||||
CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray());
|
||||
Assert.That(read, Is.EqualTo(2));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -60,11 +63,14 @@ internal partial class StreamTests
|
||||
Assert.That(stream.Position, Is.EqualTo(2));
|
||||
stream.Position = 0;
|
||||
|
||||
Span<byte> actual = stackalloc byte[2];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0xA4, 0x01 };
|
||||
int read = stream.Read(actual);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[2];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0xA4, 0x01 };
|
||||
int read = stream.Read(actual);
|
||||
|
||||
Assert.That(read, Is.EqualTo(2));
|
||||
CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray());
|
||||
Assert.That(read, Is.EqualTo(2));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -44,12 +44,15 @@ internal partial class StreamTests
|
||||
Assert.That(stream.Position, Is.EqualTo(4));
|
||||
stream.Position = 0;
|
||||
|
||||
Span<byte> actual = stackalloc byte[4];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x00, 0x00, 0x01, 0xA4 };
|
||||
int read = stream.Read(actual);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[4];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x00, 0x00, 0x01, 0xA4 };
|
||||
int read = stream.Read(actual);
|
||||
|
||||
Assert.That(read, Is.EqualTo(4));
|
||||
CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray());
|
||||
Assert.That(read, Is.EqualTo(4));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -60,11 +63,14 @@ internal partial class StreamTests
|
||||
Assert.That(stream.Position, Is.EqualTo(4));
|
||||
stream.Position = 0;
|
||||
|
||||
Span<byte> actual = stackalloc byte[4];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00 };
|
||||
int read = stream.Read(actual);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[4];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00 };
|
||||
int read = stream.Read(actual);
|
||||
|
||||
Assert.That(read, Is.EqualTo(4));
|
||||
CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray());
|
||||
Assert.That(read, Is.EqualTo(4));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -44,12 +44,15 @@ internal partial class StreamTests
|
||||
Assert.That(stream.Position, Is.EqualTo(8));
|
||||
stream.Position = 0;
|
||||
|
||||
Span<byte> actual = stackalloc byte[8];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xA4 };
|
||||
int read = stream.Read(actual);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[8];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xA4 };
|
||||
int read = stream.Read(actual);
|
||||
|
||||
Assert.That(read, Is.EqualTo(8));
|
||||
CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray());
|
||||
Assert.That(read, Is.EqualTo(8));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -60,11 +63,14 @@ internal partial class StreamTests
|
||||
Assert.That(stream.Position, Is.EqualTo(8));
|
||||
stream.Position = 0;
|
||||
|
||||
Span<byte> actual = stackalloc byte[8];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
int read = stream.Read(actual);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[8];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
int read = stream.Read(actual);
|
||||
|
||||
Assert.That(read, Is.EqualTo(8));
|
||||
CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray());
|
||||
Assert.That(read, Is.EqualTo(8));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -44,12 +44,15 @@ internal partial class StreamTests
|
||||
Assert.That(stream.Position, Is.EqualTo(4));
|
||||
stream.Position = 0;
|
||||
|
||||
Span<byte> actual = stackalloc byte[4];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x43, 0xD2, 0x00, 0x00 };
|
||||
int read = stream.Read(actual);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[4];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x43, 0xD2, 0x00, 0x00 };
|
||||
int read = stream.Read(actual);
|
||||
|
||||
Assert.That(read, Is.EqualTo(4));
|
||||
CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray());
|
||||
Assert.That(read, Is.EqualTo(4));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -60,11 +63,14 @@ internal partial class StreamTests
|
||||
Assert.That(stream.Position, Is.EqualTo(4));
|
||||
stream.Position = 0;
|
||||
|
||||
Span<byte> actual = stackalloc byte[4];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x00, 0x00, 0xD2, 0x43 };
|
||||
int read = stream.Read(actual);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[4];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x00, 0x00, 0xD2, 0x43 };
|
||||
int read = stream.Read(actual);
|
||||
|
||||
Assert.That(read, Is.EqualTo(4));
|
||||
CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray());
|
||||
Assert.That(read, Is.EqualTo(4));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -44,12 +44,15 @@ internal partial class StreamTests
|
||||
Assert.That(stream.Position, Is.EqualTo(2));
|
||||
stream.Position = 0;
|
||||
|
||||
Span<byte> actual = stackalloc byte[2];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x01, 0xA4 };
|
||||
int read = stream.Read(actual);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[2];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x01, 0xA4 };
|
||||
int read = stream.Read(actual);
|
||||
|
||||
Assert.That(read, Is.EqualTo(2));
|
||||
CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray());
|
||||
Assert.That(read, Is.EqualTo(2));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -60,11 +63,14 @@ internal partial class StreamTests
|
||||
Assert.That(stream.Position, Is.EqualTo(2));
|
||||
stream.Position = 0;
|
||||
|
||||
Span<byte> actual = stackalloc byte[2];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0xA4, 0x01 };
|
||||
int read = stream.Read(actual);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[2];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0xA4, 0x01 };
|
||||
int read = stream.Read(actual);
|
||||
|
||||
Assert.That(read, Is.EqualTo(2));
|
||||
CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray());
|
||||
Assert.That(read, Is.EqualTo(2));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -44,12 +44,15 @@ internal partial class StreamTests
|
||||
Assert.That(stream.Position, Is.EqualTo(4));
|
||||
stream.Position = 0;
|
||||
|
||||
Span<byte> actual = stackalloc byte[4];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x00, 0x00, 0x01, 0xA4 };
|
||||
int read = stream.Read(actual);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[4];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x00, 0x00, 0x01, 0xA4 };
|
||||
int read = stream.Read(actual);
|
||||
|
||||
Assert.That(read, Is.EqualTo(4));
|
||||
CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray());
|
||||
Assert.That(read, Is.EqualTo(4));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -60,11 +63,14 @@ internal partial class StreamTests
|
||||
Assert.That(stream.Position, Is.EqualTo(4));
|
||||
stream.Position = 0;
|
||||
|
||||
Span<byte> actual = stackalloc byte[4];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00 };
|
||||
int read = stream.Read(actual);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[4];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00 };
|
||||
int read = stream.Read(actual);
|
||||
|
||||
Assert.That(read, Is.EqualTo(4));
|
||||
CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray());
|
||||
Assert.That(read, Is.EqualTo(4));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -44,12 +44,15 @@ internal partial class StreamTests
|
||||
Assert.That(stream.Position, Is.EqualTo(8));
|
||||
stream.Position = 0;
|
||||
|
||||
Span<byte> actual = stackalloc byte[8];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xA4 };
|
||||
int read = stream.Read(actual);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[8];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xA4 };
|
||||
int read = stream.Read(actual);
|
||||
|
||||
Assert.That(read, Is.EqualTo(8));
|
||||
CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray());
|
||||
Assert.That(read, Is.EqualTo(8));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -60,11 +63,14 @@ internal partial class StreamTests
|
||||
Assert.That(stream.Position, Is.EqualTo(8));
|
||||
stream.Position = 0;
|
||||
|
||||
Span<byte> actual = stackalloc byte[8];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
int read = stream.Read(actual);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[8];
|
||||
ReadOnlySpan<byte> expected = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
int read = stream.Read(actual);
|
||||
|
||||
Assert.That(read, Is.EqualTo(8));
|
||||
CollectionAssert.AreEqual(expected.ToArray(), actual.ToArray());
|
||||
Assert.That(read, Is.EqualTo(8));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected.ToArray()).AsCollection);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ internal partial class StreamTests
|
||||
byte[] hash = stream.GetHash<SHA1>();
|
||||
Trace.WriteLine($"Hash: {BitConverter.ToString(hash)}");
|
||||
Trace.WriteLine($"Expected: {BitConverter.ToString(expectedHash)}");
|
||||
CollectionAssert.AreEqual(expectedHash, hash);
|
||||
Assert.That(hash, Is.EqualTo(expectedHash).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -54,7 +54,7 @@ internal partial class StreamTests
|
||||
Span<byte> hash = stackalloc byte[20];
|
||||
stream.TryWriteHash<SHA1>(hash, out int bytesWritten);
|
||||
Assert.That(bytesWritten, Is.EqualTo(expectedHash.Length));
|
||||
CollectionAssert.AreEqual(expectedHash, hash.ToArray());
|
||||
Assert.That(hash.ToArray(), Is.EqualTo(expectedHash).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -13,7 +13,7 @@ internal class UInt16Tests
|
||||
byte[] expected = { 0x0F, 0 };
|
||||
byte[] actual = value.GetLittleEndianBytes();
|
||||
|
||||
CollectionAssert.AreEqual(expected, actual);
|
||||
Assert.That(actual, Is.EqualTo(expected).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -23,7 +23,7 @@ internal class UInt16Tests
|
||||
byte[] expected = { 0, 0x0F };
|
||||
byte[] actual = value.GetBigEndianBytes();
|
||||
|
||||
CollectionAssert.AreEqual(expected, actual);
|
||||
Assert.That(actual, Is.EqualTo(expected).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -32,10 +32,12 @@ internal class UInt16Tests
|
||||
const ushort value = 0x0F;
|
||||
byte[] expected = { 0x0F, 0 };
|
||||
|
||||
Span<byte> actual = stackalloc byte[2];
|
||||
Assert.That(value.TryWriteLittleEndianBytes(actual));
|
||||
|
||||
CollectionAssert.AreEqual(expected, actual.ToArray());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[2];
|
||||
Assert.That(value.TryWriteLittleEndianBytes(actual));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -44,10 +46,12 @@ internal class UInt16Tests
|
||||
const ushort value = 0x0F;
|
||||
byte[] expected = { 0, 0x0F };
|
||||
|
||||
Span<byte> actual = stackalloc byte[2];
|
||||
Assert.That(value.TryWriteBigEndianBytes(actual));
|
||||
|
||||
CollectionAssert.AreEqual(expected, actual.ToArray());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[2];
|
||||
Assert.That(value.TryWriteBigEndianBytes(actual));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -13,7 +13,7 @@ internal class UInt32Tests
|
||||
byte[] expected = { 0x0F, 0, 0, 0 };
|
||||
byte[] actual = value.GetLittleEndianBytes();
|
||||
|
||||
CollectionAssert.AreEqual(expected, actual);
|
||||
Assert.That(actual, Is.EqualTo(expected).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -23,7 +23,7 @@ internal class UInt32Tests
|
||||
byte[] expected = { 0, 0, 0, 0x0F };
|
||||
byte[] actual = value.GetBigEndianBytes();
|
||||
|
||||
CollectionAssert.AreEqual(expected, actual);
|
||||
Assert.That(actual, Is.EqualTo(expected).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -32,10 +32,12 @@ internal class UInt32Tests
|
||||
const uint value = 0x0F;
|
||||
byte[] expected = { 0x0F, 0, 0, 0 };
|
||||
|
||||
Span<byte> actual = stackalloc byte[4];
|
||||
Assert.That(value.TryWriteLittleEndianBytes(actual));
|
||||
|
||||
CollectionAssert.AreEqual(expected, actual.ToArray());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[4];
|
||||
Assert.That(value.TryWriteLittleEndianBytes(actual));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -44,10 +46,12 @@ internal class UInt32Tests
|
||||
const uint value = 0x0F;
|
||||
byte[] expected = { 0, 0, 0, 0x0F };
|
||||
|
||||
Span<byte> actual = stackalloc byte[4];
|
||||
Assert.That(value.TryWriteBigEndianBytes(actual));
|
||||
|
||||
CollectionAssert.AreEqual(expected, actual.ToArray());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[4];
|
||||
Assert.That(value.TryWriteBigEndianBytes(actual));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -13,7 +13,7 @@ internal class UInt64Tests
|
||||
byte[] expected = { 0x0F, 0, 0, 0, 0, 0, 0, 0 };
|
||||
byte[] actual = value.GetLittleEndianBytes();
|
||||
|
||||
CollectionAssert.AreEqual(expected, actual);
|
||||
Assert.That(actual, Is.EqualTo(expected).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -23,7 +23,7 @@ internal class UInt64Tests
|
||||
byte[] expected = { 0, 0, 0, 0, 0, 0, 0, 0x0F };
|
||||
byte[] actual = value.GetBigEndianBytes();
|
||||
|
||||
CollectionAssert.AreEqual(expected, actual);
|
||||
Assert.That(actual, Is.EqualTo(expected).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -32,10 +32,12 @@ internal class UInt64Tests
|
||||
const ulong value = 0x0F;
|
||||
byte[] expected = { 0x0F, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
Span<byte> actual = stackalloc byte[8];
|
||||
Assert.That(value.TryWriteLittleEndianBytes(actual));
|
||||
|
||||
CollectionAssert.AreEqual(expected, actual.ToArray());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[8];
|
||||
Assert.That(value.TryWriteLittleEndianBytes(actual));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -44,10 +46,12 @@ internal class UInt64Tests
|
||||
const ulong value = 0x0F;
|
||||
byte[] expected = { 0, 0, 0, 0, 0, 0, 0, 0x0F };
|
||||
|
||||
Span<byte> actual = stackalloc byte[8];
|
||||
Assert.That(value.TryWriteBigEndianBytes(actual));
|
||||
|
||||
CollectionAssert.AreEqual(expected, actual.ToArray());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<byte> actual = stackalloc byte[8];
|
||||
Assert.That(value.TryWriteBigEndianBytes(actual));
|
||||
Assert.That(actual.ToArray(), Is.EqualTo(expected).AsCollection);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -142,7 +142,7 @@ internal class IsPrimeTests
|
||||
private static IReadOnlyList<int> LoadPrimes()
|
||||
{
|
||||
using var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("X10D.Tests.1000primes.txt");
|
||||
Assert.IsNotNull(stream);
|
||||
Assert.That(stream, Is.Not.Null);
|
||||
|
||||
using var reader = new StreamReader(stream, Encoding.UTF8);
|
||||
var primes = new List<int>();
|
||||
|
@ -20,7 +20,11 @@ internal class CoreTests
|
||||
int[] source = Enumerable.Range(1, 100).ToArray();
|
||||
string json = source.ToJson();
|
||||
int[]? target = json.FromJson<int[]>();
|
||||
CollectionAssert.AreEqual(source, target);
|
||||
CollectionAssert.AreEquivalent(source, target);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(target, Is.EqualTo(source).AsCollection);
|
||||
Assert.That(target, Is.EquivalentTo(source));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -10,13 +10,13 @@ internal class EnumerableTests
|
||||
public void Grep_ShouldFilterCorrectly_GivenPattern()
|
||||
{
|
||||
int year = DateTime.Now.Year;
|
||||
var source = new[] {"Hello", "World", "String 123", $"The year is {year}"};
|
||||
var expectedResult = new[] {"String 123", $"The year is {year}"};
|
||||
var source = new[] { "Hello", "World", "String 123", $"The year is {year}" };
|
||||
var expectedResult = new[] { "String 123", $"The year is {year}" };
|
||||
|
||||
const string pattern = /*lang=regex*/@"[0-9]+";
|
||||
string[] actualResult = source.Grep(pattern).ToArray();
|
||||
|
||||
CollectionAssert.AreEqual(expectedResult, actualResult);
|
||||
Assert.That(actualResult, Is.EqualTo(expectedResult).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -28,27 +28,27 @@ internal class EnumerableTests
|
||||
const string pattern = /*lang=regex*/@"[0-9]+";
|
||||
string[] actualResult = source.Grep(pattern).ToArray();
|
||||
|
||||
CollectionAssert.AreEqual(expectedResult, actualResult);
|
||||
Assert.That(actualResult, Is.EqualTo(expectedResult).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Grep_ShouldMatchUpperCase_GivenIgnoreCaseTrue()
|
||||
{
|
||||
int year = DateTime.Now.Year;
|
||||
var source = new[] {"Hello", "WORLD", "String 123", $"The year is {year}"};
|
||||
var expectedResult = new[] {"WORLD"};
|
||||
var source = new[] { "Hello", "WORLD", "String 123", $"The year is {year}" };
|
||||
var expectedResult = new[] { "WORLD" };
|
||||
|
||||
const string pattern = /*lang=regex*/@"world";
|
||||
string[] actualResult = source.Grep(pattern, true).ToArray();
|
||||
|
||||
CollectionAssert.AreEqual(expectedResult, actualResult);
|
||||
Assert.That(actualResult, Is.EqualTo(expectedResult).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Grep_ShouldNotMatchUpperCase_GivenIgnoreCaseFalse()
|
||||
{
|
||||
int year = DateTime.Now.Year;
|
||||
var source = new[] {"Hello", "WORLD", "String 123", $"The year is {year}"};
|
||||
var source = new[] { "Hello", "WORLD", "String 123", $"The year is {year}" };
|
||||
|
||||
const string pattern = /*lang=regex*/@"world";
|
||||
string[] actualResult = source.Grep(pattern, false).ToArray();
|
||||
@ -60,22 +60,28 @@ internal class EnumerableTests
|
||||
public void Grep_ShouldThrowArgumentNullException_GivenNullPattern()
|
||||
{
|
||||
IEnumerable<string> source = Enumerable.Empty<string>();
|
||||
Assert.Throws<ArgumentNullException>(() => source.Grep(null!).ToArray());
|
||||
Assert.Throws<ArgumentNullException>(() => source.Grep(null!, false).ToArray());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => source.Grep(null!).ToArray());
|
||||
Assert.Throws<ArgumentNullException>(() => source.Grep(null!, false).ToArray());
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Grep_ShouldThrowArgumentNullException_GivenNullSource()
|
||||
{
|
||||
IEnumerable<string> source = null!;
|
||||
Assert.Throws<ArgumentNullException>(() => source.Grep("foo").ToArray());
|
||||
Assert.Throws<ArgumentNullException>(() => source.Grep("foo", false).ToArray());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => source.Grep("foo").ToArray());
|
||||
Assert.Throws<ArgumentNullException>(() => source.Grep("foo", false).ToArray());
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Grep_ShouldYieldNoElements_GivenNoMatchingStrings()
|
||||
{
|
||||
var source = new[] {"Hello", "World", "String"};
|
||||
var source = new[] { "Hello", "World", "String" };
|
||||
|
||||
const string pattern = /*lang=regex*/@"[0-9]+";
|
||||
string[] actualResult = source.Grep(pattern).ToArray();
|
||||
|
@ -22,18 +22,21 @@ internal class StringBuilderReaderTests
|
||||
{
|
||||
using var reader = new StringBuilderReader(new StringBuilder("Hello\nWorld"));
|
||||
|
||||
Assert.That(reader.Read(), Is.EqualTo('H'));
|
||||
Assert.That(reader.Read(), Is.EqualTo('e'));
|
||||
Assert.That(reader.Read(), Is.EqualTo('l'));
|
||||
Assert.That(reader.Read(), Is.EqualTo('l'));
|
||||
Assert.That(reader.Read(), Is.EqualTo('o'));
|
||||
Assert.That(reader.Read(), Is.EqualTo('\n'));
|
||||
Assert.That(reader.Read(), Is.EqualTo('W'));
|
||||
Assert.That(reader.Read(), Is.EqualTo('o'));
|
||||
Assert.That(reader.Read(), Is.EqualTo('r'));
|
||||
Assert.That(reader.Read(), Is.EqualTo('l'));
|
||||
Assert.That(reader.Read(), Is.EqualTo('d'));
|
||||
Assert.That(reader.Read(), Is.EqualTo(-1));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(reader.Read(), Is.EqualTo('H'));
|
||||
Assert.That(reader.Read(), Is.EqualTo('e'));
|
||||
Assert.That(reader.Read(), Is.EqualTo('l'));
|
||||
Assert.That(reader.Read(), Is.EqualTo('l'));
|
||||
Assert.That(reader.Read(), Is.EqualTo('o'));
|
||||
Assert.That(reader.Read(), Is.EqualTo('\n'));
|
||||
Assert.That(reader.Read(), Is.EqualTo('W'));
|
||||
Assert.That(reader.Read(), Is.EqualTo('o'));
|
||||
Assert.That(reader.Read(), Is.EqualTo('r'));
|
||||
Assert.That(reader.Read(), Is.EqualTo('l'));
|
||||
Assert.That(reader.Read(), Is.EqualTo('d'));
|
||||
Assert.That(reader.Read(), Is.EqualTo(-1));
|
||||
});
|
||||
|
||||
reader.Close();
|
||||
}
|
||||
@ -45,9 +48,12 @@ internal class StringBuilderReaderTests
|
||||
|
||||
var array = new char[5];
|
||||
int read = reader.Read(array, 0, 5);
|
||||
Assert.That(read, Is.EqualTo(5));
|
||||
|
||||
CollectionAssert.AreEqual("Hello".ToCharArray(), array);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(read, Is.EqualTo(5));
|
||||
Assert.That(array, Is.EqualTo("Hello".ToCharArray()).AsCollection);
|
||||
});
|
||||
|
||||
reader.Close();
|
||||
}
|
||||
@ -114,11 +120,14 @@ internal class StringBuilderReaderTests
|
||||
{
|
||||
using var reader = new StringBuilderReader(new StringBuilder("Hello\nWorld"));
|
||||
|
||||
Span<char> span = stackalloc char[5];
|
||||
int read = reader.Read(span);
|
||||
Assert.That(read, Is.EqualTo(5));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<char> span = stackalloc char[5];
|
||||
int read = reader.Read(span);
|
||||
|
||||
CollectionAssert.AreEqual("Hello".ToCharArray(), span.ToArray());
|
||||
Assert.That(read, Is.EqualTo(5));
|
||||
Assert.That(span.ToArray(), Is.EqualTo("Hello".ToCharArray()).AsCollection);
|
||||
});
|
||||
|
||||
reader.Close();
|
||||
}
|
||||
@ -130,9 +139,12 @@ internal class StringBuilderReaderTests
|
||||
|
||||
var array = new char[5];
|
||||
int read = reader.ReadAsync(array, 0, 5).GetAwaiter().GetResult();
|
||||
Assert.That(read, Is.EqualTo(5));
|
||||
|
||||
CollectionAssert.AreEqual("Hello".ToCharArray(), array);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(read, Is.EqualTo(5));
|
||||
Assert.That(array, Is.EqualTo("Hello".ToCharArray()).AsCollection);
|
||||
});
|
||||
|
||||
reader.Close();
|
||||
}
|
||||
@ -144,9 +156,12 @@ internal class StringBuilderReaderTests
|
||||
|
||||
Memory<char> memory = new char[5];
|
||||
int read = reader.ReadAsync(memory).GetAwaiter().GetResult();
|
||||
Assert.That(read, Is.EqualTo(5));
|
||||
|
||||
CollectionAssert.AreEqual("Hello".ToCharArray(), memory.ToArray());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(read, Is.EqualTo(5));
|
||||
Assert.That(memory.ToArray(), Is.EqualTo("Hello".ToCharArray()).AsCollection);
|
||||
});
|
||||
|
||||
reader.Close();
|
||||
}
|
||||
@ -158,9 +173,12 @@ internal class StringBuilderReaderTests
|
||||
|
||||
var array = new char[5];
|
||||
int read = reader.ReadBlock(array, 0, 5);
|
||||
Assert.That(read, Is.EqualTo(5));
|
||||
|
||||
CollectionAssert.AreEqual("Hello".ToCharArray(), array);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(read, Is.EqualTo(5));
|
||||
Assert.That(array, Is.EqualTo("Hello".ToCharArray()).AsCollection);
|
||||
});
|
||||
|
||||
reader.Close();
|
||||
}
|
||||
@ -170,11 +188,14 @@ internal class StringBuilderReaderTests
|
||||
{
|
||||
using var reader = new StringBuilderReader(new StringBuilder("Hello\nWorld"));
|
||||
|
||||
Span<char> span = stackalloc char[5];
|
||||
int read = reader.ReadBlock(span);
|
||||
Assert.That(read, Is.EqualTo(5));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Span<char> span = stackalloc char[5];
|
||||
int read = reader.ReadBlock(span);
|
||||
|
||||
CollectionAssert.AreEqual("Hello".ToCharArray(), span.ToArray());
|
||||
Assert.That(read, Is.EqualTo(5));
|
||||
Assert.That(span.ToArray(), Is.EqualTo("Hello".ToCharArray()).AsCollection);
|
||||
});
|
||||
|
||||
reader.Close();
|
||||
}
|
||||
@ -200,9 +221,12 @@ internal class StringBuilderReaderTests
|
||||
|
||||
var array = new char[5];
|
||||
int read = reader.ReadBlockAsync(array, 0, 5).GetAwaiter().GetResult();
|
||||
Assert.That(read, Is.EqualTo(5));
|
||||
|
||||
CollectionAssert.AreEqual("Hello".ToCharArray(), array);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(read, Is.EqualTo(5));
|
||||
Assert.That(array, Is.EqualTo("Hello".ToCharArray()).AsCollection);
|
||||
});
|
||||
|
||||
reader.Close();
|
||||
}
|
||||
@ -214,9 +238,12 @@ internal class StringBuilderReaderTests
|
||||
|
||||
Memory<char> memory = new char[5];
|
||||
int read = reader.ReadBlockAsync(memory).GetAwaiter().GetResult();
|
||||
Assert.That(read, Is.EqualTo(5));
|
||||
|
||||
CollectionAssert.AreEqual("Hello".ToCharArray(), memory.ToArray());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(read, Is.EqualTo(5));
|
||||
Assert.That(memory.ToArray(), Is.EqualTo("Hello".ToCharArray()).AsCollection);
|
||||
});
|
||||
|
||||
reader.Close();
|
||||
}
|
||||
|
@ -423,7 +423,7 @@ internal class StringTests
|
||||
var target = json.FromJson<SampleStructure>();
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.IsInstanceOf<SampleStructure>(target);
|
||||
Assert.That(target, Is.InstanceOf<SampleStructure>());
|
||||
Assert.That(target.Values, Is.Not.Null);
|
||||
Assert.That(target.Values.Length, Is.EqualTo(3));
|
||||
Assert.That(target.Values[0], Is.EqualTo(1));
|
||||
@ -438,7 +438,7 @@ internal class StringTests
|
||||
var expected = new byte[] { 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64 };
|
||||
byte[] actual = "Hello World".GetBytes();
|
||||
|
||||
CollectionAssert.AreEqual(expected, actual);
|
||||
Assert.That(actual, Is.EqualTo(expected).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -447,7 +447,7 @@ internal class StringTests
|
||||
var expected = new byte[] { 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64 };
|
||||
byte[] actual = "Hello World".GetBytes(Encoding.ASCII);
|
||||
|
||||
CollectionAssert.AreEqual(expected, actual);
|
||||
Assert.That(actual, Is.EqualTo(expected).AsCollection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -1004,7 +1004,6 @@ internal class StringTests
|
||||
|
||||
private struct SampleStructure
|
||||
{
|
||||
[JsonPropertyName("values")]
|
||||
public int[] Values { get; set; }
|
||||
[JsonPropertyName("values")] public int[] Values { get; set; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user