more tests for Bk2LogEntryGenerator

This commit is contained in:
adelikat 2020-05-19 20:29:55 -05:00
parent 0b5047b64a
commit 0a12f9e742
1 changed files with 76 additions and 1 deletions

View File

@ -8,6 +8,36 @@ namespace BizHawk.Common.Tests.Client.Common.Movie
[TestClass]
public class LogGeneratorTests
{
private SimpleController _boolController = null!;
private Bk2LogEntryGenerator _lg = null!;
private SimpleController _floatController = null!;
private Bk2LogEntryGenerator _floatLg = null!;
[TestInitialize]
public void Initializer()
{
_boolController = new SimpleController
{
Definition = new ControllerDefinition { BoolButtons = { "A" } }
};
_floatController = new SimpleController
{
Definition = new ControllerDefinition
{
AxisControls = { "StickX", "StickY" },
AxisRanges =
{
new ControllerDefinition.AxisRange(0, 100, 200),
new ControllerDefinition.AxisRange(0, 100, 200)
}
}
};
_lg = new Bk2LogEntryGenerator("NES", _boolController);
_floatLg = new Bk2LogEntryGenerator("NES", _floatController);
}
[TestMethod]
public void GenerateLogEntry_ExclamationForUnknownButtons()
{
@ -22,8 +52,53 @@ namespace BizHawk.Common.Tests.Client.Common.Movie
var lg = new Bk2LogEntryGenerator("NES", controller);
var actual = lg.GenerateLogEntry();
Assert.IsNotNull(lg);
Assert.AreEqual("|!|", actual);
}
[TestMethod]
public void GenerateLogEntry_BoolPressed_GeneratesMnemonic()
{
_boolController["A"] = true;
var actual = _lg.GenerateLogEntry();
Assert.AreEqual("|A|", actual);
}
[TestMethod]
public void GenerateLogEntry_BoolUnPressed_GeneratesPeriod()
{
_boolController["A"] = false;
var actual = _lg.GenerateLogEntry();
Assert.AreEqual("|.|", actual);
}
[TestMethod]
public void GenerateLogEntry_Floats()
{
var actual = _floatLg.GenerateLogEntry();
Assert.AreEqual("| 0, 0,|", actual);
}
[TestMethod]
public void GenerateInputDisplay_BoolPressed_GeneratesMnemonic()
{
_boolController["A"] = true;
var actual = _lg.GenerateInputDisplay();
Assert.AreEqual("A", actual);
}
[TestMethod]
public void GenerateInputDisplay_BoolUnPressed_GeneratesSpace()
{
_boolController["A"] = false;
var actual = _lg.GenerateInputDisplay();
Assert.AreEqual(" ", actual);
}
[TestMethod]
public void GenerateInputDisplay_Floats()
{
var actual = _floatLg.GenerateInputDisplay();
Assert.AreEqual(" 0, 0,", actual);
}
}
}