2010-12-20 18:14:39 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using ArducopterConfigurator;
|
|
|
|
|
using ArducopterConfigurator.PresentationModels;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
|
|
|
namespace ArducopterConfiguratorTest
|
|
|
|
|
{
|
2010-12-23 11:59:00 -04:00
|
|
|
|
public class MockComms : IComms
|
2010-12-20 18:14:39 -04:00
|
|
|
|
{
|
|
|
|
|
public event Action<string> LineOfDataReceived;
|
|
|
|
|
public string CommPort { get; set; }
|
|
|
|
|
public List<string> SentItems = new List<string>();
|
|
|
|
|
|
2010-12-23 11:59:00 -04:00
|
|
|
|
public bool IsConnected
|
|
|
|
|
{
|
|
|
|
|
get { throw new NotImplementedException(); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<string> ListCommPorts()
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-20 18:14:39 -04:00
|
|
|
|
public void Send(string send)
|
|
|
|
|
{
|
|
|
|
|
SentItems.Add(send);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Connect()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool DisConnect()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void FireLineRecieve(string s)
|
|
|
|
|
{
|
|
|
|
|
if (LineOfDataReceived != null)
|
|
|
|
|
LineOfDataReceived(s);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class MainVmTests
|
|
|
|
|
{
|
2010-12-23 11:59:00 -04:00
|
|
|
|
private MockComms _mockComms;
|
2010-12-20 18:14:39 -04:00
|
|
|
|
private MainVm _vm;
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
2010-12-23 11:59:00 -04:00
|
|
|
|
_mockComms = new MockComms();
|
|
|
|
|
_vm = new MainVm(_mockComms);
|
2010-12-20 18:14:39 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void StateInitiallyDisconnected()
|
|
|
|
|
{
|
2010-12-22 02:42:16 -04:00
|
|
|
|
Assert.AreEqual(MainVm.SessionStates.Disconnected, _vm.ConnectionState);
|
2010-12-20 18:14:39 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-12-22 02:42:16 -04:00
|
|
|
|
|