test: return coverage to 100% (#76)

This commit is contained in:
Oliver Booth 2023-04-05 23:18:14 +01:00
parent fcdcf54aa3
commit 4a0e3c10d7
No known key found for this signature in database
GPG Key ID: 20BEB9DC87961025
14 changed files with 105 additions and 11 deletions

View File

@ -55,7 +55,7 @@ public class ByteTests
Assert.Multiple(() =>
{
Span<bool> bits = stackalloc bool[8];
value.Unpack(bits);
value.UnpackInternal_Fallback(bits);
Assert.That(bits[0], Is.False);
Assert.That(bits[1], Is.False);

View File

@ -97,6 +97,9 @@ public class CircleFTests
{
Assert.That(CircleF.Empty, Is.Not.EqualTo(CircleF.Unit));
Assert.That(CircleF.Unit, Is.Not.EqualTo(CircleF.Empty));
Assert.That(CircleF.Empty != CircleF.Unit);
Assert.That(CircleF.Unit != CircleF.Empty);
});
}
@ -104,6 +107,7 @@ public class CircleFTests
public void Equals_ShouldBeFalse_GivenDifferentObjects()
{
Assert.That(CircleF.Empty, Is.Not.EqualTo(null));
Assert.That(CircleF.Empty.Equals(null), Is.False);
}
[Test]
@ -131,6 +135,7 @@ public class CircleFTests
Assert.Multiple(() =>
{
Assert.That(converted, Is.EqualTo((Circle)unitCircle));
Assert.That(converted == (Circle)unitCircle);
Assert.That(converted.Radius, Is.EqualTo(unitCircle.Radius));
Assert.That((PointF)converted.Center, Is.EqualTo(unitCircle.Center));
});
@ -141,6 +146,9 @@ public class CircleFTests
{
Assert.That(CircleF.Unit, Is.GreaterThan(CircleF.Empty));
Assert.That(CircleF.Unit, Is.GreaterThanOrEqualTo(CircleF.Empty));
Assert.That(CircleF.Unit > CircleF.Empty);
Assert.That(CircleF.Unit >= CircleF.Empty);
}
[Test]
@ -152,6 +160,7 @@ public class CircleFTests
Assert.Multiple(() =>
{
Assert.That(converted, Is.EqualTo((CircleF)unitCircle));
Assert.That(converted == unitCircle);
Assert.That(converted.Radius, Is.EqualTo(unitCircle.Radius));
Assert.That(converted.Center, Is.EqualTo((PointF)unitCircle.Center));
});
@ -164,6 +173,9 @@ public class CircleFTests
{
Assert.That(CircleF.Empty, Is.LessThan(CircleF.Unit));
Assert.That(CircleF.Empty, Is.LessThanOrEqualTo(CircleF.Unit));
Assert.That(CircleF.Empty < CircleF.Unit);
Assert.That(CircleF.Empty <= CircleF.Unit);
});
}

View File

@ -94,6 +94,9 @@ public class CircleTests
{
Assert.That(Circle.Empty, Is.Not.EqualTo(Circle.Unit));
Assert.That(Circle.Unit, Is.Not.EqualTo(Circle.Empty));
Assert.That(Circle.Empty != Circle.Unit);
Assert.That(Circle.Unit != Circle.Empty);
});
}
@ -101,6 +104,7 @@ public class CircleTests
public void Equals_ShouldBeFalse_GivenDifferentObjects()
{
Assert.That(Circle.Empty, Is.Not.EqualTo(null));
Assert.That(Circle.Empty.Equals(null), Is.False);
}
[Test]
@ -122,15 +126,25 @@ public class CircleTests
[Test]
public void op_GreaterThan_True_GivenUnitAndEmptyCircle()
{
Assert.That(Circle.Unit, Is.GreaterThan(Circle.Empty));
Assert.That(Circle.Unit, Is.GreaterThanOrEqualTo(Circle.Empty));
Assert.Multiple(() =>
{
Assert.That(Circle.Unit, Is.GreaterThan(Circle.Empty));
Assert.That(Circle.Unit, Is.GreaterThanOrEqualTo(Circle.Empty));
Assert.That(Circle.Unit > Circle.Empty);
Assert.That(Circle.Unit >= Circle.Empty);
});
}
[Test]
public void op_LessThan_True_GivenEmptyAndUnitCircle()
{
Assert.That(Circle.Empty, Is.LessThan(Circle.Unit));
Assert.That(Circle.Empty, Is.LessThanOrEqualTo(Circle.Unit));
Assert.Multiple(() =>
{
Assert.That(Circle.Empty, Is.LessThan(Circle.Unit));
Assert.That(Circle.Empty, Is.LessThanOrEqualTo(Circle.Unit));
Assert.That(Circle.Empty < Circle.Unit);
Assert.That(Circle.Empty <= Circle.Unit);
});
}
[Test]

