Skip to content

Commit

Permalink
Test: simple test template
Browse files Browse the repository at this point in the history
  • Loading branch information
meee1 committed Nov 6, 2022
1 parent 13b6d53 commit 856ef73
Show file tree
Hide file tree
Showing 4 changed files with 307 additions and 0 deletions.
10 changes: 10 additions & 0 deletions MissionPlanner.sln
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenDroneID_Plugin", "Plugi
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bulb", "ExtLibs\LEDBulb\Bulb\Bulb.csproj", "{AF81C41B-06E6-4CA5-9FD4-A4E7042F1107}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MissionPlannerTests", "MissionPlannerTests\MissionPlannerTests.csproj", "{0B99EBF2-B964-4AAC-9EC5-76353610AAAE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -891,6 +893,14 @@ Global
{AF81C41B-06E6-4CA5-9FD4-A4E7042F1107}.Release|Any CPU.Build.0 = Release|x86
{AF81C41B-06E6-4CA5-9FD4-A4E7042F1107}.Release|x86.ActiveCfg = Release|x86
{AF81C41B-06E6-4CA5-9FD4-A4E7042F1107}.Release|x86.Build.0 = Release|x86
{0B99EBF2-B964-4AAC-9EC5-76353610AAAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0B99EBF2-B964-4AAC-9EC5-76353610AAAE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0B99EBF2-B964-4AAC-9EC5-76353610AAAE}.Debug|x86.ActiveCfg = Debug|Any CPU
{0B99EBF2-B964-4AAC-9EC5-76353610AAAE}.Debug|x86.Build.0 = Debug|Any CPU
{0B99EBF2-B964-4AAC-9EC5-76353610AAAE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0B99EBF2-B964-4AAC-9EC5-76353610AAAE}.Release|Any CPU.Build.0 = Release|Any CPU
{0B99EBF2-B964-4AAC-9EC5-76353610AAAE}.Release|x86.ActiveCfg = Release|Any CPU
{0B99EBF2-B964-4AAC-9EC5-76353610AAAE}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
77 changes: 77 additions & 0 deletions MissionPlannerTests/MissionPlannerTests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{0B99EBF2-B964-4AAC-9EC5-76353610AAAE}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MissionPlannerTests</RootNamespace>
<AssemblyName>MissionPlannerTests</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</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>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utilities\BoardDetectTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ExtLibs\ArduPilot\MissionPlanner.ArduPilot.csproj">
<Project>{ca6345d3-7a6d-478b-a0ed-a58e50dcaa83}</Project>
<Name>MissionPlanner.ArduPilot</Name>
</ProjectReference>
<ProjectReference Include="..\MissionPlanner.csproj">
<Project>{A2E22272-95FE-47B6-B050-9AE7E2055BF5}</Project>
<Name>MissionPlanner</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.TestPlatform">
<Version>17.3.2</Version>
</PackageReference>
<PackageReference Include="MSTest.TestAdapter">
<Version>2.2.10</Version>
</PackageReference>
<PackageReference Include="MSTest.TestFramework">
<Version>2.2.10</Version>
</PackageReference>
<PackageReference Include="System.IO.Ports">
<Version>4.5.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Reference Include="System">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.dll</HintPath>
</Reference>
</ItemGroup>

<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

</Project>
36 changes: 36 additions & 0 deletions MissionPlannerTests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -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("MissionPlannerTests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MissionPlannerTests")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[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("0b99ebf2-b964-4aac-9ec5-76353610aaae")]

// 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")]
184 changes: 184 additions & 0 deletions MissionPlannerTests/Utilities/BoardDetectTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MissionPlanner.Utilities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MissionPlanner.ArduPilot;

namespace MissionPlanner.Utilities.Tests
{
[TestClass()]
public class BoardDetectTests
{
[TestMethod()]
public void DetectBoardTest()
{
var ans = BoardDetect.DetectBoard("com1",
new List<DeviceInfo>()
{
new DeviceInfo()
{ board = "fmuv2", description = "", hardwareid = @"USB\VID_0483&PID_5740", name = "" },

});

if (ans != BoardDetect.boards.px4v2)
Assert.Fail();
}

[TestMethod()]
public void DetectBoardTest1()
{
var ans = BoardDetect.DetectBoard("com1",
new List<DeviceInfo>()
{

new DeviceInfo()
{ board = "fmuv2-bl", description = "", hardwareid = @"USB\VID_1209&PID_5740", name = "" },

});

if (ans != BoardDetect.boards.px4v2)
Assert.Fail();
}

[TestMethod()]
public void DetectBoardTest2()
{
var ans = BoardDetect.DetectBoard("com1",
new List<DeviceInfo>()
{

new DeviceInfo()
{ board = "CubeBlack", description = "", hardwareid = @"USB\VID_2DAE&PID_0016", name = "" },

});

if (ans != BoardDetect.boards.chbootloader)
Assert.Fail();
}

[TestMethod()]
public void DetectBoardTest3()
{
var ans = BoardDetect.DetectBoard("com1",
new List<DeviceInfo>()
{

new DeviceInfo() { board = "", description = "", hardwareid = @"USB\VID_2341&PID_0010", name = "" },

});

if (ans != BoardDetect.boards.chbootloader)
Assert.Fail();
}

[TestMethod()]
public void DetectBoardTest4()
{
var ans = BoardDetect.DetectBoard("com1",
new List<DeviceInfo>()
{

new DeviceInfo() { board = "", description = "", hardwareid = @"USB\VID_26AC&PID_0010", name = "" },

});

if (ans != BoardDetect.boards.chbootloader)
Assert.Fail();
}

[TestMethod()]
public void DetectBoardTest5()
{
var ans = BoardDetect.DetectBoard("com1",
new List<DeviceInfo>()
{

new DeviceInfo() { board = "", description = "", hardwareid = @"USB\VID_26AC&PID_0032", name = "" },

});
if (ans != BoardDetect.boards.chbootloader)
Assert.Fail();
}

[TestMethod()]
public void DetectBoardTest6()
{
var ans = BoardDetect.DetectBoard("com1",
new List<DeviceInfo>()
{


new DeviceInfo() { board = "", description = "", hardwareid = @"USB\VID_26AC&PID_0001", name = "" },


});

if (ans != BoardDetect.boards.chbootloader)
Assert.Fail();
}

[TestMethod()]
public void DetectBoardTest7()
{
var ans = BoardDetect.DetectBoard("com1",
new List<DeviceInfo>()
{



new DeviceInfo()
{
board = "", description = "chibios or normal px4", hardwareid = @"USB\VID_0483&PID_5740",
name = ""
},

});

if (ans != BoardDetect.boards.chbootloader)
Assert.Fail();
}

[TestMethod()]
public void DetectBoardTest8()
{
var ans = BoardDetect.DetectBoard("com1",
new List<DeviceInfo>()
{




new DeviceInfo()
{
board = "", description = "chibios or normal px4", hardwareid = @"USB\VID_26AC&PID_0011",
name = ""
},
});

if (ans != BoardDetect.boards.chbootloader)
Assert.Fail();
}

[TestMethod()]
public void DetectBoardTest9()
{
var ans = BoardDetect.DetectBoard("com1",
new List<DeviceInfo>()
{


new DeviceInfo()
{
board = "", description = "chibios or normal px4", hardwareid = @"USB\VID_1209&PID_5740",
name = ""
},
});

if (ans != BoardDetect.boards.chbootloader)
Assert.Fail();
}
}
}

0 comments on commit 856ef73

Please sign in to comment.