Browse Source
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1219 f9c3cf11-9bcb-44bc-f272-b75c42450872master
21 changed files with 331 additions and 26 deletions
@ -0,0 +1,48 @@
@@ -0,0 +1,48 @@
|
||||
using ArducopterConfigurator.PresentationModels; |
||||
using NUnit.Framework; |
||||
|
||||
namespace ArducopterConfiguratorTest |
||||
{ |
||||
[TestFixture] |
||||
public class AltitudeHoldVmTest |
||||
{ |
||||
private FakeComms _fakeComms; |
||||
private AltitudeHoldConfigVm _vm; |
||||
|
||||
[SetUp] |
||||
public void Setup() |
||||
{ |
||||
_fakeComms = new FakeComms(); |
||||
_vm = new AltitudeHoldConfigVm(_fakeComms); |
||||
} |
||||
|
||||
[Test] |
||||
public void UpdateStringSentIsCorrect() |
||||
{ |
||||
_vm.P = 1.0F; |
||||
_vm.I = 2.0F; |
||||
_vm.D = 3.0F; |
||||
|
||||
_vm.UpdateCommand.Execute(null); |
||||
|
||||
Assert.AreEqual(1, _fakeComms.SentItems.Count); |
||||
|
||||
Assert.AreEqual("E1;3;2", _fakeComms.SentItems[0]); |
||||
|
||||
} |
||||
|
||||
[Test] |
||||
// For whatever reason, for Altitude the properties are sent in P, D ,I |
||||
// order, but received in P,I,D order |
||||
public void UpdateStringReceivedPopulatesValuesCorrectly() |
||||
{ |
||||
_fakeComms.FireLineRecieve("F1;2;3"); |
||||
|
||||
Assert.AreEqual(1f, _vm.P); |
||||
Assert.AreEqual(2f, _vm.I); |
||||
Assert.AreEqual(3f, _vm.D); |
||||
} |
||||
|
||||
|
||||
} |
||||
} |
@ -0,0 +1,62 @@
@@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<ProductVersion>9.0.30729</ProductVersion> |
||||
<SchemaVersion>2.0</SchemaVersion> |
||||
<ProjectGuid>{36B62E9F-668C-45BF-AD72-CFF0C0A65898}</ProjectGuid> |
||||
<OutputType>Library</OutputType> |
||||
<AppDesignerFolder>Properties</AppDesignerFolder> |
||||
<RootNamespace>ArducopterConfiguratorTest</RootNamespace> |
||||
<AssemblyName>ArducopterConfiguratorTest</AssemblyName> |
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion> |
||||
<FileAlignment>512</FileAlignment> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>full</DebugType> |
||||
<Optimize>false</Optimize> |
||||
<OutputPath>bin\Debug\</OutputPath> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
<ErrorReport>prompt</ErrorReport> |
||||
<WarningLevel>4</WarningLevel> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
||||
<DebugType>pdbonly</DebugType> |
||||
<Optimize>true</Optimize> |
||||
<OutputPath>bin\Release\</OutputPath> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
<ErrorReport>prompt</ErrorReport> |
||||
<WarningLevel>4</WarningLevel> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="nunit.framework, Version=2.5.9.10348, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> |
||||
<SpecificVersion>False</SpecificVersion> |
||||
<HintPath>..\Lib3\nunit.framework.dll</HintPath> |
||||
</Reference> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Data" /> |
||||
<Reference Include="System.Xml" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="AltitudeHoldVmTest.cs" /> |
||||
<Compile Include="MainVmTests.cs" /> |
||||
<Compile Include="MotorCommandsVmTest.cs" /> |
||||
<Compile Include="Properties\AssemblyInfo.cs" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ProjectReference Include="..\ArducopterConfigurator.csproj"> |
||||
<Project>{AF26391C-7E45-4401-8984-96139A67FF31}</Project> |
||||
<Name>ArducopterConfigurator</Name> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. |
||||
Other similar extension points exist, see Microsoft.Common.targets. |
||||
<Target Name="BeforeBuild"> |
||||
</Target> |
||||
<Target Name="AfterBuild"> |
||||
</Target> |
||||
--> |
||||
</Project> |
@ -0,0 +1,123 @@
@@ -0,0 +1,123 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Text; |
||||
using ArducopterConfigurator; |
||||
using ArducopterConfigurator.PresentationModels; |
||||
using NUnit.Framework; |
||||
|
||||
namespace ArducopterConfiguratorTest |
||||
{ |
||||
internal class FakeComms : IComms |
||||
{ |
||||
public event Action<string> LineOfDataReceived; |
||||
public string CommPort { get; set; } |
||||
public List<string> SentItems = new List<string>(); |
||||
|
||||
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 |
||||
{ |
||||
private FakeComms _fakeComms; |
||||
private MainVm _vm; |
||||
|
||||
[SetUp] |
||||
public void Setup() |
||||
{ |
||||
_fakeComms = new FakeComms(); |
||||
_vm = new MainVm(_fakeComms); |
||||
} |
||||
|
||||
[Test] |
||||
public void StateInitiallyDisconnected() |
||||
{ |
||||
Assert.AreEqual(MainVm.SessionStates.Disconnected,_vm.ConnectionState); |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
|
||||
[TestFixture] |
||||
public class StableModeConfigVmTest |
||||
{ |
||||
private FakeComms _fakeComms; |
||||
private StableModeConfigVm _vm; |
||||
|
||||
[SetUp] |
||||
public void Setup() |
||||
{ |
||||
_fakeComms = new FakeComms(); |
||||
_vm = new StableModeConfigVm(_fakeComms); |
||||
|
||||
|
||||
} |
||||
|
||||
[Test] |
||||
public void UpdateStringSentIsCorrect() |
||||
{ |
||||
_vm.PitchP = 1.0F; |
||||
_vm.PitchI = 2.0F; |
||||
_vm.PitchD = 3.0F; |
||||
_vm.RollP = 5.0F; |
||||
_vm.RollI = 6.0F; |
||||
_vm.RollD = 7.0F; |
||||
_vm.YawP = 8.0F; |
||||
_vm.YawI = 9.0F; |
||||
_vm.YawD = 10.0F; |
||||
_vm.MagnetometerEnable = true; |
||||
_vm.KPrate = 4.0F; |
||||
|
||||
_vm.UpdateCommand.Execute(null); |
||||
|
||||
|
||||
Assert.AreEqual(1,_fakeComms.SentItems.Count); |
||||
|
||||
//A[KP Quad Roll];[KI Quad Roll];[KP RATE ROLL]; |
||||
// [KP Quad Pitch];[KI Quad Pitch];[KP RATE PITCH]; |
||||
// [KP Quad Yaw];[KI Quad Yaw];[KP Rate Yaw]; |
||||
// [KP Rate];[Magneto] |
||||
Assert.AreEqual("A5;6;7;1;2;3;8;9;10;4;1", _fakeComms.SentItems[0]); |
||||
} |
||||
|
||||
[Test] |
||||
public void UpdateStringReceivedPopulatesValuesCorrectly() |
||||
{ |
||||
_fakeComms.FireLineRecieve("B5;6;7;1;2;3;8;9;10;4;1"); |
||||
|
||||
Assert.AreEqual(1.0f,_vm.PitchP); |
||||
Assert.AreEqual(2f,_vm.PitchI); |
||||
Assert.AreEqual(3f,_vm.PitchD); |
||||
Assert.AreEqual(5f,_vm.RollP); |
||||
Assert.AreEqual(6f,_vm.RollI); |
||||
Assert.AreEqual(7f,_vm.RollD); |
||||
Assert.AreEqual(8f,_vm.YawP); |
||||
Assert.AreEqual(9f,_vm.YawI); |
||||
Assert.AreEqual(10f,_vm.YawD); |
||||
Assert.AreEqual(1f,_vm.MagnetometerEnable); |
||||
Assert.AreEqual(4f,_vm.KPrate); |
||||
} |
||||
|
||||
|
||||
} |
||||
} |
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
using ArducopterConfigurator.PresentationModels; |
||||
using NUnit.Framework; |
||||
|
||||
namespace ArducopterConfiguratorTest |
||||
{ |
||||
[TestFixture] |
||||
public class MotorCommandsVmTest |
||||
{ |
||||
private FakeComms _fakeComms; |
||||
private MotorCommandsVm _vm; |
||||
|
||||
[SetUp] |
||||
public void Setup() |
||||
{ |
||||
_fakeComms = new FakeComms(); |
||||
_vm = new MotorCommandsVm(_fakeComms); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
} |
||||
} |
@ -0,0 +1,36 @@
@@ -0,0 +1,36 @@
|
||||
using System.Reflection; |
||||
using System.Runtime.CompilerServices; |
||||
using System.Runtime.InteropServices; |
||||
|
||||
// General Information about an assembly is controlled through the following |
||||
// set of attributes. Change these attribute values to modify the information |
||||
// associated with an assembly. |
||||
[assembly: AssemblyTitle("ArducopterConfiguratorTest")] |
||||
[assembly: AssemblyDescription("")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyCompany("TOSHIBA")] |
||||
[assembly: AssemblyProduct("ArducopterConfiguratorTest")] |
||||
[assembly: AssemblyCopyright("Copyright © TOSHIBA 2010")] |
||||
[assembly: AssemblyTrademark("")] |
||||
[assembly: AssemblyCulture("")] |
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible |
||||
// to COM components. If you need to access a type in this assembly from |
||||
// COM, set the ComVisible attribute to true on that type. |
||||
[assembly: ComVisible(false)] |
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM |
||||
[assembly: Guid("19d172a3-8241-459a-bee7-3318a20fce16")] |
||||
|
||||
// Version information for an assembly consists of the following four values: |
||||
// |
||||
// Major Version |
||||
// Minor Version |
||||
// Build Number |
||||
// Revision |
||||
// |
||||
// You can specify all the values or you can default the Build and Revision Numbers |
||||
// by using the '*' as shown below: |
||||
// [assembly: AssemblyVersion("1.0.*")] |
||||
[assembly: AssemblyVersion("1.0.0.0")] |
||||
[assembly: AssemblyFileVersion("1.0.0.0")] |
Loading…
Reference in new issue