View File

@ -29,12 +29,15 @@ public class CuboidTests
var cube2 = Cuboid.Cube;
Assert.That(cube1, Is.EqualTo(cube2));
Assert.That(cube2, Is.EqualTo(cube1));
Assert.That(cube1 == cube2);
Assert.That(cube2 == cube1);
}
[Test]
public void Equals_ShouldBeFalse_GivenDifferentCubes()
{
Assert.That(Cuboid.Empty, Is.Not.EqualTo(Cuboid.Cube));
Assert.That(Cuboid.Empty != Cuboid.Cube);
}
[Test]

View File

@ -49,18 +49,22 @@ public class EllipseFTests
var unitEllipse2 = EllipseF.Unit;
Assert.That(unitEllipse2, Is.EqualTo(unitEllipse1));
Assert.That(unitEllipse1, Is.EqualTo(unitEllipse2));
Assert.That(unitEllipse2 == unitEllipse1);
Assert.That(unitEllipse1 == unitEllipse2);
}
[Test]
public void Equals_ShouldBeFalse_GivenDifferentEllipses()
{
Assert.That(EllipseF.Empty, Is.Not.EqualTo(EllipseF.Unit));
Assert.That(EllipseF.Empty != EllipseF.Unit);
}
[Test]
public void Equals_ShouldBeFalse_GivenDifferentObjects()
{
Assert.That(EllipseF.Unit, Is.Not.EqualTo(null));
Assert.That(EllipseF.Unit.Equals(null), Is.False);
}
[Test]
@ -100,6 +104,7 @@ public class EllipseFTests
Assert.Multiple(() =>
{
Assert.That(converted, Is.EqualTo((Ellipse)unitEllipse));
Assert.That(converted == unitEllipse);
Assert.That(converted.HorizontalRadius, Is.EqualTo(unitEllipse.HorizontalRadius));
Assert.That(converted.VerticalRadius, Is.EqualTo(unitEllipse.VerticalRadius));
Assert.That((PointF)converted.Center, Is.EqualTo(unitEllipse.Center));
@ -115,6 +120,7 @@ public class EllipseFTests
Assert.Multiple(() =>
{
Assert.That(converted, Is.EqualTo((EllipseF)unitCircle));
Assert.That(converted == unitCircle);
Assert.That(converted.HorizontalRadius, Is.EqualTo(unitCircle.Radius));
Assert.That(converted.VerticalRadius, Is.EqualTo(unitCircle.Radius));
Assert.That(converted.Center, Is.EqualTo((PointF)unitCircle.Center));

View File

@ -48,6 +48,8 @@ public class EllipseTests
{
Assert.That(unitEllipse2, Is.EqualTo(unitEllipse1));
Assert.That(unitEllipse1, Is.EqualTo(unitEllipse2));
Assert.That(unitEllipse2 == unitEllipse1);
Assert.That(unitEllipse1 == unitEllipse2);
});
}
@ -58,6 +60,8 @@ public class EllipseTests
{
Assert.That(Ellipse.Empty, Is.Not.EqualTo(Ellipse.Unit));
Assert.That(Ellipse.Unit, Is.Not.EqualTo(Ellipse.Empty));
Assert.That(Ellipse.Empty != Ellipse.Unit);
Assert.That(Ellipse.Unit != Ellipse.Empty);
});
}

