Skip to content

Commit

Permalink
Apply style and fix some warnings
Browse files Browse the repository at this point in the history
[RELEASE]

Also attempted to suppress log verbosity to console on CI server
  • Loading branch information
atruskie committed Mar 5, 2018
1 parent 7657fe0 commit cf95e13
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace Acoustics.Test.AnalysisBase
[TestClass]
public class AnalysisCoordinatorTests
{
protected DirectoryInfo outputDirectory;
private DirectoryInfo outputDirectory;

[TestInitialize]
public void Setup()
Expand Down Expand Up @@ -188,7 +188,6 @@ public void RemovesDuplicateSegmentsAfterSplitting()
{
SegmentStartOffset = 0.Seconds(),
SegmentEndOffset = 60.0.Seconds(),

},
};

Expand Down
1 change: 0 additions & 1 deletion tests/Acoustics.Test/AnalysisBase/AnalysisSettingsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public void Initialize()
this.original.AnalysisOutputDirectory = new DirectoryInfo("/");

this.cloned = (AnalysisSettings)this.original.Clone();

}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,18 @@ namespace Acoustics.Test.AnalysisPrograms.Concatenation
/// (4) for binary large objects(BLOBs) make sure git-lfs is tracking them
/// </summary>
[TestClass]
// [Ignore]
public class ConcatenationTests : OutputDirectoryTest
{
private static DirectoryInfo indonesiaIndicesDirectory;

private static DirectoryInfo newZealandArk01IndicesDirectory;

private const string IndonesiaReduced = "Indonesia_2Reduced";

private const string NewZealandArk01 = "NewZealandArk01";

/// Use ClassInitialize to run code before running the first test in the class
[ClassInitialize()]
private static DirectoryInfo indonesiaIndicesDirectory;

private static DirectoryInfo newZealandArk01IndicesDirectory;

// Use ClassInitialize to run code before running the first test in the class
[ClassInitialize]
public static void MyClassInitialize(TestContext testContext)
{
var indonesiaIndices = PathHelper.ResolveAsset("Concatenation", IndonesiaReduced + ".zip");
Expand Down Expand Up @@ -157,8 +156,8 @@ public void ConcatenateIndexFilesTest24Hour()
Assert.That.FileExists(outputDataDir.CombineFile(prefix + "Towsey.Acoustic.Indices.csv"));
Assert.That.FileNotExists(outputDataDir.CombineFile(prefix + "SummaryIndex.csv"));


var actualImage = ImageTools.ReadImage2Bitmap(imageFileInfo.FullName);

// we expect only the second half (past midnight) of the image to be rendered
Assert.That.ImageIsSize(512, 632, actualImage);
Assert.That.PixelIsColor(new Point(100, 100), Color.FromArgb(32, 25, 36), actualImage);
Expand Down Expand Up @@ -222,7 +221,7 @@ public void ConcatenateIndexFilesTest24HourWithoutDateRange()

// IMAGE 2: Compare image files - check that image exists and dimensions are correct
var dateString2 = "20160726";
var outputDataDir2= this.outputDirectory.Combine(arguments.FileStemName, dateString2);
var outputDataDir2 = this.outputDirectory.Combine(arguments.FileStemName, dateString2);
var prefix2 = arguments.FileStemName + "_" + dateString2 + "__";

var image2FileInfo = outputDataDir2.CombineFile(prefix2 + "2Maps.png");
Expand Down Expand Up @@ -298,7 +297,7 @@ public void ConcatenateIndexFilesTestConfigFileChanges()
/// Thus there's a column of data for every 20 pixels.
/// </summary>
[DataTestMethod]
[DataRow(ConcatMode.TimedGaps, new [] {1440, 1420, 1440})]
[DataRow(ConcatMode.TimedGaps, new[] { 1440, 1420, 1440 })]
[DataRow(ConcatMode.NoGaps, new[] { 73, 72, 73 })]
[DataRow(ConcatMode.EchoGaps, new[] { 1440, 1420, 1440 })]
public void SampledDataConcatModeTests(ConcatMode gapRendering, int[] expectedWidths)
Expand All @@ -325,7 +324,7 @@ public void SampledDataConcatModeTests(ConcatMode gapRendering, int[] expectedWi

ConcatenateIndexFiles.Execute(arguments);

var dateStrings = new[] {"20161209", "20161210", "20161211"}.Zip(expectedWidths, ValueTuple.Create);
var dateStrings = new[] { "20161209", "20161210", "20161211" }.Zip(expectedWidths, ValueTuple.Create);
foreach (var (dateString, expectedWidth) in dateStrings)
{
var prefix = Path.Combine(this.outputDirectory.FullName, Ark01, dateString, Ark01 + "_" + dateString + "__");
Expand Down Expand Up @@ -379,10 +378,7 @@ public void SampledDataConcatModeTests(ConcatMode gapRendering, int[] expectedWi
default:
throw new ArgumentOutOfRangeException(nameof(gapRendering), gapRendering, null);
}

}
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ public void TestGenerateTiles()
/// Tests the rendering of zooming spectrograms for a minute of audio indices
/// </summary>
[TestMethod]
//[Timeout(45_000)]
public void TestGenerateTilesSqlite()
{
// generate the zooming spectrograms
Expand Down
34 changes: 2 additions & 32 deletions tests/Acoustics.Test/ArrayExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,10 @@ namespace Acoustics.Test
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

/// <summary>
/// Summary description for ArrayExtensionsTests
/// </summary>
[TestClass]
public class ArrayExtensionsTests
{
public ArrayExtensionsTests()
{
//
// TODO: Add constructor logic here
//
}

private const int TestSize = 1000000;
private TestContext testContextInstance;

/// <summary>
Expand All @@ -39,34 +30,13 @@ public TestContext TestContext
{
return this.testContextInstance;
}

set
{
this.testContextInstance = value;
}
}

//
// You can use the following additional attributes as you write your tests:
//
// Use ClassInitialize to run code before running the first test in the class
// [ClassInitialize()]
// public static void MyClassInitialize(TestContext testContext) { }
//
// Use ClassCleanup to run code after all tests in a class have run
// [ClassCleanup()]
// public static void MyClassCleanup() { }
//
// Use TestInitialize to run code before running each test
// [TestInitialize()]
// public void MyTestInitialize() { }
//
// Use TestCleanup to run code after each test has run
// [TestCleanup()]
// public void MyTestCleanup() { }
//

private const int TestSize = 1000000;

[TestMethod]
public void TestArrayFill()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public void TestBinaryClusteringOfSpectra()

// test what used to be the CLS spectral index. Sum of the rows of the weight vectors.
var expectedSpectrumFile = new FileInfo(outputDir + "\\clusterSpectrum.bin");

// Binary.Serialize(expectedSpectrumFile, clusterSpectrum);
var expectedVector = Binary.Deserialize<double[]>(expectedSpectrumFile);
CollectionAssert.AreEqual(expectedVector, clusterSpectrum);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ namespace Acoustics.Test.AudioAnalysisTools.TileImage
[TestClass]
public class AbsoluteDateTimeTilerTests
{
private readonly DateTimeOffset dateTimeOffset = new DateTimeOffset(2015, 04, 10, 3, 30, 15, 123, TimeSpan.FromHours(10));
private AbsoluteDateTilingProfile tilingProfile;
private Tiler tiler;
private DirectoryInfo outputDirectory;
private AbsoluteDateTilingProfile tilingProfileNotRoundStart;
private readonly DateTimeOffset dateTimeOffset = new DateTimeOffset(2015, 04, 10, 3, 30, 15, 123, TimeSpan.FromHours(10));

[TestInitialize]
public void Setup()
Expand Down Expand Up @@ -64,7 +64,7 @@ public void TestNamingPattern()

Assert.AreEqual("Basename__Tag_20150409T173015.123Z_60", profile.GetFileBaseName(this.tiler.CalculatedLayers, this.tiler.CalculatedLayers.First(), new Point(0, 0)));

var profile2 = new AbsoluteDateTilingProfile("", "Tag", this.dateTimeOffset, 256, 300);
var profile2 = new AbsoluteDateTilingProfile(string.Empty, "Tag", this.dateTimeOffset, 256, 300);

Assert.AreEqual("Tag_20150409T173015.123Z_60", profile2.GetFileBaseName(this.tiler.CalculatedLayers, this.tiler.CalculatedLayers.First(), new Point(0, 0)));
}
Expand All @@ -73,7 +73,7 @@ public void TestNamingPattern()
public void TestLeftPaddingInLowerLayers()
{
const int TileWidth = 180;
var startDate = new DateTimeOffset(2014, 05, 29, 08,13, 58, TimeSpan.FromHours(10));
var startDate = new DateTimeOffset(2014, 05, 29, 08, 13, 58, TimeSpan.FromHours(10));
var boundary = ZoomTiledSpectrograms.GetPreviousTileBoundary(TileWidth, 0.1, startDate);
var padding = startDate - boundary;

Expand Down Expand Up @@ -136,7 +136,7 @@ public void TestLeftPaddingInLowerLayers()
var expectedImages =
expectedFiles
.OrderBy(x => x)
.Select((x, i) => testBitmap.Crop(new Rectangle(i * TileWidth - 100, 0, TileWidth, 256)))
.Select((x, i) => testBitmap.Crop(new Rectangle((i * TileWidth) - 100, 0, TileWidth, 256)))
.ToArray();

for (var i = 0; i < expectedImages.Length; i++)
Expand Down
5 changes: 2 additions & 3 deletions tests/Acoustics.Test/TestHelpers/Assertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public static void AreEqual(
actualEnum.Dispose();
}
}

public static void AreEqual(
this CollectionAssert collectionAssert,
double[,] expected,
Expand Down Expand Up @@ -112,7 +113,6 @@ public static void AreEqual(
$"At index [{i},{j}], expected item `{expectedItem}` does not match `{actualItem}`. "
+ $"Actual delta is `{actualDelta}`");
}

}
}
}
Expand Down Expand Up @@ -226,8 +226,7 @@ public static void ShouldEqualWithDiff(this string actualValue, string expectedV
i < expectedValue.Length ? ((int)expectedValue[i]).ToString() : string.Empty, // character decimal value
i < expectedValue.Length ? expectedValue[i].ToSafeString() : string.Empty, // character safe string
i < actualValue.Length ? ((int)actualValue[i]).ToString() : string.Empty, // character decimal value
i < actualValue.Length ? actualValue[i].ToSafeString() : string.Empty // character safe string
);
i < actualValue.Length ? actualValue[i].ToSafeString() : string.Empty); // character safe string
}
}

