Skip to content

Commit

Permalink
Fixes unit tests
Browse files Browse the repository at this point in the history
Added delta in where needed.

Also enabled saving trx file for test runs
  • Loading branch information
atruskie committed May 29, 2020
1 parent f9c3388 commit 55c288b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
5 changes: 5 additions & 0 deletions tests/Acoustics.Test/.runsettings
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
<!-- <verbosity>detailed</verbosity> -->
</Configuration>
</Logger>
<Logger friendlyName="trx">
<Configuration>
<!-- <verbosity>detailed</verbosity> -->
</Configuration>
</Logger>
</Loggers>
</LoggerRunSettings>
<DataCollectionRunSettings>
Expand Down
4 changes: 2 additions & 2 deletions tests/Acoustics.Test/AnalysisBase/AnalysisCoordinatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -901,15 +901,15 @@ private void AssertFilesAreAsExpected(int stage, State state, CoordinatorPathTes
foreach (var file in state.ShouldExist)
{
var f = file.FormatToken(paths);
Trace.WriteLine(f);
//Trace.WriteLine(f);

Assert.That.PathExists(f, $"(stage: {stage}, pre-templated string: \"{file}\")");
}

foreach (var file in state.ShouldNotExist)
{
var f = file.FormatToken(paths);
Trace.WriteLine(f);
//Trace.WriteLine(f);
Assert.That.PathNotExists(file, $"(stage: {stage}, pre-templated string: \"{file}\")");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public void TestRecognizer()
Assert.AreEqual(6.0720181405895692, secondEvent.EventEndSeconds);
Assert.AreEqual(483, secondEvent.LowFrequencyHertz);
Assert.AreEqual(735, secondEvent.HighFrequencyHertz);
Assert.AreEqual(20.901882476071698, secondEvent.Score);
Assert.AreEqual(0.20786700431266195, secondEvent.ScoreNormalized);
Assert.AreEqual(20.901882476071698, secondEvent.Score, TestHelper.AllowedDelta);
Assert.AreEqual(0.20786700431266195, secondEvent.ScoreNormalized, TestHelper.AllowedDelta);
}
}
}
7 changes: 7 additions & 0 deletions tests/Acoustics.Test/TestHelpers/TestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ namespace Acoustics.Test.TestHelpers
/// </summary>
public static class TestHelper
{
/// <summary>
/// A generally tolerable delta for unit tests that experience
/// computational errors. Use this only if needed and only for
/// errors derived from floating-point calculations.
/// <summary>
public const double AllowedDelta = 1.0E-9;

public static readonly IReadOnlyDictionary<string, AudioUtilityInfo> AudioDetails = new Dictionary<string, AudioUtilityInfo>
{
{
Expand Down

0 comments on commit 55c288b

Please sign in to comment.