View File

@ -76,18 +76,21 @@ public class Line3DTests
Line3D second = Line3D.One;
Assert.That(second, Is.EqualTo(first));
Assert.That(second == first);
}
[Test]
public void Equals_ShouldBeFalse_GivenDifferentLines()
{
Assert.That(Line3D.Empty, Is.Not.EqualTo(Line3D.One));
Assert.That(Line3D.Empty != Line3D.One);
}
[Test]
public void Equals_ShouldBeFalse_GivenDifferentObjects()
{
Assert.That(Line3D.One, Is.Not.EqualTo(null));
Assert.That(Line3D.One.Equals(null), Is.False);
}
[Test]
@ -145,6 +148,9 @@ public class Line3DTests
{
Assert.That(Line3D.One, Is.GreaterThan(Line3D.Empty));
Assert.That(Line3D.One, Is.GreaterThanOrEqualTo(Line3D.Empty));
Assert.That(Line3D.One > Line3D.Empty);
Assert.That(Line3D.One >= Line3D.Empty);
}
[Test]
@ -177,6 +183,7 @@ public class Line3DTests
Assert.Multiple(() =>
{
Assert.That(converted, Is.EqualTo((Line3D)oneLine));
Assert.That(converted == oneLine);
Assert.That(converted.Length, Is.EqualTo(oneLine.Length));
Assert.That(converted.Start, Is.EqualTo(expectedStart));
Assert.That(converted.End, Is.EqualTo(expectedEnd));
@ -188,5 +195,7 @@ public class Line3DTests
{
Assert.That(Line3D.Empty, Is.LessThan(Line3D.One));
Assert.That(Line3D.Empty, Is.LessThanOrEqualTo(Line3D.One));
Assert.That(Line3D.Empty < Line3D.One);
Assert.That(Line3D.Empty <= Line3D.One);
}
}

View File

@ -71,6 +71,8 @@ public class LineFTests
{
Assert.That(second, Is.EqualTo(first));
Assert.That(first, Is.EqualTo(second));
Assert.That(second == first);
Assert.That(first == second);
});
}
@ -81,6 +83,8 @@ public class LineFTests
{
Assert.That(LineF.Empty, Is.Not.EqualTo(LineF.One));
Assert.That(LineF.One, Is.Not.EqualTo(LineF.Empty));
Assert.That(LineF.Empty != LineF.One);
Assert.That(LineF.One != LineF.Empty);
});
}
@ -88,6 +92,7 @@ public class LineFTests
public void Equals_ShouldBeFalse_GivenDifferentObjects()
{
Assert.That(LineF.One, Is.Not.EqualTo(null));
Assert.That(LineF.One.Equals(null), Is.False);
}
[Test]
@ -115,6 +120,7 @@ public class LineFTests
Assert.Multiple(() =>
{
Assert.That(converted, Is.EqualTo((Line)oneLine));
Assert.That(converted == oneLine);
Assert.That(converted.Length, Is.EqualTo(oneLine.Length));
Assert.That((PointF)converted.Start, Is.EqualTo(oneLine.Start));
Assert.That((PointF)converted.End, Is.EqualTo(oneLine.End));
@ -126,6 +132,8 @@ public class LineFTests
{
Assert.That(LineF.One, Is.GreaterThan(LineF.Empty));
Assert.That(LineF.One, Is.GreaterThanOrEqualTo(LineF.Empty));
Assert.That(LineF.One > LineF.Empty);
Assert.That(LineF.One >= LineF.Empty);
}
[Test]
@ -137,6 +145,7 @@ public class LineFTests
Assert.Multiple(() =>
{
Assert.That(converted, Is.EqualTo((LineF)oneLine));
Assert.That(converted == oneLine);
Assert.That(converted.Length, Is.EqualTo(oneLine.Length));
Assert.That(converted.Start, Is.EqualTo((PointF)oneLine.Start));
Assert.That(converted.End, Is.EqualTo((PointF)oneLine.End));
@ -148,5 +157,7 @@ public class LineFTests
{
Assert.That(LineF.Empty, Is.LessThan(LineF.One));
Assert.That(LineF.Empty, Is.LessThanOrEqualTo(LineF.One));
Assert.That(LineF.Empty < LineF.One);
Assert.That(LineF.Empty <= LineF.One);
}
}

View File

@ -53,6 +53,8 @@ public class LineTests
{
Assert.That(second, Is.EqualTo(first));
Assert.That(first, Is.EqualTo(second));
Assert.That(second == first);
Assert.That(first == second);
});
}
@ -63,6 +65,8 @@ public class LineTests
{
Assert.That(Line.Empty, Is.Not.EqualTo(Line.One));
Assert.That(Line.One, Is.Not.EqualTo(Line.Empty));
Assert.That(Line.Empty != Line.One);
Assert.That(Line.One != Line.Empty);
});
}
@ -70,6 +74,7 @@ public class LineTests
public void Equals_ShouldBeFalse_GivenDifferentObjects()
{
Assert.That(Line.One, Is.Not.EqualTo(null));
Assert.That(Line.One.Equals(null), Is.False);
}
[Test]
@ -111,6 +116,8 @@ public class LineTests
{
Assert.That(Line.One, Is.GreaterThan(Line.Empty));
Assert.That(Line.One, Is.GreaterThanOrEqualTo(Line.Empty));
Assert.That(Line.One > Line.Empty);
Assert.That(Line.One >= Line.Empty);
}
[Test]
@ -118,5 +125,7 @@ public class LineTests
{
Assert.That(Line.Empty, Is.LessThan(Line.One));
Assert.That(Line.Empty, Is.LessThanOrEqualTo(Line.One));
Assert.That(Line.Empty < Line.One);
Assert.That(Line.Empty <= Line.One);
}
}

