forked from space-wizards/space-station-14
-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #453 from TGRCdev/spelf-moods-duplicate-vars
Spelf moods now check for duplicate moodvars by default
- Loading branch information
Showing
3 changed files
with
135 additions
and
2 deletions.
There are no files selected for viewing
95 changes: 95 additions & 0 deletions
95
Content.IntegrationTests/Tests/Impstation/Spelfs/MoodTests.cs
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,95 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using Content.IntegrationTests; | ||
using Content.Server.Impstation.Spelfs; | ||
using Content.Shared.Dataset; | ||
using Content.Shared.Impstation.Spelfs; | ||
using NUnit.Framework; | ||
using Robust.Shared.ContentPack; | ||
using Robust.Shared.GameObjects; | ||
using Robust.Shared.IoC; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Serialization.Manager; | ||
|
||
namespace Content.IntegrationTests.Tests.Impstation.Spelfs; | ||
|
||
[TestFixture, TestOf(typeof(SpelfMoodPrototype))] | ||
public sealed class SpelfMoodTests | ||
{ | ||
[TestPrototypes] | ||
const string PROTOTYPES = @" | ||
- type: dataset | ||
id: ThreeValueSet | ||
values: | ||
- One | ||
- Two | ||
- Three | ||
- type: spelfMood | ||
id: DuplicateTest | ||
moodName: DuplicateTest | ||
moodDesc: DuplicateTest | ||
allowDuplicateMoodVars: false | ||
moodVars: | ||
a: ThreeValueSet | ||
b: ThreeValueSet | ||
c: ThreeValueSet | ||
- type: spelfMood | ||
id: DuplicateOverlapTest | ||
moodName: DuplicateOverlapTest | ||
moodDesc: DuplicateOverlapTest | ||
allowDuplicateMoodVars: false | ||
moodVars: | ||
a: ThreeValueSet | ||
b: ThreeValueSet | ||
c: ThreeValueSet | ||
d: ThreeValueSet | ||
e: ThreeValueSet | ||
"; | ||
|
||
[Test] | ||
[Repeat(10)] | ||
public async Task TestDuplicatePrevention() | ||
{ | ||
await using var pair = await PoolManager.GetServerClient(); | ||
var server = pair.Server; | ||
|
||
var entMan = server.ResolveDependency<IEntityManager>(); | ||
var spelfSystem = entMan.System<SpelfMoodsSystem>(); | ||
var protoMan = server.ResolveDependency<IPrototypeManager>(); | ||
|
||
var dataset = protoMan.Index<DatasetPrototype>("ThreeValueSet"); | ||
var moodProto = protoMan.Index<SpelfMoodPrototype>("DuplicateTest"); | ||
|
||
var datasetSet = dataset.Values.ToHashSet(); | ||
var mood = spelfSystem.RollMood(moodProto); | ||
var moodVarSet = mood.MoodVars.Values.ToHashSet(); | ||
|
||
Assert.That(moodVarSet, Is.EquivalentTo(datasetSet)); | ||
|
||
await pair.CleanReturnAsync(); | ||
} | ||
|
||
[Test] | ||
[Repeat(10)] | ||
public async Task TestDuplicateOverlap() | ||
{ | ||
await using var pair = await PoolManager.GetServerClient(); | ||
var server = pair.Server; | ||
|
||
var entMan = server.ResolveDependency<IEntityManager>(); | ||
var spelfSystem = entMan.System<SpelfMoodsSystem>(); | ||
var protoMan = server.ResolveDependency<IPrototypeManager>(); | ||
|
||
var dataset = protoMan.Index<DatasetPrototype>("ThreeValueSet"); | ||
var moodProto = protoMan.Index<SpelfMoodPrototype>("DuplicateOverlapTest"); | ||
|
||
var datasetSet = dataset.Values.ToHashSet(); | ||
var mood = spelfSystem.RollMood(moodProto); | ||
var moodVarSet = mood.MoodVars.Values.ToHashSet(); | ||
|
||
Assert.That(moodVarSet, Is.EquivalentTo(datasetSet)); | ||
|
||
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