2010-12-22 06:04:16 -04:00
|
|
|
using ArducopterConfigurator;
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
|
namespace ArducopterConfiguratorTest
|
|
|
|
{
|
|
|
|
public abstract class VmTestBase<T> where T : MonitorVm
|
|
|
|
{
|
|
|
|
protected T _vm;
|
2010-12-23 11:59:00 -04:00
|
|
|
protected MockComms _mockComms;
|
2010-12-22 06:04:16 -04:00
|
|
|
protected string sampleLineOfData; // should be taken from a real APM if possible
|
|
|
|
protected string getCommand;
|
|
|
|
protected string setCommand;
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void ActivateSendsCorrectCommand()
|
|
|
|
{
|
|
|
|
_vm.Activate();
|
2010-12-23 11:59:00 -04:00
|
|
|
Assert.AreEqual(1, _mockComms.SentItems.Count);
|
|
|
|
Assert.AreEqual(getCommand, _mockComms.SentItems[0]);
|
2010-12-22 06:04:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void ReceivedDataIgnoredWhenNotActive()
|
|
|
|
{
|
|
|
|
bool inpcFired = false;
|
|
|
|
_vm.PropertyChanged += delegate { inpcFired = true; };
|
|
|
|
|
2010-12-23 11:59:00 -04:00
|
|
|
_mockComms.FireLineRecieve(sampleLineOfData);
|
2010-12-22 06:04:16 -04:00
|
|
|
Assert.False(inpcFired);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void ReceivedDataIgnoredAfterDeActive()
|
|
|
|
{
|
|
|
|
_vm.Activate();
|
2010-12-23 11:59:00 -04:00
|
|
|
_mockComms.FireLineRecieve(sampleLineOfData);
|
2010-12-22 06:04:16 -04:00
|
|
|
_vm.DeActivate();
|
2010-12-23 11:59:00 -04:00
|
|
|
_mockComms.FireLineRecieve(sampleLineOfData);
|
2010-12-22 06:04:16 -04:00
|
|
|
bool inpcFired = false;
|
|
|
|
_vm.PropertyChanged += delegate { inpcFired = true; };
|
|
|
|
|
|
|
|
Assert.False(inpcFired);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void UpdateStringReceivedPopulatesValues()
|
|
|
|
{
|
|
|
|
bool inpcFired = false;
|
|
|
|
_vm.PropertyChanged += delegate { inpcFired = true; };
|
|
|
|
|
|
|
|
_vm.Activate();
|
2010-12-23 11:59:00 -04:00
|
|
|
_mockComms.FireLineRecieve(sampleLineOfData);
|
2010-12-22 06:04:16 -04:00
|
|
|
|
|
|
|
Assert.True(inpcFired);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|