Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added basic ReadFrames integration tests.

  • Loading branch information...
commit a09c8f57ebe78bc460e7201d9aedf3656305063f 1 parent d1f4886
Andrew Hawker authored
94 src/NLibsndfile.Native.Tests/Integration/Api/ReadFramesTests.cs
View
@@ -0,0 +1,94 @@
+using System;
+using NUnit.Framework;
+
+namespace NLibsndfile.Native.Tests.Integration.Api
+{
+ [TestFixture]
+ [Category("NLibsndfileApi.Native.IntegrationTests.Api")]
+ public class ReadFramesTests
+ {
+ [Test]
+ public void ReadFramesShort_ReturnsValidData()
+ {
+ const long Items = 50;
+
+ var api = new LibsndfileApi();
+ var info = new LibsndfileInfo();
+
+ var open = api.Open(TestConfiguration.ValidWavFile, LibsndfileMode.Read, ref info);
+ Assert.That(open != IntPtr.Zero);
+
+ var buffer = new short[Items];
+ var read = api.ReadFrames(open, buffer, Items);
+ Assert.That(Items == read);
+ Assert.That(buffer != null);
+ Assert.That(buffer.Length == Items);
+
+ var close = api.Close(open);
+ Assert.That(close == LibsndfileError.NoError);
+ }
+
+ [Test]
+ public void ReadFramesInt_ReturnsValidData()
+ {
+ const long Items = 50;
+
+ var api = new LibsndfileApi();
+ var info = new LibsndfileInfo();
+
+ var open = api.Open(TestConfiguration.ValidWavFile, LibsndfileMode.Read, ref info);
+ Assert.That(open != IntPtr.Zero);
+
+ var buffer = new int[Items];
+ var read = api.ReadFrames(open, buffer, Items);
+ Assert.That(Items == read);
+ Assert.That(buffer != null);
+ Assert.That(buffer.Length == Items);
+
+ var close = api.Close(open);
+ Assert.That(close == LibsndfileError.NoError);
+ }
+
+ [Test]
+ public void ReadFramesFloat_ReturnsValidData()
+ {
+ const long Items = 50;
+
+ var api = new LibsndfileApi();
+ var info = new LibsndfileInfo();
+
+ var open = api.Open(TestConfiguration.ValidWavFile, LibsndfileMode.Read, ref info);
+ Assert.That(open != IntPtr.Zero);
+
+ var buffer = new float[Items];
+ var read = api.ReadFrames(open, buffer, Items);
+ Assert.That(Items == read);
+ Assert.That(buffer != null);
+ Assert.That(buffer.Length == Items);
+
+ var close = api.Close(open);
+ Assert.That(close == LibsndfileError.NoError);
+ }
+
+ [Test]
+ public void ReadFramesDouble_ReturnsValidData()
+ {
+ const long Items = 50;
+
+ var api = new LibsndfileApi();
+ var info = new LibsndfileInfo();
+
+ var open = api.Open(TestConfiguration.ValidWavFile, LibsndfileMode.Read, ref info);
+ Assert.That(open != IntPtr.Zero);
+
+ var buffer = new double[Items];
+ var read = api.ReadFrames(open, buffer, Items);
+ Assert.That(Items == read);
+ Assert.That(buffer != null);
+ Assert.That(buffer.Length == Items);
+
+ var close = api.Close(open);
+ Assert.That(close == LibsndfileError.NoError);
+ }
+ }
+}
32 src/NLibsndfile.Native.Tests/Integration/Api/ReadItemsTests.cs
View
@@ -18,11 +18,11 @@ public void ReadItemsShort_ReturnsValidData()
var open = api.Open(TestConfiguration.ValidWavFile, LibsndfileMode.Read, ref info);
Assert.That(open != IntPtr.Zero);
- var sBuffer = new short[Items];
- var read = api.ReadItems(open, sBuffer, Items);
+ var buffer = new short[Items];
+ var read = api.ReadItems(open, buffer, Items);
Assert.That(Items == read);
- Assert.That(sBuffer != null);
- Assert.That(sBuffer.Length == Items);
+ Assert.That(buffer != null);
+ Assert.That(buffer.Length == Items);
var close = api.Close(open);
Assert.That(close == LibsndfileError.NoError);
@@ -39,11 +39,11 @@ public void ReadItemsInt_ReturnsValidData()
var open = api.Open(TestConfiguration.ValidWavFile, LibsndfileMode.Read, ref info);
Assert.That(open != IntPtr.Zero);
- var sBuffer = new int[Items];
- var read = api.ReadItems(open, sBuffer, Items);
+ var buffer = new int[Items];
+ var read = api.ReadItems(open, buffer, Items);
Assert.That(Items == read);
- Assert.That(sBuffer != null);
- Assert.That(sBuffer.Length == Items);
+ Assert.That(buffer != null);
+ Assert.That(buffer.Length == Items);
var close = api.Close(open);
Assert.That(close == LibsndfileError.NoError);
@@ -60,11 +60,11 @@ public void ReadItemsFloat_ReturnsValidData()
var open = api.Open(TestConfiguration.ValidWavFile, LibsndfileMode.Read, ref info);
Assert.That(open != IntPtr.Zero);
- var sBuffer = new float[Items];
- var read = api.ReadItems(open, sBuffer, Items);
+ var buffer = new float[Items];
+ var read = api.ReadItems(open, buffer, Items);
Assert.That(Items == read);
- Assert.That(sBuffer != null);
- Assert.That(sBuffer.Length == Items);
+ Assert.That(buffer != null);
+ Assert.That(buffer.Length == Items);
var close = api.Close(open);
Assert.That(close == LibsndfileError.NoError);
@@ -81,11 +81,11 @@ public void ReadItemsDouble_ReturnsValidData()
var open = api.Open(TestConfiguration.ValidWavFile, LibsndfileMode.Read, ref info);
Assert.That(open != IntPtr.Zero);
- var sBuffer = new double[Items];
- var read = api.ReadItems(open, sBuffer, Items);
+ var buffer = new double[Items];
+ var read = api.ReadItems(open, buffer, Items);
Assert.That(Items == read);
- Assert.That(sBuffer != null);
- Assert.That(sBuffer.Length == Items);
+ Assert.That(buffer != null);
+ Assert.That(buffer.Length == Items);
var close = api.Close(open);
Assert.That(close == LibsndfileError.NoError);
Please sign in to comment.
Something went wrong with that request. Please try again.