Fix content.integration tests warnings (#17817)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Database;
|
||||
using NUnit.Framework;
|
||||
using Robust.Server.Console;
|
||||
using Robust.Server.Player;
|
||||
|
||||
@@ -17,7 +14,7 @@ namespace Content.IntegrationTests.Tests.Commands
|
||||
[Test]
|
||||
public async Task PardonTest()
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new (){Destructive = true});
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new() { Destructive = true });
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
var sPlayerManager = server.ResolveDependency<IPlayerManager>();
|
||||
@@ -30,17 +27,23 @@ namespace Content.IntegrationTests.Tests.Commands
|
||||
var clientId = clientSession.UserId;
|
||||
|
||||
// No bans on record
|
||||
Assert.That(await sDatabase.GetServerBanAsync(null, clientId, null), Is.Null);
|
||||
Assert.That(await sDatabase.GetServerBanAsync(1), Is.Null);
|
||||
Assert.That(await sDatabase.GetServerBansAsync(null, clientId, null), Is.Empty);
|
||||
Assert.Multiple(async () =>
|
||||
{
|
||||
Assert.That(await sDatabase.GetServerBanAsync(null, clientId, null), Is.Null);
|
||||
Assert.That(await sDatabase.GetServerBanAsync(1), Is.Null);
|
||||
Assert.That(await sDatabase.GetServerBansAsync(null, clientId, null), Is.Empty);
|
||||
});
|
||||
|
||||
// Try to pardon a ban that does not exist
|
||||
sConsole.ExecuteCommand("pardon 1");
|
||||
|
||||
// Still no bans on record
|
||||
Assert.That(await sDatabase.GetServerBanAsync(null, clientId, null), Is.Null);
|
||||
Assert.That(await sDatabase.GetServerBanAsync(1), Is.Null);
|
||||
Assert.That(await sDatabase.GetServerBansAsync(null, clientId, null), Is.Empty);
|
||||
Assert.Multiple(async () =>
|
||||
{
|
||||
Assert.That(await sDatabase.GetServerBanAsync(null, clientId, null), Is.Null);
|
||||
Assert.That(await sDatabase.GetServerBanAsync(1), Is.Null);
|
||||
Assert.That(await sDatabase.GetServerBansAsync(null, clientId, null), Is.Empty);
|
||||
});
|
||||
|
||||
var banReason = "test";
|
||||
|
||||
@@ -48,9 +51,12 @@ namespace Content.IntegrationTests.Tests.Commands
|
||||
sConsole.ExecuteCommand($"ban {clientSession.Name} {banReason} 1440");
|
||||
|
||||
// Should have one ban on record now
|
||||
Assert.That(await sDatabase.GetServerBanAsync(null, clientId, null), Is.Not.Null);
|
||||
Assert.That(await sDatabase.GetServerBanAsync(1), Is.Not.Null);
|
||||
Assert.That(await sDatabase.GetServerBansAsync(null, clientId, null), Has.Count.EqualTo(1));
|
||||
Assert.Multiple(async () =>
|
||||
{
|
||||
Assert.That(await sDatabase.GetServerBanAsync(null, clientId, null), Is.Not.Null);
|
||||
Assert.That(await sDatabase.GetServerBanAsync(1), Is.Not.Null);
|
||||
Assert.That(await sDatabase.GetServerBansAsync(null, clientId, null), Has.Count.EqualTo(1));
|
||||
});
|
||||
|
||||
// Try to pardon a ban that does not exist
|
||||
sConsole.ExecuteCommand("pardon 2");
|
||||
@@ -59,22 +65,23 @@ namespace Content.IntegrationTests.Tests.Commands
|
||||
Assert.That(await sDatabase.GetServerBanAsync(null, clientId, null), Is.Not.Null);
|
||||
|
||||
var ban = await sDatabase.GetServerBanAsync(1);
|
||||
Assert.That(ban, Is.Not.Null);
|
||||
Assert.Multiple(async () =>
|
||||
{
|
||||
Assert.That(ban, Is.Not.Null);
|
||||
Assert.That(await sDatabase.GetServerBansAsync(null, clientId, null), Has.Count.EqualTo(1));
|
||||
|
||||
Assert.That(await sDatabase.GetServerBansAsync(null, clientId, null), Has.Count.EqualTo(1));
|
||||
// Check that it matches
|
||||
Assert.That(ban.Id, Is.EqualTo(1));
|
||||
Assert.That(ban.UserId, Is.EqualTo(clientId));
|
||||
Assert.That(ban.BanTime.UtcDateTime - DateTime.UtcNow, Is.LessThanOrEqualTo(MarginOfError));
|
||||
Assert.That(ban.ExpirationTime, Is.Not.Null);
|
||||
Assert.That(ban.ExpirationTime.Value.UtcDateTime - DateTime.UtcNow.AddHours(24), Is.LessThanOrEqualTo(MarginOfError));
|
||||
Assert.That(ban.Reason, Is.EqualTo(banReason));
|
||||
|
||||
// Check that it matches
|
||||
Assert.That(ban.Id, Is.EqualTo(1));
|
||||
Assert.That(ban.UserId, Is.EqualTo(clientId));
|
||||
Assert.That(ban.BanTime.UtcDateTime - DateTime.UtcNow, Is.LessThanOrEqualTo(MarginOfError));
|
||||
Assert.NotNull(ban.ExpirationTime);
|
||||
Assert.That(ban.ExpirationTime.Value.UtcDateTime - DateTime.UtcNow.AddHours(24), Is.LessThanOrEqualTo(MarginOfError));
|
||||
Assert.That(ban.Reason, Is.EqualTo(banReason));
|
||||
|
||||
// Done through the console
|
||||
Assert.That(ban.BanningAdmin, Is.Null);
|
||||
|
||||
Assert.That(ban.Unban, Is.Null);
|
||||
// Done through the console
|
||||
Assert.That(ban.BanningAdmin, Is.Null);
|
||||
Assert.That(ban.Unban, Is.Null);
|
||||
});
|
||||
|
||||
// Pardon the actual ban
|
||||
sConsole.ExecuteCommand("pardon 1");
|
||||
@@ -84,42 +91,48 @@ namespace Content.IntegrationTests.Tests.Commands
|
||||
|
||||
// Direct id lookup returns a pardoned ban
|
||||
var pardonedBan = await sDatabase.GetServerBanAsync(1);
|
||||
Assert.That(pardonedBan, Is.Not.Null);
|
||||
Assert.Multiple(async () =>
|
||||
{
|
||||
// Check that it matches
|
||||
Assert.That(pardonedBan, Is.Not.Null);
|
||||
|
||||
// The list is still returned since that ignores pardons
|
||||
Assert.That(await sDatabase.GetServerBansAsync(null, clientId, null), Has.Count.EqualTo(1));
|
||||
// The list is still returned since that ignores pardons
|
||||
Assert.That(await sDatabase.GetServerBansAsync(null, clientId, null), Has.Count.EqualTo(1));
|
||||
|
||||
// Check that it matches
|
||||
Assert.That(pardonedBan.Id, Is.EqualTo(1));
|
||||
Assert.That(pardonedBan.UserId, Is.EqualTo(clientId));
|
||||
Assert.That(pardonedBan.BanTime.UtcDateTime - DateTime.UtcNow, Is.LessThanOrEqualTo(MarginOfError));
|
||||
Assert.NotNull(pardonedBan.ExpirationTime);
|
||||
Assert.That(pardonedBan.ExpirationTime.Value.UtcDateTime - DateTime.UtcNow.AddHours(24), Is.LessThanOrEqualTo(MarginOfError));
|
||||
Assert.That(pardonedBan.Reason, Is.EqualTo(banReason));
|
||||
Assert.That(pardonedBan.Id, Is.EqualTo(1));
|
||||
Assert.That(pardonedBan.UserId, Is.EqualTo(clientId));
|
||||
Assert.That(pardonedBan.BanTime.UtcDateTime - DateTime.UtcNow, Is.LessThanOrEqualTo(MarginOfError));
|
||||
Assert.That(pardonedBan.ExpirationTime, Is.Not.Null);
|
||||
Assert.That(pardonedBan.ExpirationTime.Value.UtcDateTime - DateTime.UtcNow.AddHours(24), Is.LessThanOrEqualTo(MarginOfError));
|
||||
Assert.That(pardonedBan.Reason, Is.EqualTo(banReason));
|
||||
|
||||
// Done through the console
|
||||
Assert.That(pardonedBan.BanningAdmin, Is.Null);
|
||||
// Done through the console
|
||||
Assert.That(pardonedBan.BanningAdmin, Is.Null);
|
||||
|
||||
Assert.That(pardonedBan.Unban, Is.Not.Null);
|
||||
Assert.That(pardonedBan.Unban.BanId, Is.EqualTo(1));
|
||||
Assert.That(pardonedBan.Unban, Is.Not.Null);
|
||||
Assert.That(pardonedBan.Unban.BanId, Is.EqualTo(1));
|
||||
|
||||
// Done through the console
|
||||
Assert.That(pardonedBan.Unban.UnbanningAdmin, Is.Null);
|
||||
// Done through the console
|
||||
Assert.That(pardonedBan.Unban.UnbanningAdmin, Is.Null);
|
||||
|
||||
Assert.That(pardonedBan.Unban.UnbanTime.UtcDateTime - DateTime.UtcNow, Is.LessThanOrEqualTo(MarginOfError));
|
||||
Assert.That(pardonedBan.Unban.UnbanTime.UtcDateTime - DateTime.UtcNow, Is.LessThanOrEqualTo(MarginOfError));
|
||||
});
|
||||
|
||||
// Try to pardon it again
|
||||
sConsole.ExecuteCommand("pardon 1");
|
||||
|
||||
// Nothing changes
|
||||
// No bans should be returned
|
||||
Assert.That(await sDatabase.GetServerBanAsync(null, clientId, null), Is.Null);
|
||||
Assert.Multiple(async () =>
|
||||
{
|
||||
// No bans should be returned
|
||||
Assert.That(await sDatabase.GetServerBanAsync(null, clientId, null), Is.Null);
|
||||
|
||||
// Direct id lookup returns a pardoned ban
|
||||
Assert.That(await sDatabase.GetServerBanAsync(1), Is.Not.Null);
|
||||
// Direct id lookup returns a pardoned ban
|
||||
Assert.That(await sDatabase.GetServerBanAsync(1), Is.Not.Null);
|
||||
|
||||
// The list is still returned since that ignores pardons
|
||||
Assert.That(await sDatabase.GetServerBansAsync(null, clientId, null), Has.Count.EqualTo(1));
|
||||
// The list is still returned since that ignores pardons
|
||||
Assert.That(await sDatabase.GetServerBansAsync(null, clientId, null), Has.Count.EqualTo(1));
|
||||
});
|
||||
});
|
||||
await pairTracker.CleanReturnAsync();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Administration.Commands;
|
||||
using Content.Server.Administration.Commands;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -34,7 +32,11 @@ namespace Content.IntegrationTests.Tests.Commands
|
||||
[Test]
|
||||
public async Task RejuvenateDeadTest()
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true, ExtraPrototypes = Prototypes});
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
var entManager = server.ResolveDependency<IEntityManager>();
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
@@ -45,37 +47,50 @@ namespace Content.IntegrationTests.Tests.Commands
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
var human = entManager.SpawnEntity("DamageableDummy", MapCoordinates.Nullspace);
|
||||
DamageableComponent damageable = null;
|
||||
MobStateComponent mobState = null;
|
||||
|
||||
// Sanity check
|
||||
Assert.True(entManager.TryGetComponent(human, out DamageableComponent damageable));
|
||||
Assert.True(entManager.TryGetComponent(human, out MobStateComponent mobState));
|
||||
Assert.That(mobStateSystem.IsAlive(human, mobState), Is.True);
|
||||
Assert.That(mobStateSystem.IsCritical(human, mobState), Is.False);
|
||||
Assert.That(mobStateSystem.IsDead(human, mobState), Is.False);
|
||||
Assert.That(mobStateSystem.IsIncapacitated(human, mobState), Is.False);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(entManager.TryGetComponent(human, out damageable));
|
||||
Assert.That(entManager.TryGetComponent(human, out mobState));
|
||||
});
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(mobStateSystem.IsAlive(human, mobState), Is.True);
|
||||
Assert.That(mobStateSystem.IsCritical(human, mobState), Is.False);
|
||||
Assert.That(mobStateSystem.IsDead(human, mobState), Is.False);
|
||||
Assert.That(mobStateSystem.IsIncapacitated(human, mobState), Is.False);
|
||||
});
|
||||
|
||||
// Kill the entity
|
||||
DamageSpecifier damage = new(prototypeManager.Index<DamageGroupPrototype>("Toxin"),
|
||||
FixedPoint2.New(10000000));
|
||||
DamageSpecifier damage = new(prototypeManager.Index<DamageGroupPrototype>("Toxin"), FixedPoint2.New(10000000));
|
||||
|
||||
damSystem.TryChangeDamage(human, damage, true);
|
||||
|
||||
// Check that it is dead
|
||||
Assert.That(mobStateSystem.IsAlive(human, mobState), Is.False);
|
||||
Assert.That(mobStateSystem.IsCritical(human, mobState), Is.False);
|
||||
Assert.That(mobStateSystem.IsDead(human, mobState), Is.True);
|
||||
Assert.That(mobStateSystem.IsIncapacitated(human, mobState), Is.True);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(mobStateSystem.IsAlive(human, mobState), Is.False);
|
||||
Assert.That(mobStateSystem.IsCritical(human, mobState), Is.False);
|
||||
Assert.That(mobStateSystem.IsDead(human, mobState), Is.True);
|
||||
Assert.That(mobStateSystem.IsIncapacitated(human, mobState), Is.True);
|
||||
});
|
||||
|
||||
// Rejuvenate them
|
||||
RejuvenateCommand.PerformRejuvenate(human);
|
||||
|
||||
// Check that it is alive and with no damage
|
||||
Assert.That(mobStateSystem.IsAlive(human, mobState), Is.True);
|
||||
Assert.That(mobStateSystem.IsCritical(human, mobState), Is.False);
|
||||
Assert.That(mobStateSystem.IsDead(human, mobState), Is.False);
|
||||
Assert.That(mobStateSystem.IsIncapacitated(human, mobState), Is.False);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(mobStateSystem.IsAlive(human, mobState), Is.True);
|
||||
Assert.That(mobStateSystem.IsCritical(human, mobState), Is.False);
|
||||
Assert.That(mobStateSystem.IsDead(human, mobState), Is.False);
|
||||
Assert.That(mobStateSystem.IsIncapacitated(human, mobState), Is.False);
|
||||
|
||||
Assert.That(damageable.TotalDamage, Is.EqualTo(FixedPoint2.Zero));
|
||||
Assert.That(damageable.TotalDamage, Is.EqualTo(FixedPoint2.Zero));
|
||||
});
|
||||
});
|
||||
await pairTracker.CleanReturnAsync();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.GameTicking.Commands;
|
||||
using Content.Shared.CCVar;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Timing;
|
||||
@@ -19,7 +16,7 @@ namespace Content.IntegrationTests.Tests.Commands
|
||||
[TestCase(false)]
|
||||
public async Task RestartRoundAfterStart(bool lobbyEnabled)
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings(){Dirty = true});
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings() { Dirty = true });
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
var configManager = server.ResolveDependency<IConfigurationManager>();
|
||||
@@ -54,7 +51,7 @@ namespace Content.IntegrationTests.Tests.Commands
|
||||
{
|
||||
var tickAfterRestart = entityManager.CurrentTick;
|
||||
|
||||
Assert.That(tickBeforeRestart < tickAfterRestart);
|
||||
Assert.That(tickBeforeRestart, Is.LessThan(tickAfterRestart));
|
||||
});
|
||||
|
||||
await PoolManager.RunTicksSync(pairTracker.Pair, 5);
|
||||
|
||||
Reference in New Issue
Block a user