public void OpenFileDescriptor_ShouldThrowExceptionOnZeroHandle() { var api = new LibsndfileApi(); var info = new LibsndfileInfo(); api.OpenFileDescriptor(0, LibsndfileMode.Read, ref info, 0); }
public void Open_ShouldThrowExceptionOnEmptyPath() { var api = new LibsndfileApi(); var info = new LibsndfileInfo(); api.Open(string.Empty, LibsndfileMode.Read, ref info); }
public void Open_ShouldThrowExceptionOnNullPath() { var api = new LibsndfileApi(); var info = new LibsndfileInfo(); api.Open(null, LibsndfileMode.Read, ref info); }
public void FormatCheck_ShouldThrowExceptionOnDefaultInfoStruct() { var api = new LibsndfileApi(); var info = new LibsndfileInfo(); api.FormatCheck(ref info); }
public void OpenFileDescriptor_ShouldThrowExceptionOnNegativeOneHandle() { var api = new LibsndfileApi(); var info = new LibsndfileInfo(); api.OpenFileDescriptor(-1, LibsndfileMode.Read, ref info, 0); }
public void Open_ShouldReturnZeroHandleOnEmptyFileHandle() { var info = new LibsndfileInfo(); var mock = new Mock<ILibsndfileApi>(); mock.Setup(x => x.Open(It.IsAny<string>(), It.IsAny<LibsndfileMode>(), ref info)).Returns(IntPtr.Zero); var api = new LibsndfileApi(mock.Object); var retval = api.Open("junk.txt", LibsndfileMode.Read, ref info); Assert.AreEqual(IntPtr.Zero, retval); }
public void OpenFileDescriptor_ShouldThrowExceptionOnZeroFileHandle() { var info = new LibsndfileInfo(); var mock = new Mock<ILibsndfileApi>(); mock.Setup(x => x.OpenFileDescriptor(It.IsAny<int>(), It.IsAny<LibsndfileMode>(), ref info, It.IsAny<int>())).Returns(IntPtr.Zero); var api = new LibsndfileApi(mock.Object); var retval = api.OpenFileDescriptor(20, LibsndfileMode.Read, ref info, 0); Assert.AreEqual(IntPtr.Zero, retval); }
public void OpenFileDescriptor_ShouldThrowExceptionOnZeroFileHandle() { var info = new LibsndfileInfo(); var mock = new Mock <ILibsndfileApi>(); mock.Setup(x => x.OpenFileDescriptor(It.IsAny <int>(), It.IsAny <LibsndfileMode>(), ref info, It.IsAny <int>())).Returns(IntPtr.Zero); var api = new LibsndfileApi(mock.Object); var retval = api.OpenFileDescriptor(20, LibsndfileMode.Read, ref info, 0); Assert.AreEqual(IntPtr.Zero, retval); }
public void Open_ShouldReturnZeroHandleOnEmptyFileHandle() { var info = new LibsndfileInfo(); var mock = new Mock <ILibsndfileApi>(); mock.Setup(x => x.Open(It.IsAny <string>(), It.IsAny <LibsndfileMode>(), ref info)).Returns(IntPtr.Zero); var api = new LibsndfileApi(mock.Object); var retval = api.Open("junk.txt", LibsndfileMode.Read, ref info); Assert.AreEqual(IntPtr.Zero, retval); }
public void OpenWav_ReadModeReturnsValidHandle() { var api = new LibsndfileApi(); var info = new LibsndfileInfo(); Assert.That(File.Exists(TestConfiguration.ValidWavFile)); var open = api.Open(TestConfiguration.ValidWavFile, LibsndfileMode.Read, ref info); Assert.That(open != IntPtr.Zero); var close = api.Close(open); Assert.That(close == LibsndfileError.NoError); }
public void FormatCheck_ShouldPassOnValidFormat() { const bool Result = true; var info = new LibsndfileInfo { Format = LibsndfileFormat.Wav, Channels = 1, SampleRate = 1 }; var mock = new Mock<ILibsndfileApi>(); mock.Setup(x => x.FormatCheck(ref info)).Returns(Result); var api = new LibsndfileApi(mock.Object); var retval = api.FormatCheck(ref info); Assert.AreEqual(Result, retval); }
public void CalcMaxAllChannels_ReturnsValidData() { var api = new LibsndfileApi(); var info = new LibsndfileInfo(); var sndfile = api.Open(TestConfiguration.ValidWavFile, LibsndfileMode.Read, ref info); Assert.That(sndfile != IntPtr.Zero); var max = api.Commands.CalcMaxAllChannels(sndfile, info.Channels); Assert.That(max != null); Assert.That(max.Length == info.Channels); var close = api.Close(sndfile); Assert.That(close == LibsndfileError.NoError); }
public void FormatCheck_ShouldPassOnValidFormat() { const bool Result = true; var info = new LibsndfileInfo { Format = LibsndfileFormat.Wav, Channels = 1, SampleRate = 1 }; var mock = new Mock <ILibsndfileApi>(); mock.Setup(x => x.FormatCheck(ref info)).Returns(Result); var api = new LibsndfileApi(mock.Object); var retval = api.FormatCheck(ref info); Assert.AreEqual(Result, retval); }
public void CalcNormMaxAllChannels_ReturnsValidData() { var api = new LibsndfileApi(); var info = new LibsndfileInfo(); var sndfile = api.Open(TestConfiguration.ValidWavFile, LibsndfileMode.Read, ref info); Assert.That(sndfile != IntPtr.Zero); var max = api.Commands.CalcNormMaxAllChannels(sndfile, info.Channels); Assert.That(max != null); Assert.That(max.Length == info.Channels); var close = api.Close(sndfile); Assert.That(close == LibsndfileError.NoError); }
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); }
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); }