View File

@ -108,6 +108,8 @@ public class PolygonFTests
{
Assert.That(second, Is.EqualTo(first));
Assert.That(first, Is.EqualTo(second));
Assert.That(second == first);
Assert.That(first == second);
});
}
@ -121,6 +123,8 @@ public class PolygonFTests
{
Assert.That(second, Is.EqualTo(first));
Assert.That(first, Is.EqualTo(second));
Assert.That(second == first);
Assert.That(first == second);
});
}
@ -134,6 +138,8 @@ public class PolygonFTests
{
Assert.That(second, Is.Not.EqualTo(first));
Assert.That(first, Is.Not.EqualTo(second));
Assert.That(second != first);
Assert.That(first != second);
});
}
@ -185,6 +191,7 @@ public class PolygonFTests
Assert.Multiple(() =>
{
Assert.That(converted, Is.EqualTo((PolygonF)polygon));
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));

View File

@ -52,7 +52,7 @@ public class PolygonTests
public void Constructor_ShouldThrowArgumentNullException_GivenNullEnumerableOfPoint()
{
IEnumerable<Point> vertices = null!;
Assert.Throws<ArgumentNullException>(() => new Polygon(vertices));
Assert.Throws<ArgumentNullException>(() => _ = new Polygon(vertices));
}
[Test]
@ -77,7 +77,7 @@ public class PolygonTests
public void CopyConstructor_ShouldThrowArgumentNullException_GivenNullPolygon()
{
Polygon polygon = null!;
Assert.Throws<ArgumentNullException>(() => new Polygon(polygon));
Assert.Throws<ArgumentNullException>(() => _ = new Polygon(polygon));
}
[Test]
@ -90,6 +90,8 @@ public class PolygonTests
{
Assert.That(second, Is.EqualTo(first));
Assert.That(first, Is.EqualTo(second));
Assert.That(second == first);
Assert.That(first == second);
});
}
@ -103,6 +105,8 @@ public class PolygonTests
{
Assert.That(second, Is.EqualTo(first));
Assert.That(first, Is.EqualTo(second));
Assert.That(second == first);
Assert.That(first == second);
});
}
@ -116,6 +120,8 @@ public class PolygonTests
{
Assert.That(second, Is.Not.EqualTo(first));
Assert.That(first, Is.Not.EqualTo(second));
Assert.That(second != first);
Assert.That(first != second);
});
}