Expand Down
15 changes: 7 additions & 8 deletions tests/Acoustics.Test/TestHelpers/Setup.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
// <copyright file="DotNetVersionTests.cs" company="QutEcoacoustics">
// <copyright file="Setup.cs" company="QutEcoacoustics">
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Acoustics.Test.TestHelpers
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using global::AnalysisPrograms;
using global::AnalysisPrograms.Production.Arguments;
using Microsoft.VisualStudio.TestTools.UnitTesting;
Expand All @@ -20,7 +19,7 @@ public class Setup
[AssemblyInitialize]
public static void AssemblyInitialize(TestContext context)
{
MainEntry.SetLogVerbosity(LogVerbosity.Warn, false);
MainEntry.SetLogVerbosity(LogVerbosity.Warn, true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public void SoxSelectsChannels1234Correctly()
new[] { 1000 },
};

ChannelTest(FourChannelFile, new[] {1, 2, 3, 4 }, false, expectedFrequencies);
ChannelTest(FourChannelFile, new[] { 1, 2, 3, 4 }, false, expectedFrequencies);
}

[TestMethod]
Expand All @@ -183,7 +183,7 @@ public void SoxMixesDownChannels1And2Correctly()
// array of channels of frequencies (expected in each channel)
var expectedFrequencies = new[]
{
new[] { 4000, 3000},
new[] { 4000, 3000 },
};

