fix: Adds ISpanParsable and fixes command conditionals (#1241)

* Adds `ISpanParsable<T>`
* Removes `[Parsable]`
* Fixes querying by serial, body, and a few others.
* Adds `Parse` to `Rectangle3D`
* Fixes AutoArchive NPE


Closes #1209
This commit is contained in:
Kamron Batman 2022-11-12 00:26:02 -08:00 • committed by GitHub
parent d494a9c78c
commit 03fb36c869
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 1119 additions and 271 deletions

View file

@ -69,4 +69,60 @@ public class Point3DTests
Assert.False(p4.TryFormat(array, out var cp4, null, null));
Assert.Equal(0, cp4);
}
[Fact]
public void TestPoint3DTryParse()
{
// Happy Path
Assert.True(Point3D.TryParse("(101, 23, 55)", null, out var p));
Assert.Equal(new Point3D(101, 23, 55), p);
Assert.Equal(new Point3D(101, 23, 55), Point3D.Parse("(101, 23, 55)", null));
// Trimming
Assert.True(Point3D.TryParse(" (101,23 ,55) ", null, out p));
Assert.Equal(new Point3D(101, 23, 55), p);
Assert.Equal(new Point3D(101, 23, 55), Point3D.Parse(" (101,23 ,55) ", null));
// No parenthesis
Assert.False(Point3D.TryParse("101, 23 55)", null, out p));
Assert.Equal(default, p);
Assert.Throws<FormatException>(() => Point3D.Parse("101, 23, 55)", null));
Assert.False(Point3D.TryParse("(101, 23, 55", null, out p));
Assert.Equal(default, p);
Assert.Throws<FormatException>(() => Point3D.Parse("(101, 23, 55", null));
// No numbers
Assert.False(Point3D.TryParse("()", null, out p));
Assert.Equal(default, p);
Assert.Throws<FormatException>(() => Point3D.Parse("()", null));
Assert.False(Point3D.TryParse("(,)", null, out p));
Assert.Equal(default, p);
Assert.Throws<FormatException>(() => Point3D.Parse("(,)", null));
Assert.False(Point3D.TryParse("(|)", null, out p));
Assert.Equal(default, p);
Assert.Throws<FormatException>(() => Point3D.Parse("(|)", null));
Assert.False(Point3D.TryParse("(101)", null, out p));
Assert.Equal(default, p);
Assert.Throws<FormatException>(() => Point3D.Parse("(101)", null));
Assert.False(Point3D.TryParse("(101,)", null, out p));
Assert.Equal(default, p);
Assert.Throws<FormatException>(() => Point3D.Parse("(101,)", null));
Assert.False(Point3D.TryParse("(,23)", null, out p));
Assert.Equal(default, p);
Assert.Throws<FormatException>(() => Point3D.Parse("(,23)", null));
Assert.False(Point3D.TryParse("(,23,55)", null, out p));
Assert.Equal(default, p);
Assert.Throws<FormatException>(() => Point3D.Parse("(,23,55)", null));
Assert.False(Point3D.TryParse("(,23,)", null, out p));
Assert.Equal(default, p);
Assert.Throws<FormatException>(() => Point3D.Parse("(,23,)", null));
}
}