2010-12-22 06:04:16 -04:00
|
|
|
using ArducopterConfigurator.PresentationModels;
|
2010-12-20 18:14:39 -04:00
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
|
namespace ArducopterConfiguratorTest
|
|
|
|
{
|
2010-12-22 06:04:16 -04:00
|
|
|
[TestFixture]
|
|
|
|
public class AltitudeHoldVmTest : VmTestBase<AltitudeHoldConfigVm>
|
2010-12-20 18:14:39 -04:00
|
|
|
{
|
|
|
|
|
2010-12-22 06:04:16 -04:00
|
|
|
[SetUp]
|
|
|
|
public void Setup()
|
2010-12-20 18:14:39 -04:00
|
|
|
{
|
2010-12-22 06:04:16 -04:00
|
|
|
sampleLineOfData = "0.800,0.200,0.300";
|
|
|
|
getCommand = "F";
|
|
|
|
setCommand = "E";
|
|
|
|
|
2010-12-23 11:59:00 -04:00
|
|
|
_mockComms = new MockComms();
|
|
|
|
_vm = new AltitudeHoldConfigVm(_mockComms);
|
2010-12-20 18:14:39 -04:00
|
|
|
}
|
|
|
|
|
2010-12-22 06:04:16 -04:00
|
|
|
|
2010-12-20 18:14:39 -04:00
|
|
|
[Test]
|
2010-12-22 06:04:16 -04:00
|
|
|
// For whatever reason, for Altitude the properties are sent in P, D ,I
|
|
|
|
// order, but received in P,I,D order
|
|
|
|
public void UpdateStringSentIsCorrect()
|
2010-12-20 18:14:39 -04:00
|
|
|
{
|
2010-12-22 06:04:16 -04:00
|
|
|
_vm.P = 1.0F;
|
|
|
|
_vm.I = 2.0F;
|
|
|
|
_vm.D = 3.0F;
|
2010-12-20 18:14:39 -04:00
|
|
|
|
2010-12-22 06:04:16 -04:00
|
|
|
_vm.UpdateCommand.Execute(null);
|
|
|
|
|
2010-12-23 11:59:00 -04:00
|
|
|
Assert.AreEqual(1, _mockComms.SentItems.Count);
|
|
|
|
Assert.AreEqual("E1;3;2", _mockComms.SentItems[0]);
|
2010-12-20 18:14:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
2010-12-22 06:04:16 -04:00
|
|
|
// For whatever reason, for Altitude the properties are sent in P, D ,I
|
|
|
|
// order, but received in P,I,D order
|
|
|
|
public void UpdateStringReceivedPopulatesValuesCorrectly()
|
2010-12-20 18:14:39 -04:00
|
|
|
{
|
2010-12-22 02:42:16 -04:00
|
|
|
_vm.Activate();
|
2010-12-23 11:59:00 -04:00
|
|
|
_mockComms.FireLineRecieve(sampleLineOfData);
|
2010-12-20 18:14:39 -04:00
|
|
|
|
2010-12-22 06:04:16 -04:00
|
|
|
Assert.AreEqual(0.8f, _vm.P);
|
|
|
|
Assert.AreEqual(0.2f, _vm.I);
|
|
|
|
Assert.AreEqual(0.3f, _vm.D);
|
2010-12-22 02:42:16 -04:00
|
|
|
}
|
2010-12-22 06:04:16 -04:00
|
|
|
|
|
|
|
|
2010-12-20 18:14:39 -04:00
|
|
|
}
|
2010-12-22 02:42:16 -04:00
|
|
|
}
|