Fix content.integration tests warnings (#17817)

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
TemporalOroboros
2023-07-05 21:54:25 -07:00
committed by GitHub
parent 20c1754abd
commit ba91023a85
121 changed files with 3658 additions and 1961 deletions

View File

@@ -1,8 +1,6 @@
#nullable enable
using System.Collections.Generic;
using System.Threading.Tasks;
using Content.Shared.Tag;
using NUnit.Framework;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
@@ -45,7 +43,11 @@ namespace Content.IntegrationTests.Tests.Tag
[Test]
public async Task TagComponentTest()
{
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 sEntityManager = server.ResolveDependency<IEntityManager>();
@@ -65,53 +67,62 @@ namespace Content.IntegrationTests.Tests.Tag
{
var tagSystem = entManager.GetEntitySystem<TagSystem>();
// Has one tag, the starting tag
Assert.That(sTagComponent.Tags.Count, Is.EqualTo(1));
Assert.That(sTagComponent.Tags, Has.Count.EqualTo(1));
sPrototypeManager.Index<TagPrototype>(StartingTag);
Assert.That(sTagComponent.Tags, Contains.Item(StartingTag));
Assert.Multiple(() =>
{
Assert.That(sTagComponent.Tags, Contains.Item(StartingTag));
// Single
Assert.True(tagSystem.HasTag(sTagDummy, StartingTag));
Assert.True(tagSystem.HasTag(sTagComponent, StartingTag));
// Single
Assert.That(tagSystem.HasTag(sTagDummy, StartingTag));
Assert.That(tagSystem.HasTag(sTagComponent, StartingTag));
// Any
Assert.True(tagSystem.HasAnyTag(sTagDummy, StartingTag));
Assert.True(tagSystem.HasAnyTag(sTagComponent, StartingTag));
// Any
Assert.That(tagSystem.HasAnyTag(sTagDummy, StartingTag));
Assert.That(tagSystem.HasAnyTag(sTagComponent, StartingTag));
// All
Assert.True(tagSystem.HasAllTags(sTagDummy, StartingTag));
Assert.True(tagSystem.HasAllTags(sTagComponent, StartingTag));
// All
Assert.That(tagSystem.HasAllTags(sTagDummy, StartingTag));
Assert.That(tagSystem.HasAllTags(sTagComponent, StartingTag));
});
// Does not have the added tag
var addedTagPrototype = sPrototypeManager.Index<TagPrototype>(AddedTag);
Assert.That(sTagComponent.Tags, Does.Not.Contains(addedTagPrototype));
Assert.Multiple(() =>
{
Assert.That(sTagComponent.Tags, Does.Not.Contains(addedTagPrototype));
// Single
Assert.False(tagSystem.HasTag(sTagDummy, AddedTag));
Assert.False(tagSystem.HasTag(sTagComponent, AddedTag));
// Single
Assert.That(tagSystem.HasTag(sTagDummy, AddedTag), Is.False);
Assert.That(tagSystem.HasTag(sTagComponent, AddedTag), Is.False);
// Any
Assert.False(tagSystem.HasAnyTag(sTagDummy, AddedTag));
Assert.False(tagSystem.HasAnyTag(sTagComponent, AddedTag));
// Any
Assert.That(tagSystem.HasAnyTag(sTagDummy, AddedTag), Is.False);
Assert.That(tagSystem.HasAnyTag(sTagComponent, AddedTag), Is.False);
// All
Assert.False(tagSystem.HasAllTags(sTagDummy, AddedTag));
Assert.False(tagSystem.HasAllTags(sTagComponent, AddedTag));
// All
Assert.That(tagSystem.HasAllTags(sTagDummy, AddedTag), Is.False);
Assert.That(tagSystem.HasAllTags(sTagComponent, AddedTag), Is.False);
});
// Does not have the unused tag
var unusedTagPrototype = sPrototypeManager.Index<TagPrototype>(UnusedTag);
Assert.That(sTagComponent.Tags, Does.Not.Contains(unusedTagPrototype));
Assert.Multiple(() =>
{
Assert.That(sTagComponent.Tags, Does.Not.Contains(unusedTagPrototype));
// Single
Assert.False(tagSystem.HasTag(sTagDummy, UnusedTag));
Assert.False(tagSystem.HasTag(sTagComponent, UnusedTag));
// Single
Assert.That(tagSystem.HasTag(sTagDummy, UnusedTag), Is.False);
Assert.That(tagSystem.HasTag(sTagComponent, UnusedTag), Is.False);
// Any
Assert.False(tagSystem.HasAnyTag(sTagDummy, UnusedTag));
Assert.False(tagSystem.HasAnyTag(sTagComponent, UnusedTag));
// Any
Assert.That(tagSystem.HasAnyTag(sTagDummy, UnusedTag), Is.False);
Assert.That(tagSystem.HasAnyTag(sTagComponent, UnusedTag), Is.False);
// All
Assert.False(tagSystem.HasAllTags(sTagDummy, UnusedTag));
Assert.False(tagSystem.HasAllTags(sTagComponent, UnusedTag));
// All
Assert.That(tagSystem.HasAllTags(sTagDummy, UnusedTag), Is.False);
Assert.That(tagSystem.HasAllTags(sTagComponent, UnusedTag), Is.False);
});
// Throws when checking for an unregistered tag
Assert.Throws<UnknownPrototypeException>(() =>
@@ -119,76 +130,88 @@ namespace Content.IntegrationTests.Tests.Tag
sPrototypeManager.Index<TagPrototype>(UnregisteredTag);
});
// Cannot add the starting tag again
Assert.That(tagSystem.AddTag(sTagComponent, StartingTag), Is.False);
Assert.That(tagSystem.AddTags(sTagComponent, StartingTag, StartingTag), Is.False);
Assert.That(tagSystem.AddTags(sTagComponent, new List<string> {StartingTag, StartingTag}), Is.False);
Assert.Multiple(() =>
{
// Cannot add the starting tag again
Assert.That(tagSystem.AddTag(sTagComponent, StartingTag), Is.False);
Assert.That(tagSystem.AddTags(sTagComponent, StartingTag, StartingTag), Is.False);
Assert.That(tagSystem.AddTags(sTagComponent, new List<string> { StartingTag, StartingTag }), Is.False);
// Has the starting tag
Assert.That(tagSystem.HasTag(sTagComponent, StartingTag), Is.True);
Assert.That(tagSystem.HasAllTags(sTagComponent, StartingTag, StartingTag), Is.True);
Assert.That(tagSystem.HasAllTags(sTagComponent, new List<string> {StartingTag, StartingTag}), Is.True);
Assert.That(tagSystem.HasAnyTag(sTagComponent, StartingTag, StartingTag), Is.True);
Assert.That(tagSystem.HasAnyTag(sTagComponent, new List<string> {StartingTag, StartingTag}), Is.True);
// Has the starting tag
Assert.That(tagSystem.HasTag(sTagComponent, StartingTag), Is.True);
Assert.That(tagSystem.HasAllTags(sTagComponent, StartingTag, StartingTag), Is.True);
Assert.That(tagSystem.HasAllTags(sTagComponent, new List<string> { StartingTag, StartingTag }), Is.True);
Assert.That(tagSystem.HasAnyTag(sTagComponent, StartingTag, StartingTag), Is.True);
Assert.That(tagSystem.HasAnyTag(sTagComponent, new List<string> { StartingTag, StartingTag }), Is.True);
// Does not have the added tag yet
Assert.That(tagSystem.HasTag(sTagComponent, AddedTag), Is.False);
Assert.That(tagSystem.HasAllTags(sTagComponent, AddedTag, AddedTag), Is.False);
Assert.That(tagSystem.HasAllTags(sTagComponent, new List<string> {AddedTag, AddedTag}), Is.False);
Assert.That(tagSystem.HasAnyTag(sTagComponent, AddedTag, AddedTag), Is.False);
Assert.That(tagSystem.HasAnyTag(sTagComponent, new List<string> {AddedTag, AddedTag}), Is.False);
// Does not have the added tag yet
Assert.That(tagSystem.HasTag(sTagComponent, AddedTag), Is.False);
Assert.That(tagSystem.HasAllTags(sTagComponent, AddedTag, AddedTag), Is.False);
Assert.That(tagSystem.HasAllTags(sTagComponent, new List<string> { AddedTag, AddedTag }), Is.False);
Assert.That(tagSystem.HasAnyTag(sTagComponent, AddedTag, AddedTag), Is.False);
Assert.That(tagSystem.HasAnyTag(sTagComponent, new List<string> { AddedTag, AddedTag }), Is.False);
// Has a combination of the two tags
Assert.That(tagSystem.HasAnyTag(sTagComponent, StartingTag, AddedTag), Is.True);
Assert.That(tagSystem.HasAnyTag(sTagComponent, new List<string> {StartingTag, AddedTag}), Is.True);
// Has a combination of the two tags
Assert.That(tagSystem.HasAnyTag(sTagComponent, StartingTag, AddedTag), Is.True);
Assert.That(tagSystem.HasAnyTag(sTagComponent, new List<string> { StartingTag, AddedTag }), Is.True);
// Does not have both tags
Assert.That(tagSystem.HasAllTags(sTagComponent, StartingTag, AddedTag), Is.False);
Assert.That(tagSystem.HasAllTags(sTagComponent, new List<string> {StartingTag, AddedTag}), Is.False);
// Does not have both tags
Assert.That(tagSystem.HasAllTags(sTagComponent, StartingTag, AddedTag), Is.False);
Assert.That(tagSystem.HasAllTags(sTagComponent, new List<string> { StartingTag, AddedTag }), Is.False);
// Cannot remove a tag that does not exist
Assert.That(tagSystem.RemoveTag(sTagComponent, AddedTag), Is.False);
Assert.That(tagSystem.RemoveTags(sTagComponent, AddedTag, AddedTag), Is.False);
Assert.That(tagSystem.RemoveTags(sTagComponent, new List<string> {AddedTag, AddedTag}), Is.False);
// Cannot remove a tag that does not exist
Assert.That(tagSystem.RemoveTag(sTagComponent, AddedTag), Is.False);
Assert.That(tagSystem.RemoveTags(sTagComponent, AddedTag, AddedTag), Is.False);
Assert.That(tagSystem.RemoveTags(sTagComponent, new List<string> { AddedTag, AddedTag }), Is.False);
});
// Can add the new tag
Assert.That(tagSystem.AddTag(sTagComponent, AddedTag), Is.True);
// Cannot add it twice
Assert.That(tagSystem.AddTag(sTagComponent, AddedTag), Is.False);
Assert.Multiple(() =>
{
// Cannot add it twice
Assert.That(tagSystem.AddTag(sTagComponent, AddedTag), Is.False);
// Cannot add existing tags
Assert.That(tagSystem.AddTags(sTagComponent, StartingTag, AddedTag), Is.False);
Assert.That(tagSystem.AddTags(sTagComponent, new List<string> {StartingTag, AddedTag}), Is.False);
// Cannot add existing tags
Assert.That(tagSystem.AddTags(sTagComponent, StartingTag, AddedTag), Is.False);
Assert.That(tagSystem.AddTags(sTagComponent, new List<string> { StartingTag, AddedTag }), Is.False);
// Now has two tags
Assert.That(sTagComponent.Tags.Count, Is.EqualTo(2));
// Now has two tags
Assert.That(sTagComponent.Tags, Has.Count.EqualTo(2));
// Has both tags
Assert.That(tagSystem.HasTag(sTagComponent, StartingTag), Is.True);
Assert.That(tagSystem.HasTag(sTagComponent, AddedTag), Is.True);
Assert.That(tagSystem.HasAllTags(sTagComponent, StartingTag, StartingTag), Is.True);
Assert.That(tagSystem.HasAllTags(sTagComponent, AddedTag, StartingTag), Is.True);
Assert.That(tagSystem.HasAllTags(sTagComponent, new List<string> {StartingTag, AddedTag}), Is.True);
Assert.That(tagSystem.HasAllTags(sTagComponent, new List<string> {AddedTag, StartingTag}), Is.True);
Assert.That(tagSystem.HasAnyTag(sTagComponent, StartingTag, AddedTag), Is.True);
Assert.That(tagSystem.HasAnyTag(sTagComponent, AddedTag, StartingTag), Is.True);
// Has both tags
Assert.That(tagSystem.HasTag(sTagComponent, StartingTag), Is.True);
Assert.That(tagSystem.HasTag(sTagComponent, AddedTag), Is.True);
Assert.That(tagSystem.HasAllTags(sTagComponent, StartingTag, StartingTag), Is.True);
Assert.That(tagSystem.HasAllTags(sTagComponent, AddedTag, StartingTag), Is.True);
Assert.That(tagSystem.HasAllTags(sTagComponent, new List<string> { StartingTag, AddedTag }), Is.True);
Assert.That(tagSystem.HasAllTags(sTagComponent, new List<string> { AddedTag, StartingTag }), Is.True);
Assert.That(tagSystem.HasAnyTag(sTagComponent, StartingTag, AddedTag), Is.True);
Assert.That(tagSystem.HasAnyTag(sTagComponent, AddedTag, StartingTag), Is.True);
});
// Remove the existing starting tag
Assert.That(tagSystem.RemoveTag(sTagComponent, StartingTag), Is.True);
Assert.Multiple(() =>
{
// Remove the existing starting tag
Assert.That(tagSystem.RemoveTag(sTagComponent, StartingTag), Is.True);
// Remove the existing added tag
Assert.That(tagSystem.RemoveTags(sTagComponent, AddedTag, AddedTag), Is.True);
// Remove the existing added tag
Assert.That(tagSystem.RemoveTags(sTagComponent, AddedTag, AddedTag), Is.True);
});
// No tags left to remove
Assert.That(tagSystem.RemoveTags(sTagComponent, new List<string> {StartingTag, AddedTag}), Is.False);
Assert.Multiple(() =>
{
// No tags left to remove
Assert.That(tagSystem.RemoveTags(sTagComponent, new List<string> { StartingTag, AddedTag }), Is.False);
// No tags left in the component
Assert.That(sTagComponent.Tags, Is.Empty);
// No tags left in the component
Assert.That(sTagComponent.Tags, Is.Empty);
});
#if !DEBUG
#if !DEBUG
return;
#endif
#endif
// Single
Assert.Throws<DebugAssertException>(() =>