-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Write a bunch of code to make tests pass
- Loading branch information
Showing
13 changed files
with
129 additions
and
57 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,36 @@ | ||
using ME3Tweaks.Wwiser.Model.Action; | ||
using ME3Tweaks.Wwiser.Model.RTPC; | ||
using Action = ME3Tweaks.Wwiser.Model.Hierarchy.Action; | ||
|
||
namespace ME3Tweaks.Wwiser.Tests.ActionTests; | ||
|
||
public class PlayTests | ||
{ | ||
[Test] | ||
public void Play_V134_Parses() | ||
{ | ||
var data = TestData.GetTestDataBytes(@"Action",@"Play_v134.bin"); | ||
var (_, result) = TestHelpers.Deserialize<Action>(data, 134); | ||
|
||
Assert.Multiple(() => | ||
{ | ||
Assert.That(result.Type.Value, Is.EqualTo(ActionTypeValue.Play)); | ||
Assert.That(result.IsBus, Is.EqualTo(false)); | ||
Assert.That(result.ActionParams, Is.InstanceOf<Play>()); | ||
|
||
var play = result.ActionParams as Play; | ||
Assert.That(play!.Params.CurveInterpolation, Is.EqualTo(CurveInterpolation.Linear)); | ||
}); | ||
} | ||
|
||
[TestCase("Play_V134.bin", 134)] | ||
[TestCase("Play_V56.bin", 56)] | ||
public void Play_Reserializes(string file, int version) | ||
{ | ||
var data = TestData.GetTestDataBytes(@"Action",file); | ||
var (_, result) = TestHelpers.Deserialize<Action>(data, version); | ||
|
||
var reserialized = TestHelpers.Serialize(result, version); | ||
Assert.That(reserialized, Is.EqualTo(data)); | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
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
23 changes: 23 additions & 0 deletions
23
ME3Tweaks.Wwiser/Model/Action/ActionSpecificParamsFactory.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,23 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using BinarySerialization; | ||
using ME3Tweaks.Wwiser.Model.Hierarchy; | ||
|
||
namespace ME3Tweaks.Wwiser.Model.Action; | ||
|
||
public class ActionSpecificParamsFactory : ISubtypeFactory | ||
{ | ||
public bool TryGetKey(Type valueType, [UnscopedRef] out object key) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public bool TryGetType(object key, [UnscopedRef] out Type type) | ||
{ | ||
type = (ActionTypeValue)key switch | ||
{ | ||
ActionTypeValue.Play => typeof(Specific.Action), | ||
_ => typeof(Play) | ||
}; | ||
return true; | ||
} | ||
} |
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,14 @@ | ||
using BinarySerialization; | ||
using ME3Tweaks.Wwiser.Attributes; | ||
|
||
namespace ME3Tweaks.Wwiser.Model.Action; | ||
|
||
public class Active : IActionParams | ||
{ | ||
[FieldOrder(1)] | ||
[SerializeWhenVersion(56, ComparisonOperator.LessThanOrEqual)] | ||
public uint SubSectionSize { get; set; } | ||
|
||
[FieldOrder(2)] | ||
public required ActiveParams Params { get; set; } | ||
} |
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,36 @@ | ||
using BinarySerialization; | ||
using ME3Tweaks.Wwiser.Attributes; | ||
using ME3Tweaks.Wwiser.Model.Action.Specific; | ||
using ME3Tweaks.Wwiser.Model.RTPC; | ||
|
||
namespace ME3Tweaks.Wwiser.Model.Action; | ||
|
||
public class ActiveParams | ||
{ | ||
[FieldOrder(0)] | ||
[SerializeWhenVersion(56, ComparisonOperator.LessThanOrEqual)] | ||
public int Time { get; set; } | ||
|
||
[FieldOrder(1)] | ||
[SerializeWhenVersion(56, ComparisonOperator.LessThanOrEqual)] | ||
public int TimeMin { get; set; } | ||
|
||
[FieldOrder(2)] | ||
[SerializeWhenVersion(56, ComparisonOperator.LessThanOrEqual)] | ||
public int TimeMax { get; set; } | ||
|
||
[FieldOrder(3)] | ||
[SerializeAs(SerializedType.UInt1)] | ||
public CurveInterpolation CurveInterpolation { get; set; } | ||
|
||
[FieldOrder(4)] | ||
[SerializeWhenVersion(56, ComparisonOperator.LessThanOrEqual)] | ||
[SubtypeFactory($"{nameof(Hierarchy.Action.Type)}.{nameof(Hierarchy.Action.Type.Value)}", | ||
typeof(ActionSpecificParamsFactory), BindingMode = BindingMode.OneWay, | ||
AncestorType = typeof(Hierarchy.Action), RelativeSourceMode = RelativeSourceMode.FindAncestor)] | ||
public required ISpecificParams SpecificParams { get; set; } | ||
|
||
[FieldOrder(5)] | ||
[SerializeWhenVersion(56, ComparisonOperator.LessThanOrEqual)] | ||
public ExceptParams ExceptParams { get; set; } = new(); | ||
} |
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
5 changes: 1 addition & 4 deletions
5
...weaks.Wwiser/Model/Action/ActionParams.cs → ...eaks.Wwiser/Model/Action/IActionParams.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 |
---|---|---|
@@ -1,6 +1,3 @@ | ||
namespace ME3Tweaks.Wwiser.Model.Action; | ||
|
||
public class ActionParams | ||
{ | ||
|
||
} | ||
public interface IActionParams; |
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 |
---|---|---|
@@ -1,40 +1,17 @@ | ||
using BinarySerialization; | ||
using ME3Tweaks.Wwiser.Attributes; | ||
using ME3Tweaks.Wwiser.Model.Action.Specific; | ||
using ME3Tweaks.Wwiser.Model.RTPC; | ||
|
||
namespace ME3Tweaks.Wwiser.Model.Action; | ||
|
||
public class Play : ActionParams | ||
public class Play : Active | ||
{ | ||
[FieldOrder(0)] | ||
[SerializeWhenVersion(56, ComparisonOperator.LessThanOrEqual)] | ||
public int Time { get; set; } | ||
|
||
[FieldOrder(1)] | ||
[SerializeWhenVersion(56, ComparisonOperator.LessThanOrEqual)] | ||
public int TimeMin { get; set; } | ||
|
||
[FieldOrder(2)] | ||
[SerializeWhenVersion(56, ComparisonOperator.LessThanOrEqual)] | ||
public int TimeMax { get; set; } | ||
|
||
[FieldOrder(3)] | ||
[SerializeAs(SerializedType.UInt1)] | ||
public CurveInterpolation CurveInterpolation { get; set; } | ||
|
||
[FieldOrder(4)] | ||
[SerializeWhenVersion(56, ComparisonOperator.LessThanOrEqual)] | ||
public SpecificParams SpecificParams { get; set; } | ||
|
||
[FieldOrder(5)] | ||
[SerializeWhenVersion(56, ComparisonOperator.LessThanOrEqual)] | ||
public ExceptParams ExceptParams { get; set; } | ||
|
||
[FieldOrder(6)] | ||
[SerializeWhenVersion(26, ComparisonOperator.GreaterThan)] | ||
public uint BankId { get; set; } | ||
|
||
[FieldOrder(7)] | ||
[FieldOrder(2)] | ||
[SerializeWhenVersion(144, ComparisonOperator.GreaterThanOrEqual)] | ||
public uint BankType { get; set; } | ||
} |
4 changes: 2 additions & 2 deletions
4
...aks.Wwiser/Model/Action/SpecificParams.cs → ...ks.Wwiser/Model/Action/Specific/Action.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
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,3 @@ | ||
namespace ME3Tweaks.Wwiser.Model.Action.Specific; | ||
|
||
public interface ISpecificParams; |
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