Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[.NET] Add test project and support for including native libs in build
- Loading branch information
Showing
5 changed files
with
95 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,5 @@ msbuild.wrn | |
|
||
# Visual Studio 2015 | ||
.vs/ | ||
|
||
lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" /> | ||
<PackageReference Include="xunit" Version="2.4.1" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="3.1.2"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
|
||
<ProjectReference Include="..\Cantera\Cantera.csproj" /> | ||
</ItemGroup> | ||
|
||
<Target Name="CopyLibraries" AfterTargets="AfterBuild"> | ||
<ItemGroup> | ||
<Libraries Include="$([MSBuild]::NormalizePath(../lib/))*" /> | ||
</ItemGroup> | ||
|
||
<Copy SourceFiles="@(Libraries)" DestinationFolder="$(OutDir)" /> | ||
</Target> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Cantera.Interop; | ||
using Xunit; | ||
|
||
namespace Cantera.Tests; | ||
|
||
public class CanteraExceptionTest | ||
{ | ||
[Fact] | ||
public void CanteraException_Thrown() | ||
{ | ||
Assert.Throws<CanteraException>(() => | ||
{ | ||
LibCantera.thermo_newFromFile(".yaml", ""); | ||
// test that an error message is gathered from the native library | ||
CanteraException.ThrowLatest(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Xunit; | ||
|
||
namespace Cantera.Tests; | ||
|
||
public class CanteraInfoTest | ||
{ | ||
[Fact] | ||
public void CanteraInfo_VersionRetrieved() | ||
{ | ||
// version string should start with a number | ||
Assert.Matches("^[1-9]", CanteraInfo.Version); | ||
} | ||
|
||
[Fact] | ||
public void CanteraInfo_GitCommitRetrieved() | ||
{ | ||
Assert.NotEmpty(CanteraInfo.GitCommit); | ||
} | ||
|
||
[Fact] | ||
public void CanteraInfo_DataDirectoryAdded() | ||
{ | ||
var dirs = CanteraInfo.DataDirectories; | ||
var originalCount = dirs.Count; | ||
var longestDir = dirs.MaxBy(d => d.FullName.Length); | ||
|
||
Assert.NotNull(longestDir); | ||
|
||
dirs.Add(Path.Join(longestDir!.FullName, "garbazh")); | ||
|
||
Assert.Equal(originalCount + 1, dirs.Count); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters