-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'ParadiseDelta-Items' of https://github.com/Rinary1/spac…
…e-sunrise into ParadiseDelta-Items
- Loading branch information
Showing
12 changed files
with
134 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
using Content.Shared.CCVar; | ||
using Robust.Shared.Configuration; | ||
using Robust.Shared.Console; | ||
|
||
namespace Content.IntegrationTests.Tests.Commands; | ||
|
||
[TestFixture] | ||
public sealed class ForceMapTest | ||
{ | ||
private const string DefaultMapName = "Empty"; | ||
private const string BadMapName = "asdf_asd-fa__sdfAsd_f"; // Hopefully no one ever names a map this... | ||
private const string TestMapEligibleName = "ForceMapTestEligible"; | ||
private const string TestMapIneligibleName = "ForceMapTestIneligible"; | ||
|
||
[TestPrototypes] | ||
private static readonly string TestMaps = @$" | ||
- type: gameMap | ||
id: {TestMapIneligibleName} | ||
mapName: {TestMapIneligibleName} | ||
mapPath: /Maps/Test/empty.yml | ||
minPlayers: 20 | ||
maxPlayers: 80 | ||
stations: | ||
Empty: | ||
stationProto: StandardNanotrasenStation | ||
components: | ||
- type: StationNameSetup | ||
mapNameTemplate: ""Empty"" | ||
- type: gameMap | ||
id: {TestMapEligibleName} | ||
mapName: {TestMapEligibleName} | ||
mapPath: /Maps/Test/empty.yml | ||
minPlayers: 0 | ||
stations: | ||
Empty: | ||
stationProto: StandardNanotrasenStation | ||
components: | ||
- type: StationNameSetup | ||
mapNameTemplate: ""Empty"" | ||
"; | ||
|
||
[Test] | ||
public async Task TestForceMapCommand() | ||
{ | ||
await using var pair = await PoolManager.GetServerClient(); | ||
var server = pair.Server; | ||
|
||
var entMan = server.EntMan; | ||
var configManager = server.ResolveDependency<IConfigurationManager>(); | ||
var consoleHost = server.ResolveDependency<IConsoleHost>(); | ||
|
||
await server.WaitAssertion(() => | ||
{ | ||
// Make sure we're set to the default map | ||
Assert.That(configManager.GetCVar(CCVars.GameMap), Is.EqualTo(DefaultMapName), | ||
$"Test didn't start on expected map ({DefaultMapName})!"); | ||
|
||
// Try changing to a map that doesn't exist | ||
consoleHost.ExecuteCommand($"forcemap {BadMapName}"); | ||
Assert.That(configManager.GetCVar(CCVars.GameMap), Is.EqualTo(DefaultMapName), | ||
$"Forcemap succeeded with a map that does not exist ({BadMapName})!"); | ||
|
||
// Try changing to a valid map | ||
consoleHost.ExecuteCommand($"forcemap {TestMapEligibleName}"); | ||
Assert.That(configManager.GetCVar(CCVars.GameMap), Is.EqualTo(TestMapEligibleName), | ||
$"Forcemap failed with a valid map ({TestMapEligibleName})"); | ||
|
||
// Try changing to a map that exists but is ineligible | ||
consoleHost.ExecuteCommand($"forcemap {TestMapIneligibleName}"); | ||
Assert.That(configManager.GetCVar(CCVars.GameMap), Is.EqualTo(TestMapIneligibleName), | ||
$"Forcemap failed with valid but ineligible map ({TestMapIneligibleName})!"); | ||
}); | ||
|
||
// Cleanup | ||
configManager.SetCVar(CCVars.GameMap, DefaultMapName); | ||
|
||
await pair.CleanReturnAsync(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters