Add a new test case for actor info merging.
This commit is contained in:
@@ -31,6 +31,8 @@ namespace OpenRA.Test
|
|||||||
class MockB2Info : MockTraitInfo { }
|
class MockB2Info : MockTraitInfo { }
|
||||||
class MockC2Info : MockTraitInfo { }
|
class MockC2Info : MockTraitInfo { }
|
||||||
|
|
||||||
|
class MockStringInfo : MockTraitInfo { public string AString = null; }
|
||||||
|
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ActorInfoTest
|
public class ActorInfoTest
|
||||||
{
|
{
|
||||||
@@ -142,6 +144,29 @@ Actor:
|
|||||||
Assert.IsFalse(actorInfo.HasTraitInfo<MockA2Info>(), "Actor should not have the MockA2 trait, but does.");
|
Assert.IsFalse(actorInfo.HasTraitInfo<MockA2Info>(), "Actor should not have the MockA2 trait, but does.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase(TestName = "Trait can be removed and later overridden")]
|
||||||
|
public void TraitCanBeRemovedAndLaterOverridden()
|
||||||
|
{
|
||||||
|
var baseYaml = @"
|
||||||
|
^BaseA:
|
||||||
|
MockString:
|
||||||
|
AString: ""Base""
|
||||||
|
Actor:
|
||||||
|
Inherits: ^BaseA
|
||||||
|
-MockString:
|
||||||
|
";
|
||||||
|
var overrideYaml = @"
|
||||||
|
Actor:
|
||||||
|
MockString:
|
||||||
|
AString: ""Override""
|
||||||
|
";
|
||||||
|
|
||||||
|
var actorInfo = CreateActorInfoFromYaml("Actor", null, baseYaml, overrideYaml);
|
||||||
|
Assert.IsTrue(actorInfo.HasTraitInfo<MockStringInfo>(), "Actor should have the MockStringInfo trait, but does not.");
|
||||||
|
Assert.IsTrue(actorInfo.TraitInfo<MockStringInfo>().AString == "\"Override\"",
|
||||||
|
"MockStringInfo trait has not been set with the correct override value for AString.");
|
||||||
|
}
|
||||||
|
|
||||||
// This needs to match the logic used in RulesetCache.LoadYamlRules
|
// This needs to match the logic used in RulesetCache.LoadYamlRules
|
||||||
ActorInfo CreateActorInfoFromYaml(string name, string mapYaml, params string[] yamls)
|
ActorInfo CreateActorInfoFromYaml(string name, string mapYaml, params string[] yamls)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user