Fix event tests

This commit is contained in:
Jordan Dominion
2023-10-16 09:18:31 -04:00
parent 04bf89f646
commit a71f23ee29
3 changed files with 6 additions and 4 deletions
@@ -20,7 +20,7 @@ namespace Tgstation.Server.Host.Components.Events
/// <param name="scriptNames">The value of <see cref="ScriptNames"/>.</param>
public EventScriptAttribute(params string[] scriptNames)
{
ScriptNames = ScriptNames ?? throw new ArgumentNullException(nameof(scriptNames));
ScriptNames = scriptNames ?? throw new ArgumentNullException(nameof(scriptNames));
}
}
}
@@ -1,5 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Linq;
namespace Tgstation.Server.Host.Components.Events.Tests
@@ -14,8 +15,8 @@ namespace Tgstation.Server.Host.Components.Events.Tests
public void TestConstruction()
{
Assert.ThrowsException<ArgumentNullException>(() => new EventScriptAttribute(null));
var test = new EventScriptAttribute("test");
Assert.AreEqual("test", test.ScriptName);
var test = new EventScriptAttribute("test1", "test2");
Assert.IsTrue(test.ScriptNames.SequenceEqual(["test1", "test2"]));
}
}
}
@@ -22,7 +22,8 @@ namespace Tgstation.Server.Host.Components.Events.Tests
Assert.AreEqual(1, list.Count, $"EventType: {eventType}");
var attribute = list.First();
Assert.IsTrue(allScripts.Add(attribute.ScriptName), $"Non-unique script Name: {attribute.ScriptName}");
foreach (var scriptName in attribute.ScriptNames)
Assert.IsTrue(allScripts.Add(scriptName), $"Non-unique script Names: {scriptName}");
}
}
}