Reduce vendor restocking time + some code cleanup (#16025)
This commit is contained in:
@@ -3,12 +3,10 @@ using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Content.Server.Storage.Components;
|
||||
using Content.Server.VendingMachines;
|
||||
using Content.Server.VendingMachines.Restock;
|
||||
using Content.Shared.Cargo.Prototypes;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
@@ -20,7 +18,7 @@ namespace Content.IntegrationTests.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
[TestOf(typeof(VendingMachineRestockComponent))]
|
||||
[TestOf(typeof(VendingMachineRestockSystem))]
|
||||
[TestOf(typeof(VendingMachineSystem))]
|
||||
public sealed class VendingMachineRestockTest : EntitySystem
|
||||
{
|
||||
private const string Prototypes = @"
|
||||
@@ -209,25 +207,24 @@ namespace Content.IntegrationTests.Tests
|
||||
Assert.True(entityManager.TryGetComponent(packageWrong, out restockWrongComponent!), $"Wrong package has no {nameof(VendingMachineRestockComponent)}");
|
||||
Assert.True(entityManager.TryGetComponent(machine, out machineWiresPanel!), $"Machine has no {nameof(WiresPanelComponent)}");
|
||||
|
||||
var systemRestock = entitySystemManager.GetEntitySystem<VendingMachineRestockSystem>();
|
||||
var systemMachine = entitySystemManager.GetEntitySystem<VendingMachineSystem>();
|
||||
|
||||
// Test that the panel needs to be opened first.
|
||||
Assert.That(systemRestock.TryAccessMachine(packageRight, restockRightComponent, machineComponent, user, machine), Is.False, "Right package is able to restock without opened access panel");
|
||||
Assert.That(systemRestock.TryAccessMachine(packageWrong, restockWrongComponent, machineComponent, user, machine), Is.False, "Wrong package is able to restock without opened access panel");
|
||||
Assert.That(systemMachine.TryAccessMachine(packageRight, restockRightComponent, machineComponent, user, machine), Is.False, "Right package is able to restock without opened access panel");
|
||||
Assert.That(systemMachine.TryAccessMachine(packageWrong, restockWrongComponent, machineComponent, user, machine), Is.False, "Wrong package is able to restock without opened access panel");
|
||||
|
||||
var systemWires = entitySystemManager.GetEntitySystem<WiresSystem>();
|
||||
// Open the panel.
|
||||
systemWires.TogglePanel(machine, machineWiresPanel, true);
|
||||
|
||||
// Test that the right package works for the right machine.
|
||||
Assert.That(systemRestock.TryAccessMachine(packageRight, restockRightComponent, machineComponent, user, machine), Is.True, "Correct package is unable to restock with access panel opened");
|
||||
Assert.That(systemMachine.TryAccessMachine(packageRight, restockRightComponent, machineComponent, user, machine), Is.True, "Correct package is unable to restock with access panel opened");
|
||||
|
||||
// Test that the wrong package does not work.
|
||||
Assert.That(systemRestock.TryMatchPackageToMachine(packageWrong, restockWrongComponent, machineComponent, user, machine), Is.False, "Package with invalid canRestock is able to restock machine");
|
||||
Assert.That(systemMachine.TryMatchPackageToMachine(packageWrong, restockWrongComponent, machineComponent, user, machine), Is.False, "Package with invalid canRestock is able to restock machine");
|
||||
|
||||
// Test that the right package does work.
|
||||
Assert.That(systemRestock.TryMatchPackageToMachine(packageRight, restockRightComponent, machineComponent, user, machine), Is.True, "Package with valid canRestock is unable to restock machine");
|
||||
Assert.That(systemMachine.TryMatchPackageToMachine(packageRight, restockRightComponent, machineComponent, user, machine), Is.True, "Package with valid canRestock is unable to restock machine");
|
||||
|
||||
// Make sure there's something in there to begin with.
|
||||
Assert.That(systemMachine.GetAvailableInventory(machine, machineComponent).Count, Is.GreaterThan(0),
|
||||
|
||||
Reference in New Issue
Block a user