Ardupilot2/Configurator/Configurator.Net/Test/AltitudeHoldVmTest.cs
2010-12-22 06:42:16 +00:00

45 lines
1.2 KiB
C#

using ArducopterConfigurator;
using NUnit.Framework;
namespace ArducopterConfiguratorTest
{
public abstract class VmTestBase<T> where T : MonitorVm
{
protected T _vm;
protected FakeComms _fakeComms;
protected string sampleLineOfData;
protected string getCommand;
protected string setCommand;
[Test]
public void ActivateSendsCorrectCommand()
{
_vm.Activate();
Assert.AreEqual(1, _fakeComms.SentItems.Count);
Assert.AreEqual(getCommand, _fakeComms.SentItems[0]);
}
[Test]
public void ReceivedDataIgnoredWhenNotActive()
{
bool inpcFired = false;
_vm.PropertyChanged += delegate { inpcFired = true; };
_fakeComms.FireLineRecieve(sampleLineOfData);
Assert.False(inpcFired);
}
[Test]
public void UpdateStringReceivedPopulatesValues()
{
bool inpcFired = false;
_vm.PropertyChanged += delegate { inpcFired = true; };
_vm.Activate();
_fakeComms.FireLineRecieve(sampleLineOfData);
Assert.True(inpcFired);
}
}
}