ChannelTest(FourChannelFile, new[] { 1, 2 }, true, expectedFrequencies);
Expand All @@ -210,7 +210,7 @@ public void SoxMixesDownChannels1234Correctly()
new[] { 4000, 3000, 2000, 1000 },
};

ChannelTest(FourChannelFile, new[] {1, 2, 3, 4 }, true, expectedFrequencies);
ChannelTest(FourChannelFile, new[] { 1, 2, 3, 4 }, true, expectedFrequencies);
}

[TestMethod]
Expand Down
7 changes: 7 additions & 0 deletions tests/Acoustics.Test/Tools/AudioUtilityFfmpegPcmRawTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public void FailsWithMissingBitDepth()
//BitDepth = 16,
TargetSampleRate = 22050,
Channels = new[] { 1, 2, 3, 4 },

//BandPass
};

Expand All @@ -176,6 +177,7 @@ public void FailsWithInvalidBitDepth()
BitDepth = 64,
TargetSampleRate = 22050,
Channels = new[] { 1, 2, 3, 4 },

//BandPass
};

Expand All @@ -200,8 +202,11 @@ public void FailsWithMissingSampleRate()
var request = new AudioUtilityRequest
{
BitDepth = 16,

//TargetSampleRate = 22050,

Channels = new[] { 1, 2, 3, 4 },

//BandPass
};

Expand All @@ -217,6 +222,7 @@ public void FailsWithMissingChannels()
{
BitDepth = 16,
TargetSampleRate = 22050,

//Channels = new[] { 1, 2, 3, 4 },
//BandPass
};
Expand All @@ -234,6 +240,7 @@ public void FailsChannelSelection()
BitDepth = 16,
TargetSampleRate = 22050,
Channels = new[] { 5, 2, 3, 4 },

//BandPass
};

Expand Down
8 changes: 8 additions & 0 deletions tests/Acoustics.Test/Tools/AudioUtilityWavTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,10 @@ public void SegmentsWavCorrectly1Shntool()
var request = new AudioUtilityRequest
{
//MixDownToMono = true,

OffsetStart = TimeSpan.FromSeconds(20),
OffsetEnd = TimeSpan.FromSeconds(50),

//TargetSampleRate = 17460
};

Expand Down Expand Up @@ -262,7 +264,9 @@ public void SegmentsWavCorrectly2Shntool()
var request = new AudioUtilityRequest
{
//MixDownToMono = true,

OffsetEnd = TimeSpan.FromSeconds(35),

//TargetSampleRate = 17460
};

Expand Down Expand Up @@ -364,8 +368,10 @@ public void SegmentsWavCorrectly5Shntool()
var request = new AudioUtilityRequest
{
//MixDownToMono = true,

OffsetStart = TimeSpan.FromSeconds(27),
OffsetEnd = TimeSpan.FromSeconds(117),

//TargetSampleRate = 17460
};

Expand Down Expand Up @@ -400,7 +406,9 @@ public void SegmentsWavCorrectly6Shntool()
{
//MixDownToMono = false,
//Channel = 2,

OffsetStart = TimeSpan.FromSeconds(27),

//TargetSampleRate = 17460,
};

Expand Down
Loading

0 comments on commit cf95e13

Please sign in to comment.