Skip to content

Commit 9211b9e

Browse files
authored
Merge 5e5980b into b6cde45
2 parents b6cde45 + 5e5980b commit 9211b9e

File tree

143 files changed

+85491
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+85491
-1
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "nanoFramework.TestFramework"]
2+
path = nanoFramework.TestFramework
3+
url = https://github.com/nanoframework/nanoFramework.TestFramework

NuGet.Config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
<configuration>
33
<packageSources>
44
<add key="NuGet" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
5+
<add key="Azure Artifacts nanoFramework dev" value="https://pkgs.dev.azure.com/nanoframework/feed/_packaging/sandbox/nuget/v3/index.json" protocolVersion="3" />
56
</packageSources>
67
</configuration>

README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
-----
77

8-
### Welcome to the **nanoFramework** Base Class Library repository!
8+
# Welcome to the **nanoFramework** Base Class Library repository!
99

1010
## Build status
1111

@@ -20,6 +20,40 @@
2020

2121
The **nanoFramework** Base Class Library is provided in two flavours: with or without support for System.Reflection namespace. The reason for this is that the reflection API adds up a significant size to the DLL and image size. For targets with smaller flash this can be prohibitive.
2222

23+
## Unit Test
24+
25+
nanoFramework has a dedicated [Unit Test framework](https://github.com/nanoframework/nanoFramework.TestFramework). This repository has Unit Test and you will find all of them under the `Tests`folder. The main solution embed all all the tests as well. You can run them directly from Visual Studio and create new tests. For more information on the [Unit Test Framework](https://docs.nanoframework.net/content/unit-test/index.html).
26+
27+
lib-CoreLibrary has specific needs that differ from what you'll find in the documentation:
28+
29+
- You need to have th nanoFramework.TestFramework as a nuget package as it will bring the nanoCLR Win32 emulator
30+
- You need to remove the reference to mscorlib, nanoFramework.TestFramework and nanoFramework.UnitTestLauncher
31+
- Use project reference instead for all those 3 elements
32+
33+
You can then run the test either on a real device, either in the emulator as described in the documentation. You may have to manually flash your device for the mscorlib version to match the one you are building on.
34+
35+
**Important**: Any new code checked in this repository will have to:
36+
37+
- have a proper test covering for all the methods, properties, events and the possible exceptions,
38+
- do not break more of the the existing tests meaning, in other words, it should not create more issues than already existing.
39+
40+
### Test structure and project reference
41+
42+
All the projects are referenced based and to be able to run the tests in the pipeline, in command line and in Visual Studio, it does require a specific structure:
43+
44+
- The `NFUnitTestAdapter` project must be present and untouched. It does contains the core elements needed to have the nanoCLR Win32 application present.
45+
- You need to have a `nano.runsettings` file in each sub directory you want to run the tests on from Visual Studio
46+
- If you want to run the tests in command line you have to use the `Developer Command Prompt for VS 2019` then you can use from the home cloned lib-CoreLibrary directory a command line like this one:
47+
48+
```cmd
49+
vstest.console.exe .\Tests\NFUnitTestBitConverter\bin\Release\NFUnitTest.dll /Settings:.\Tests\NFUnitTestAdapater\nano.runsettings /TestAdapterPath:.\nanoFramework.TestFramework\source\TestAdapter\bin\Debug\net4.8 /Diag:.\log.txt /Logger:trx
50+
```
51+
52+
*Notes*:
53+
54+
- You have to build the TestAdapter from the source in this case. You can use the path to the nuget as well, this will have the same effect.
55+
- you have full diagnostic enabled in this case.
56+
2357
## Feedback and documentation
2458

2559
For documentation, providing feedback, issues and finding out how to contribute please refer to the [Home repo](https://github.com/nanoframework/Home).
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// Copyright (c) .NET Foundation and Contributors
3+
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
4+
// See LICENSE file in the project root for full license information.
5+
//
6+
7+
using System.Diagnostics;
8+
9+
namespace NFUnitTestAdapater
10+
{
11+
public class DummyClass
12+
{
13+
public void DummyMethod()
14+
{
15+
Debug.WriteLine("This is just to get the TestAdapter. Don not remove this project!");
16+
}
17+
}
18+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<ProjectCapability Include="TestContainer" />
5+
</ItemGroup>
6+
<PropertyGroup Label="Globals">
7+
<NanoFrameworkProjectSystemPath>$(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\</NanoFrameworkProjectSystemPath>
8+
</PropertyGroup>
9+
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props')" />
10+
<PropertyGroup>
11+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
12+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
13+
<ProjectTypeGuids>{11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
14+
<ProjectGuid>396a2b21-8a5f-4274-9fdd-3b35dc8eae47</ProjectGuid>
15+
<OutputType>Library</OutputType>
16+
<AppDesignerFolder>Properties</AppDesignerFolder>
17+
<FileAlignment>512</FileAlignment>
18+
<RootNamespace>NFUnitTestAdpater</RootNamespace>
19+
<AssemblyName>NFUnitTest</AssemblyName>
20+
<IsCodedUITest>False</IsCodedUITest>
21+
<IsTestProject>true</IsTestProject>
22+
<TestProjectType>UnitTest</TestProjectType>
23+
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
24+
</PropertyGroup>
25+
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')" />
26+
<PropertyGroup>
27+
<RunSettingsFilePath>$(MSBuildProjectDirectory)\nano.runsettings</RunSettingsFilePath>
28+
</PropertyGroup>
29+
<ItemGroup>
30+
<Compile Include="DummyClass.cs" />
31+
<Compile Include="Properties\AssemblyInfo.cs" />
32+
</ItemGroup>
33+
<ItemGroup>
34+
<Reference Include="mscorlib, Version=1.10.1.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
35+
<HintPath>..\..\packages\nanoFramework.CoreLibrary.1.10.1-preview.11\lib\mscorlib.dll</HintPath>
36+
<Private>True</Private>
37+
<SpecificVersion>True</SpecificVersion>
38+
</Reference>
39+
<Reference Include="nanoFramework.TestFramework, Version=1.0.80.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
40+
<HintPath>..\..\packages\nanoFramework.TestFramework.1.0.80\lib\nanoFramework.TestFramework.dll</HintPath>
41+
<Private>True</Private>
42+
<SpecificVersion>True</SpecificVersion>
43+
</Reference>
44+
<Reference Include="nanoFramework.UnitTestLauncher, Version=0.0.0.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
45+
<HintPath>..\..\packages\nanoFramework.TestFramework.1.0.80\lib\nanoFramework.UnitTestLauncher.exe</HintPath>
46+
<Private>True</Private>
47+
<SpecificVersion>True</SpecificVersion>
48+
</Reference>
49+
</ItemGroup>
50+
<ItemGroup>
51+
<None Include="nano.runsettings" />
52+
<None Include="packages.config" />
53+
</ItemGroup>
54+
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
55+
<ProjectExtensions>
56+
<ProjectCapabilities>
57+
<ProjectConfigurationsDeclaredAsItems />
58+
</ProjectCapabilities>
59+
</ProjectExtensions>
60+
</Project>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("CSharp.TestApplication")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("CSharp.TestApplication")]
13+
[assembly: AssemblyCopyright("Copyright © ")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// Version information for an assembly consists of the following four values:
23+
//
24+
// Major Version
25+
// Minor Version
26+
// Build Number
27+
// Revision
28+
//
29+
// You can specify all the values or you can default the Build and Revision Numbers
30+
// by using the '*' as shown below:
31+
// [assembly: AssemblyVersion("1.0.*")]
32+
[assembly: AssemblyVersion("1.0.0.0")]
33+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RunSettings>
3+
<!-- Configurations that affect the Test Framework -->
4+
<RunConfiguration>
5+
<MaxCpuCount>1</MaxCpuCount>
6+
<ResultsDirectory>.\TestResults</ResultsDirectory><!-- Path relative to solution directory -->
7+
<TestSessionTimeout>1200000</TestSessionTimeout><!-- Milliseconds -->
8+
<TargetFrameworkVersion>Framework40</TargetFrameworkVersion>
9+
</RunConfiguration>
10+
<nanoFrameworkAdapter>
11+
<Logging>Verbose</Logging>
12+
<IsRealHardware>False</IsRealHardware>
13+
</nanoFrameworkAdapter>
14+
</RunSettings>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="nanoFramework.CoreLibrary" version="1.10.1-preview.11" targetFramework="netnanoframework10" />
4+
<package id="nanoFramework.TestFramework" version="1.0.80" targetFramework="netnanoframework10" developmentDependency="true" />
5+
</packages>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<ProjectCapability Include="TestContainer" />
5+
</ItemGroup>
6+
<PropertyGroup Label="Globals">
7+
<NanoFrameworkProjectSystemPath>$(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\</NanoFrameworkProjectSystemPath>
8+
</PropertyGroup>
9+
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props')" />
10+
<PropertyGroup>
11+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
12+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
13+
<ProjectTypeGuids>{11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
14+
<ProjectGuid>6b598666-54c8-4705-a7fb-b2bc75ca00bc</ProjectGuid>
15+
<OutputType>Library</OutputType>
16+
<AppDesignerFolder>Properties</AppDesignerFolder>
17+
<FileAlignment>512</FileAlignment>
18+
<RootNamespace>NFUnitTestArithmetic</RootNamespace>
19+
<AssemblyName>NFUnitTest</AssemblyName>
20+
<IsCodedUITest>False</IsCodedUITest>
21+
<IsTestProject>true</IsTestProject>
22+
<TestProjectType>UnitTest</TestProjectType>
23+
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
24+
</PropertyGroup>
25+
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')" />
26+
<PropertyGroup>
27+
<RunSettingsFilePath>$(MSBuildProjectDirectory)\nano.runsettings</RunSettingsFilePath>
28+
</PropertyGroup>
29+
<ItemGroup>
30+
<Compile Include="UnitTestArithmeticTest1.cs" />
31+
<Compile Include="Properties\AssemblyInfo.cs" />
32+
<Compile Include="UnitTestArithmeticTest2.cs" />
33+
<Compile Include="UnitTestExpressionTests.cs" />
34+
<Compile Include="UnitTestOtherArithmeticTests.cs" />
35+
</ItemGroup>
36+
<ItemGroup>
37+
<None Include="nano.runsettings" />
38+
</ItemGroup>
39+
<ItemGroup>
40+
<ProjectReference Include="..\..\nanoFramework.CoreLibrary\CoreLibrary.nfproj" />
41+
<ProjectReference Include="..\TestFramework\TestFramework.nfproj" />
42+
<ProjectReference Include="..\UnitTestLauncher\UnitTestLauncher.nfproj" />
43+
</ItemGroup>
44+
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
45+
<ProjectExtensions>
46+
<ProjectCapabilities>
47+
<ProjectConfigurationsDeclaredAsItems />
48+
</ProjectCapabilities>
49+
</ProjectExtensions>
50+
</Project>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("CSharp.TestApplication")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("CSharp.TestApplication")]
13+
[assembly: AssemblyCopyright("Copyright © ")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// Version information for an assembly consists of the following four values:
23+
//
24+
// Major Version
25+
// Minor Version
26+
// Build Number
27+
// Revision
28+
//
29+
// You can specify all the values or you can default the Build and Revision Numbers
30+
// by using the '*' as shown below:
31+
// [assembly: AssemblyVersion("1.0.*")]
32+
[assembly: AssemblyVersion("1.0.0.0")]
33+
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)