|
|
@@ -16,7 +16,7 @@ namespace TechbloxModdingAPI.Blocks |
|
|
|
[APITestClass] |
|
|
|
public static class BlockTests |
|
|
|
{ |
|
|
|
[APITestCase(TestType.EditMode)] |
|
|
|
[APITestCase(TestType.Game)] //At least one block must be placed for simulation to work |
|
|
|
public static void TestPlaceNew() |
|
|
|
{ |
|
|
|
Block newBlock = Block.PlaceNew(BlockIDs.Cube, Unity.Mathematics.float3.zero); |
|
|
@@ -81,10 +81,9 @@ namespace TechbloxModdingAPI.Blocks |
|
|
|
{ |
|
|
|
Block newBlock = Block.PlaceNew(BlockIDs.DampedSpring, Unity.Mathematics.float3.zero + 1); |
|
|
|
DampedSpring b = null; // Note: the assignment operation is a lambda, which slightly confuses the compiler |
|
|
|
Assert.Errorless(() => { b = newBlock.Specialise<DampedSpring>(); }, "Block.Specialize<Servo>() raised an exception: ", "Block.Specialize<DampedSpring>() completed without issue."); |
|
|
|
if (!Assert.NotNull(b, "Block.Specialize<DampedSpring>() returned null, possibly because it failed silently.", "Specialized DampedSpring is not null.")) return; |
|
|
|
if (!Assert.CloseTo(b.Stiffness, 1.0f, $"DampedSpring.Stiffness {b.Stiffness} does not equal default value, possibly because it failed silently.", "DampedSpring.Stiffness is close enough to default.")) return; |
|
|
|
if (!Assert.CloseTo(b.Damping, 0.1f, $"DampedSpring.Damping {b.Damping} does not equal default value, possibly because it failed silently.", "DampedSpring.Damping is close enough to default.")) return; |
|
|
|
Assert.Errorless(() => { b = (DampedSpring) newBlock; }, "Casting block to DampedSpring raised an exception: ", "Casting block to DampedSpring completed without issue."); |
|
|
|
if (!Assert.CloseTo(b.SpringFrequency, 30f, $"DampedSpring.SpringFrequency {b.SpringFrequency} does not equal default value, possibly because it failed silently.", "DampedSpring.SpringFrequency is close enough to default.")) return; |
|
|
|
if (!Assert.CloseTo(b.Damping, 30f, $"DampedSpring.Damping {b.Damping} does not equal default value, possibly because it failed silently.", "DampedSpring.Damping is close enough to default.")) return; |
|
|
|
if (!Assert.CloseTo(b.MaxExtension, 0.3f, $"DampedSpring.MaxExtension {b.MaxExtension} does not equal default value, possibly because it failed silently.", "DampedSpring.MaxExtension is close enough to default.")) return; |
|
|
|
} |
|
|
|
|
|
|
|