View File

@ -105,6 +105,8 @@ public class PolyhedronTests
{
Assert.That(second, Is.EqualTo(first));
Assert.That(first, Is.EqualTo(second));
Assert.That(second == first);
Assert.That(first == second);
});
}
@ -118,6 +120,8 @@ public class PolyhedronTests
{
Assert.That(second, Is.Not.EqualTo(first));
Assert.That(first, Is.Not.EqualTo(second));
Assert.That(second != first);
Assert.That(first != second);
});
}

View File

@ -66,6 +66,8 @@ public class SphereTests
{
Assert.That(unitCircle2, Is.EqualTo(unitCircle1));
Assert.That(unitCircle1, Is.EqualTo(unitCircle2));
Assert.That(unitCircle2 == unitCircle1);
Assert.That(unitCircle1 == unitCircle2);
});
}
@ -73,6 +75,7 @@ public class SphereTests
public void Equals_ShouldBeFalse_GivenDifferentObjects()
{
Assert.That(Sphere.Unit, Is.Not.EqualTo(null));
Assert.That(Sphere.Unit.Equals(null), Is.False);
}
[Test]
@ -80,6 +83,8 @@ public class SphereTests
{
Assert.That(Sphere.Empty, Is.Not.EqualTo(Sphere.Unit));
Assert.That(Sphere.Unit, Is.Not.EqualTo(Sphere.Empty));
Assert.That(Sphere.Empty != Sphere.Unit);
Assert.That(Sphere.Unit != Sphere.Empty);
}
[Test]
@ -103,6 +108,8 @@ public class SphereTests
{
Assert.That(Sphere.Unit, Is.GreaterThan(Sphere.Empty));
Assert.That(Sphere.Unit, Is.GreaterThanOrEqualTo(Sphere.Empty));
Assert.That(Sphere.Unit > Sphere.Empty);
Assert.That(Sphere.Unit >= Sphere.Empty);
}
[Test]
@ -110,6 +117,8 @@ public class SphereTests
{
Assert.That(Sphere.Empty, Is.LessThan(Sphere.Unit));
Assert.That(Sphere.Empty, Is.LessThanOrEqualTo(Sphere.Unit));
Assert.That(Sphere.Empty < Sphere.Unit);
Assert.That(Sphere.Empty <= Sphere.Unit);
}
[Test]

View File

@ -59,10 +59,10 @@ public class MemberInfoTests
Func<CLSCompliantAttribute, bool> predicate = attribute => attribute.IsCompliant;
Assert.Multiple(() =>
{
Assert.That(typeof(byte).SelectFromCustomAttribute(predicate));
Assert.That(typeof(short).SelectFromCustomAttribute(predicate));
Assert.That(typeof(int).SelectFromCustomAttribute(predicate));
Assert.That(typeof(long).SelectFromCustomAttribute(predicate));
Assert.That(typeof(byte).SelectFromCustomAttribute(predicate, true));
Assert.That(typeof(short).SelectFromCustomAttribute(predicate, true));
Assert.That(typeof(int).SelectFromCustomAttribute(predicate, true));
Assert.That(typeof(long).SelectFromCustomAttribute(predicate, true));
});
}