Fix content.integration tests warnings (#17817)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Access.Systems;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Access
|
||||
@@ -14,63 +12,82 @@ namespace Content.IntegrationTests.Tests.Access
|
||||
[Test]
|
||||
public async Task TestTags()
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true});
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
|
||||
var server = pairTracker.Pair.Server;
|
||||
var entityManager = server.ResolveDependency<IEntityManager>();
|
||||
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
var system = EntitySystem.Get<AccessReaderSystem>();
|
||||
var system = entityManager.System<AccessReaderSystem>();
|
||||
|
||||
// test empty
|
||||
var reader = new AccessReaderComponent();
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "Foo" }, reader), Is.True);
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "Bar" }, reader), Is.True);
|
||||
Assert.That(system.AreAccessTagsAllowed(new string[] { }, reader), Is.True);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "Foo" }, reader), Is.True);
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "Bar" }, reader), Is.True);
|
||||
Assert.That(system.AreAccessTagsAllowed(Array.Empty<string>(), reader), Is.True);
|
||||
});
|
||||
|
||||
// test deny
|
||||
reader = new AccessReaderComponent();
|
||||
reader.DenyTags.Add("A");
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "Foo" }, reader), Is.True);
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "A" }, reader), Is.False);
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "A", "Foo" }, reader), Is.False);
|
||||
Assert.That(system.AreAccessTagsAllowed(new string[] { }, reader), Is.True);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "Foo" }, reader), Is.True);
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "A" }, reader), Is.False);
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "A", "Foo" }, reader), Is.False);
|
||||
Assert.That(system.AreAccessTagsAllowed(Array.Empty<string>(), reader), Is.True);
|
||||
});
|
||||
|
||||
// test one list
|
||||
reader = new AccessReaderComponent();
|
||||
reader.AccessLists.Add(new HashSet<string> { "A" });
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "A" }, reader), Is.True);
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "B" }, reader), Is.False);
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "A", "B" }, reader), Is.True);
|
||||
Assert.That(system.AreAccessTagsAllowed(new string[] { }, reader), Is.False);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "A" }, reader), Is.True);
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "B" }, reader), Is.False);
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "A", "B" }, reader), Is.True);
|
||||
Assert.That(system.AreAccessTagsAllowed(Array.Empty<string>(), reader), Is.False);
|
||||
});
|
||||
|
||||
// test one list - two items
|
||||
reader = new AccessReaderComponent();
|
||||
reader.AccessLists.Add(new HashSet<string> { "A", "B" });
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "A" }, reader), Is.False);
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "B" }, reader), Is.False);
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "A", "B" }, reader), Is.True);
|
||||
Assert.That(system.AreAccessTagsAllowed(new string[] { }, reader), Is.False);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "A" }, reader), Is.False);
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "B" }, reader), Is.False);
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "A", "B" }, reader), Is.True);
|
||||
Assert.That(system.AreAccessTagsAllowed(Array.Empty<string>(), reader), Is.False);
|
||||
});
|
||||
|
||||
// test two list
|
||||
reader = new AccessReaderComponent();
|
||||
reader.AccessLists.Add(new HashSet<string> { "A" });
|
||||
reader.AccessLists.Add(new HashSet<string> { "B", "C" });
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "A" }, reader), Is.True);
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "B" }, reader), Is.False);
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "A", "B" }, reader), Is.True);
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "C", "B" }, reader), Is.True);
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "C", "B", "A" }, reader), Is.True);
|
||||
Assert.That(system.AreAccessTagsAllowed(new string[] { }, reader), Is.False);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "A" }, reader), Is.True);
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "B" }, reader), Is.False);
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "A", "B" }, reader), Is.True);
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "C", "B" }, reader), Is.True);
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "C", "B", "A" }, reader), Is.True);
|
||||
Assert.That(system.AreAccessTagsAllowed(Array.Empty<string>(), reader), Is.False);
|
||||
});
|
||||
|
||||
// test deny list
|
||||
reader = new AccessReaderComponent();
|
||||
reader.AccessLists.Add(new HashSet<string> { "A" });
|
||||
reader.DenyTags.Add("B");
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "A" }, reader), Is.True);
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "B" }, reader), Is.False);
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "A", "B" }, reader), Is.False);
|
||||
Assert.That(system.AreAccessTagsAllowed(new string[] { }, reader), Is.False);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "A" }, reader), Is.True);
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "B" }, reader), Is.False);
|
||||
Assert.That(system.AreAccessTagsAllowed(new[] { "A", "B" }, reader), Is.False);
|
||||
Assert.That(system.AreAccessTagsAllowed(Array.Empty<string>(), reader), Is.False);
|
||||
});
|
||||
});
|
||||
await pairTracker.CleanReturnAsync();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user