Skip to content

Commit

Permalink
Add StorageInteractionTest (space-wizards#28541)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectroJr authored Jun 3, 2024
1 parent 98ab251 commit 5e51a1d
Show file tree
Hide file tree
Showing 18 changed files with 427 additions and 190 deletions.
2 changes: 1 addition & 1 deletion Content.IntegrationTests/Tests/Chemistry/DispenserTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public async Task InsertEjectBuiTest()
ToggleNeedPower();

// Insert beaker
await Interact("Beaker");
await InteractUsing("Beaker");
Assert.That(Hands.ActiveHandEntity, Is.Null);

// Open BUI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ public async Task ConstructComputer()
await StartConstruction(Computer);

// Initial interaction (ghost turns into real entity)
await Interact(Steel, 5);
ClientAssertPrototype(ComputerFrame, ClientTarget);
Target = CTestSystem.Ghosts[ClientTarget!.Value.GetHashCode()];
ClientTarget = null;
await InteractUsing(Steel, 5);
ClientAssertPrototype(ComputerFrame, Target);

// Perform construction steps
await Interact(
Expand All @@ -41,7 +39,7 @@ public async Task DeconstructComputer()
await StartDeconstruction(ComputerId);

// Initial interaction turns id computer into generic computer
await Interact(Screw);
await InteractUsing(Screw);
AssertPrototype(ComputerFrame);

// Perform deconstruction steps
Expand Down Expand Up @@ -71,7 +69,7 @@ public async Task ChangeComputer()
await SpawnTarget(ComputerId);

// Initial interaction turns id computer into generic computer
await Interact(Screw);
await InteractUsing(Screw);
AssertPrototype(ComputerFrame);

// Perform partial deconstruction steps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,22 @@ public async Task WindowOnGrille()
{
// Construct Grille
await StartConstruction(Grille);
await Interact(Rod, 10);
ClientAssertPrototype(Grille, ClientTarget);

Target = CTestSystem.Ghosts[ClientTarget!.Value.GetHashCode()];
await InteractUsing(Rod, 10);
ClientAssertPrototype(Grille, Target);
var grille = Target;

// Construct Window
await StartConstruction(Window);
await Interact(Glass, 10);
ClientAssertPrototype(Window, ClientTarget);
Target = CTestSystem.Ghosts[ClientTarget!.Value.GetHashCode()];
await InteractUsing(Glass, 10);
ClientAssertPrototype(Window, Target);

// Deconstruct Window
await Interact(Screw, Wrench);
AssertDeleted();

// Deconstruct Grille
Target = grille;
await Interact(Cut);
await InteractUsing(Cut);
AssertDeleted();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ public sealed class MachineConstruction : InteractionTest
public async Task ConstructProtolathe()
{
await StartConstruction(MachineFrame);
await Interact(Steel, 5);
ClientAssertPrototype(Unfinished, ClientTarget);
Target = CTestSystem.Ghosts[ClientTarget!.Value.GetHashCode()];
await InteractUsing(Steel, 5);
ClientAssertPrototype(Unfinished, Target);
await Interact(Wrench, Cable);
AssertPrototype(MachineFrame);
await Interact(ProtolatheBoard, Bin1, Bin1, Manipulator1, Manipulator1, Beaker, Beaker, Screw);
Expand Down Expand Up @@ -51,7 +50,7 @@ public async Task ChangeMachine()
AssertPrototype(MachineFrame);

// Change it into an autolathe
await Interact("AutolatheMachineCircuitboard");
await InteractUsing("AutolatheMachineCircuitboard");
AssertPrototype(MachineFrame);
await Interact(Bin1, Bin1, Bin1, Manipulator1, Glass, Screw);
AssertPrototype("Autolathe");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ public async Task WiresPanelScrewing(string prototype)

// Open & close panel
Assert.That(comp.Open, Is.False);
await Interact(Screw);
await InteractUsing(Screw);
Assert.That(comp.Open, Is.True);
await Interact(Screw);
await InteractUsing(Screw);
Assert.That(comp.Open, Is.False);

// Interrupted DoAfters
await Interact(Screw, awaitDoAfters: false);
await InteractUsing(Screw, awaitDoAfters: false);
await CancelDoAfters();
Assert.That(comp.Open, Is.False);
await Interact(Screw);
await InteractUsing(Screw);
Assert.That(comp.Open, Is.True);
await Interact(Screw, awaitDoAfters: false);
await InteractUsing(Screw, awaitDoAfters: false);
await CancelDoAfters();
Assert.That(comp.Open, Is.True);
await Interact(Screw);
await InteractUsing(Screw);
Assert.That(comp.Open, Is.False);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public async Task DeconstructTable()
{
await StartDeconstruction("Table");
Assert.That(Comp<PlaceableSurfaceComponent>().IsPlaceable);
await Interact(Wrench);
await InteractUsing(Wrench);
AssertPrototype("TableFrame");
await Interact(Wrench);
await InteractUsing(Wrench);
AssertDeleted();
await AssertEntityLookup((Steel, 1), (Rod, 2));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ public sealed class WallConstruction : InteractionTest
public async Task ConstructWall()
{
await StartConstruction(Wall);
await Interact(Steel, 2);
await InteractUsing(Steel, 2);
Assert.That(Hands.ActiveHandEntity, Is.Null);
ClientAssertPrototype(Girder, ClientTarget);
Target = CTestSystem.Ghosts[ClientTarget!.Value.GetHashCode()];
await Interact(Steel, 2);
ClientAssertPrototype(Girder, Target);
await InteractUsing(Steel, 2);
Assert.That(Hands.ActiveHandEntity, Is.Null);
AssertPrototype(WallSolid);
}
Expand All @@ -25,7 +24,7 @@ public async Task ConstructWall()
public async Task DeconstructWall()
{
await StartDeconstruction(WallSolid);
await Interact(Weld);
await InteractUsing(Weld);
AssertPrototype(Girder);
await Interact(Wrench, Screw);
AssertDeleted();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public sealed class WindowConstruction : InteractionTest
public async Task ConstructWindow()
{
await StartConstruction(Window);
await Interact(Glass, 5);
ClientAssertPrototype(Window, ClientTarget);
await InteractUsing(Glass, 5);
ClientAssertPrototype(Window, Target);
}

[Test]
Expand All @@ -28,8 +28,8 @@ public async Task DeconstructWindow()
public async Task ConstructReinforcedWindow()
{
await StartConstruction(RWindow);
await Interact(RGlass, 5);
ClientAssertPrototype(RWindow, ClientTarget);
await InteractUsing(RGlass, 5);
ClientAssertPrototype(RWindow, Target);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public async Task RepairReinforcedWindow()
Assert.That(comp.Damage.GetTotal(), Is.GreaterThan(FixedPoint2.Zero));

// Repair the entity
await Interact(Weld);
await InteractUsing(Weld);
Assert.That(comp.Damage.GetTotal(), Is.EqualTo(FixedPoint2.Zero));

// Validate that we can still deconstruct the entity (i.e., that welding deconstruction is not blocked).
Expand Down
39 changes: 19 additions & 20 deletions Content.IntegrationTests/Tests/DoAfter/DoAfterCancellationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,69 +16,68 @@ public sealed class DoAfterCancellationTests : InteractionTest
public async Task CancelWallDeconstruct()
{
await StartDeconstruction(WallConstruction.WallSolid);
await Interact(Weld, awaitDoAfters: false);
await InteractUsing(Weld, awaitDoAfters: false);

// Failed do-after has no effect
await CancelDoAfters();
AssertPrototype(WallConstruction.WallSolid);

// Second attempt works fine
await Interact(Weld);
await InteractUsing(Weld);
AssertPrototype(WallConstruction.Girder);

// Repeat for wrenching interaction
AssertAnchored();
await Interact(Wrench, awaitDoAfters: false);
await InteractUsing(Wrench, awaitDoAfters: false);
await CancelDoAfters();
AssertAnchored();
AssertPrototype(WallConstruction.Girder);
await Interact(Wrench);
await InteractUsing(Wrench);
AssertAnchored(false);

// Repeat for screwdriver interaction.
AssertExists();
await Interact(Screw, awaitDoAfters: false);
await InteractUsing(Screw, awaitDoAfters: false);
await CancelDoAfters();
AssertExists();
await Interact(Screw);
await InteractUsing(Screw);
AssertDeleted();
}

[Test]
public async Task CancelWallConstruct()
{
await StartConstruction(WallConstruction.Wall);
await Interact(Steel, 5, awaitDoAfters: false);
await InteractUsing(Steel, 5, awaitDoAfters: false);
await CancelDoAfters();

await Interact(Steel, 5);
ClientAssertPrototype(WallConstruction.Girder, ClientTarget);
Target = CTestSystem.Ghosts[ClientTarget!.Value.GetHashCode()];
await Interact(Steel, 5, awaitDoAfters: false);
await InteractUsing(Steel, 5);
ClientAssertPrototype(WallConstruction.Girder, Target);
await InteractUsing(Steel, 5, awaitDoAfters: false);
await CancelDoAfters();
AssertPrototype(WallConstruction.Girder);

await Interact(Steel, 5);
await InteractUsing(Steel, 5);
AssertPrototype(WallConstruction.WallSolid);
}

[Test]
public async Task CancelTilePry()
{
await SetTile(Floor);
await Interact(Pry, awaitDoAfters: false);
await InteractUsing(Pry, awaitDoAfters: false);
await CancelDoAfters();
await AssertTile(Floor);

await Interact(Pry);
await InteractUsing(Pry);
await AssertTile(Plating);
}

[Test]
public async Task CancelRepeatedTilePry()
{
await SetTile(Floor);
await Interact(Pry, awaitDoAfters: false);
await InteractUsing(Pry, awaitDoAfters: false);
await RunTicks(1);
Assert.That(ActiveDoAfters.Count(), Is.EqualTo(1));
await AssertTile(Floor);
Expand All @@ -89,7 +88,7 @@ public async Task CancelRepeatedTilePry()
await AssertTile(Floor);

// Third do after will work fine
await Interact(Pry);
await InteractUsing(Pry);
Assert.That(ActiveDoAfters.Count(), Is.EqualTo(0));
await AssertTile(Plating);
}
Expand All @@ -102,7 +101,7 @@ public async Task CancelRepeatedWeld()

Assert.That(comp.IsWelded, Is.False);

await Interact(Weld, awaitDoAfters: false);
await InteractUsing(Weld, awaitDoAfters: false);
await RunTicks(1);
Assert.Multiple(() =>
{
Expand All @@ -120,15 +119,15 @@ public async Task CancelRepeatedWeld()
});

// Third do after will work fine
await Interact(Weld);
await InteractUsing(Weld);
Assert.Multiple(() =>
{
Assert.That(ActiveDoAfters.Count(), Is.EqualTo(0));
Assert.That(comp.IsWelded, Is.True);
});

// Repeat test for un-welding
await Interact(Weld, awaitDoAfters: false);
await InteractUsing(Weld, awaitDoAfters: false);
await RunTicks(1);
Assert.Multiple(() =>
{
Expand All @@ -141,7 +140,7 @@ public async Task CancelRepeatedWeld()
Assert.That(ActiveDoAfters.Count(), Is.EqualTo(0));
Assert.That(comp.IsWelded, Is.True);
});
await Interact(Weld);
await InteractUsing(Weld);
Assert.Multiple(() =>
{
Assert.That(ActiveDoAfters.Count(), Is.EqualTo(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public async Task HeadsetKeys()
});

// Remove the key
await Interact(Screw);
await InteractUsing(Screw);
Assert.Multiple(() =>
{
Assert.That(comp.KeyContainer.ContainedEntities, Has.Count.EqualTo(0));
Expand All @@ -34,7 +34,7 @@ public async Task HeadsetKeys()
await AssertEntityLookup(("EncryptionKeyCommon", 1));

// Re-insert a key.
await Interact("EncryptionKeyCentCom");
await InteractUsing("EncryptionKeyCentCom");
Assert.Multiple(() =>
{
Assert.That(comp.KeyContainer.ContainedEntities, Has.Count.EqualTo(1));
Expand All @@ -59,7 +59,7 @@ public async Task CommsServerKeys()
});

// cannot remove keys without opening panel
await Interact(Pry);
await InteractUsing(Pry);
Assert.Multiple(() =>
{
Assert.That(comp.KeyContainer.ContainedEntities, Has.Count.GreaterThan(0));
Expand All @@ -68,7 +68,7 @@ public async Task CommsServerKeys()
});

// Open panel
await Interact(Screw);
await InteractUsing(Screw);
Assert.Multiple(() =>
{
Assert.That(panel.Open, Is.True);
Expand All @@ -79,15 +79,15 @@ public async Task CommsServerKeys()
});

// Now remove the keys
await Interact(Pry);
await InteractUsing(Pry);
Assert.Multiple(() =>
{
Assert.That(comp.KeyContainer.ContainedEntities, Has.Count.EqualTo(0));
Assert.That(comp.Channels, Has.Count.EqualTo(0));
});

// Reinsert a key
await Interact("EncryptionKeyCentCom");
await InteractUsing("EncryptionKeyCentCom");
Assert.Multiple(() =>
{
Assert.That(comp.KeyContainer.ContainedEntities, Has.Count.EqualTo(1));
Expand All @@ -97,7 +97,7 @@ public async Task CommsServerKeys()
});

// Remove it again
await Interact(Pry);
await InteractUsing(Pry);
Assert.Multiple(() =>
{
Assert.That(comp.KeyContainer.ContainedEntities, Has.Count.EqualTo(0));
Expand All @@ -106,7 +106,7 @@ public async Task CommsServerKeys()

// Prying again will start deconstructing the machine.
AssertPrototype("TelecomServerFilled");
await Interact(Pry);
await InteractUsing(Pry);
AssertPrototype("MachineFrame");
}
}
Loading

0 comments on commit 5e51a1d

Please sign in to comment.