public void CommandDouble_ShouldThrowExceptionOnZeroHandleWithNonStaticCommand() { var doubleRef = It.IsAny <double>(); var api = new LibsndfileApi(); api.Command(IntPtr.Zero, LibsndfileCommand.GetLogInfo, ref doubleRef, It.IsAny <int>()); }
public void ReadShortItems_ShouldThrowExceptionOnEmptyBuffer() { var api = new LibsndfileApi(); var buffer = new short[] { }; api.ReadItems(new IntPtr(1), buffer, It.IsAny <long>()); }
public void Open_ShouldThrowExceptionOnNullPath() { var api = new LibsndfileApi(); var info = new LibsndfileInfo(); api.Open(null, LibsndfileMode.Read, ref info); }
public void ReadShortItems_ShouldThrowExceptionOnLessThanZeroItems() { var api = new LibsndfileApi(); var buffer = new short[1]; api.ReadItems(new IntPtr(1), buffer, -1); }
public void CommandDoubleArray_ShouldThrowExceptionOnEmptyData() { var api = new LibsndfileApi(); var data = new double[] { }; api.Command(new IntPtr(1), It.IsAny <LibsndfileCommand>(), data, It.IsAny <int>()); }
public void WriteDoubleItems_ShouldThrowExceptionOnEmptyBuffer() { var api = new LibsndfileApi(); var buffer = new double[] { }; api.WriteItems(new IntPtr(1), buffer, It.IsAny <long>()); }
public void WriteShortItems_ShouldThrowExceptionOnNullBuffer() { var api = new LibsndfileApi(); short[] buffer = null; api.WriteItems(new IntPtr(1), buffer, It.IsAny <long>()); }
public void WriteFloatItems_ShouldThrowExceptionOnLessThanZeroItems() { var api = new LibsndfileApi(); var buffer = new float[1]; api.WriteItems(new IntPtr(1), buffer, -1); }
public void ReadIntItems_ShouldThrowExceptionOnNullBuffer() { var api = new LibsndfileApi(); int[] buffer = null; api.ReadItems(new IntPtr(1), buffer, It.IsAny <long>()); }
public void Open_ShouldThrowExceptionOnEmptyPath() { var api = new LibsndfileApi(); var info = new LibsndfileInfo(); api.Open(string.Empty, LibsndfileMode.Read, ref info); }
public void OpenFileDescriptor_ShouldThrowExceptionOnZeroHandle() { var api = new LibsndfileApi(); var info = new LibsndfileInfo(); api.OpenFileDescriptor(0, LibsndfileMode.Read, ref info, 0); }
public void GetLibVersion_ReturnsCorrectVersion() { var api = new LibsndfileApi(); var version = api.Commands.GetLibVersion(); Assert.That(!string.IsNullOrEmpty(version)); }
public void ReadDoubleFrames_ShouldThrowExceptionOnEmptyBuffer() { var api = new LibsndfileApi(); var buffer = new double[] { }; api.ReadFrames(new IntPtr(1), buffer, It.IsAny <long>()); }
public void ReadDoubleFrames_ShouldThrowExceptionOnLessThanZeroItems() { var api = new LibsndfileApi(); var buffer = new double[1]; api.ReadFrames(new IntPtr(1), buffer, -1); }
public void FormatCheck_ShouldThrowExceptionOnDefaultInfoStruct() { var api = new LibsndfileApi(); var info = new LibsndfileInfo(); api.FormatCheck(ref info); }
public void ReadShortFrames_ShouldThrowExceptionOnNullBuffer() { var api = new LibsndfileApi(); short[] buffer = null; api.ReadFrames(new IntPtr(1), buffer, It.IsAny <long>()); }
public void WriteRaw_ShouldThrowExceptionOnNullBuffer() { var api = new LibsndfileApi(); byte[] buffer = null; api.WriteRaw(new IntPtr(1), buffer, It.IsAny <long>()); }
public void OpenFileDescriptor_ShouldThrowExceptionOnNegativeOneHandle() { var api = new LibsndfileApi(); var info = new LibsndfileInfo(); api.OpenFileDescriptor(-1, LibsndfileMode.Read, ref info, 0); }
public void WriteRaw_ShouldThrowExceptionOnEmptyBuffer() { var api = new LibsndfileApi(); var buffer = new byte[] { }; api.WriteRaw(new IntPtr(1), buffer, It.IsAny <long>()); }
public void WriteRaw_ShouldThrowExceptionOnLessThanZeroItems() { var api = new LibsndfileApi(); var buffer = new byte[1]; api.WriteRaw(new IntPtr(1), buffer, -1); }
public void Close_ShouldThrowExceptionOnErrorResult() { var mock = new Mock<ILibsndfileApi>(); mock.Setup(x => x.Close(It.IsAny<IntPtr>())).Returns(LibsndfileError.MalformedFile); var api = new LibsndfileApi(mock.Object); api.Close(new IntPtr(1)); }
public void ErrorString_ShouldThrowExceptionOnEmptyStringReturned() { var mock = new Mock<ILibsndfileApi>(); mock.Setup(x => x.ErrorString(It.IsAny<IntPtr>())).Returns(string.Empty); var api = new LibsndfileApi(mock.Object); api.ErrorString(new IntPtr(1)); }
public void ErrorNumber_ShouldThrowExceptionOnNullStringReturned() { var mock = new Mock<ILibsndfileApi>(); mock.Setup(x => x.ErrorNumber(It.IsAny<int>())).Returns((string)null); var api = new LibsndfileApi(mock.Object); api.ErrorNumber(1); }
public void Seek_ShouldThrowExceptionOnNegativeOffset() { var mock = new Mock<ILibsndfileApi>(); mock.Setup(x => x.Seek(It.IsAny<IntPtr>(), It.IsAny<long>(), It.IsAny<int>())).Returns(-1); var api = new LibsndfileApi(mock.Object); api.Seek(new IntPtr(1), 1, 1); }
public void CommandDoubleArray_ShouldThrowExceptionOnInvalidResult() { var data = new double[1]; var mock = new Mock<ILibsndfileApi>(); mock.Setup(x => x.Command(It.IsAny<IntPtr>(), It.IsAny<LibsndfileCommand>(), data, It.IsAny<int>())).Returns(-1); var api = new LibsndfileApi(mock.Object); api.Command(new IntPtr(1), It.IsAny<LibsndfileCommand>(), data, It.IsAny<int>()); }
public void Close_ShouldPassOnNoErrorResult() { var mock = new Mock<ILibsndfileApi>(); mock.Setup(x => x.Close(It.IsAny<IntPtr>())).Returns(LibsndfileError.NoError); var api = new LibsndfileApi(mock.Object); var retval = api.Close(new IntPtr(1)); Assert.AreEqual(LibsndfileError.NoError, retval); }
public void SetString_ShouldPassOnNoErrorResult() { var mock = new Mock<ILibsndfileApi>(); mock.Setup(x => x.SetString(It.IsAny<IntPtr>(), It.IsAny<LibsndfileStringType>(), It.IsAny<string>())).Returns(LibsndfileError.NoError); var api = new LibsndfileApi(mock.Object); var retval = api.SetString(new IntPtr(1), LibsndfileStringType.Album, "album"); Assert.AreEqual(LibsndfileError.NoError, retval); }
public void Seek_ShouldThrowExceptionOnNegativeOffset() { var mock = new Mock <ILibsndfileApi>(); mock.Setup(x => x.Seek(It.IsAny <IntPtr>(), It.IsAny <long>(), It.IsAny <int>())).Returns(-1); var api = new LibsndfileApi(mock.Object); api.Seek(new IntPtr(1), 1, 1); }
public void ErrorNumber_ShouldThrowExceptionOnNullStringReturned() { var mock = new Mock <ILibsndfileApi>(); mock.Setup(x => x.ErrorNumber(It.IsAny <int>())).Returns((string)null); var api = new LibsndfileApi(mock.Object); api.ErrorNumber(1); }
public void Close_ShouldThrowExceptionOnErrorResult() { var mock = new Mock <ILibsndfileApi>(); mock.Setup(x => x.Close(It.IsAny <IntPtr>())).Returns(LibsndfileError.MalformedFile); var api = new LibsndfileApi(mock.Object); api.Close(new IntPtr(1)); }
public void CommandIntPtr_ShouldThrowExceptionOnInvalidResult() { var mock = new Mock <ILibsndfileApi>(); mock.Setup(x => x.Command(It.IsAny <IntPtr>(), It.IsAny <LibsndfileCommand>(), It.IsAny <IntPtr>(), It.IsAny <int>())).Returns(-1); var api = new LibsndfileApi(mock.Object); api.Command(new IntPtr(1), It.IsAny <LibsndfileCommand>(), It.IsAny <IntPtr>(), It.IsAny <int>()); }
public void SetString_ShouldThrowExceptionOnErrorResult() { var mock = new Mock <ILibsndfileApi>(); mock.Setup(x => x.SetString(It.IsAny <IntPtr>(), It.IsAny <LibsndfileStringType>(), It.IsAny <string>())).Returns(LibsndfileError.MalformedFile); var api = new LibsndfileApi(mock.Object); api.SetString(new IntPtr(1), LibsndfileStringType.Album, "album"); }
public void ErrorString_ShouldThrowExceptionOnEmptyStringReturned() { var mock = new Mock <ILibsndfileApi>(); mock.Setup(x => x.ErrorString(It.IsAny <IntPtr>())).Returns(string.Empty); var api = new LibsndfileApi(mock.Object); api.ErrorString(new IntPtr(1)); }
public void Close_ShouldPassOnNoErrorResult() { var mock = new Mock <ILibsndfileApi>(); mock.Setup(x => x.Close(It.IsAny <IntPtr>())).Returns(LibsndfileError.NoError); var api = new LibsndfileApi(mock.Object); var retval = api.Close(new IntPtr(1)); Assert.AreEqual(LibsndfileError.NoError, retval); }
public void CommandDoubleArray_ShouldPassOnZeroHandleWithStaticCommand() { var data = new double[1]; var mock = new Mock<ILibsndfileApi>(); mock.Setup(x => x.Command(It.IsAny<IntPtr>(), It.IsAny<LibsndfileCommand>(), It.IsAny<double[]>(), It.IsAny<int>())).Returns(1); var api = new LibsndfileApi(mock.Object); var retval = api.Command(IntPtr.Zero, LibsndfileCommand.GetLibVersion, data, It.IsAny<int>()); Assert.Greater(retval, 0); }
public void SetString_ShouldPassOnNoErrorResult() { var mock = new Mock <ILibsndfileApi>(); mock.Setup(x => x.SetString(It.IsAny <IntPtr>(), It.IsAny <LibsndfileStringType>(), It.IsAny <string>())).Returns(LibsndfileError.NoError); var api = new LibsndfileApi(mock.Object); var retval = api.SetString(new IntPtr(1), LibsndfileStringType.Album, "album"); Assert.AreEqual(LibsndfileError.NoError, retval); }
public void CommandIntPtr_ShouldPassOnZeroHandleWithStaticCommand() { var mock = new Mock <ILibsndfileApi>(); mock.Setup(x => x.Command(It.IsAny <IntPtr>(), It.IsAny <LibsndfileCommand>(), It.IsAny <IntPtr>(), It.IsAny <int>())).Returns(1); var api = new LibsndfileApi(mock.Object); var retval = api.Command(IntPtr.Zero, LibsndfileCommand.GetLibVersion, IntPtr.Zero, It.IsAny <int>()); Assert.Greater(retval, 0); }
public void GetString_ShouldReturnValidString() { const string Tag = "AlbumTag"; var mock = new Mock<ILibsndfileApi>(); mock.Setup(x => x.GetString(It.IsAny<IntPtr>(), It.IsAny<LibsndfileStringType>())).Returns(Tag); var api = new LibsndfileApi(mock.Object); var retval = api.GetString(new IntPtr(1), It.IsAny<LibsndfileStringType>()); Assert.AreEqual(Tag, 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 ErrorString_ShouldReturnValidErrorString() { const string ErrorString = "Libsndfile encountered no errors."; var mock = new Mock<ILibsndfileApi>(); mock.Setup(x => x.ErrorString(It.IsAny<IntPtr>())).Returns(ErrorString); var api = new LibsndfileApi(mock.Object); var retval = api.ErrorString(new IntPtr(1)); Assert.AreEqual(ErrorString, retval); }
public void Seek_ShouldPassOnCorrectOffsetFromBeginning() { const int Result = 42; var mock = new Mock<ILibsndfileApi>(); mock.Setup(x => x.Seek(It.IsAny<IntPtr>(), It.IsAny<long>(), It.IsAny<int>())).Returns(Result); var api = new LibsndfileApi(mock.Object); var retval = api.Seek(new IntPtr(1), 42, 1); Assert.AreEqual(Result, 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 ReadDoubleItems_ShouldReturnSameAsItemsRequested() { const long Items = 10; var mock = new Mock<ILibsndfileApi>(); mock.Setup(x => x.ReadItems(It.IsAny<IntPtr>(), It.IsAny<double[]>(), It.IsAny<long>())).Returns(Items); var api = new LibsndfileApi(mock.Object); var buffer = new double[1]; var retval = api.ReadItems(new IntPtr(1), buffer, Items); Assert.AreEqual(Items, retval); }
public void ReadRaw_ShouldReturnSameAsItemsRequested() { const long Bytes = 10; var mock = new Mock<ILibsndfileApi>(); mock.Setup(x => x.ReadRaw(It.IsAny<IntPtr>(), It.IsAny<byte[]>(), It.IsAny<long>())).Returns(Bytes); var api = new LibsndfileApi(mock.Object); var buffer = new byte[1]; var retval = api.ReadRaw(new IntPtr(1), buffer, Bytes); Assert.AreEqual(Bytes, retval); }
public void WriteFloatFrames_ShouldReturnSameAsItemsRequested() { const long Frames = 10; var mock = new Mock<ILibsndfileApi>(); mock.Setup(x => x.WriteFrames(It.IsAny<IntPtr>(), It.IsAny<float[]>(), It.IsAny<long>())).Returns(Frames); var api = new LibsndfileApi(mock.Object); var buffer = new float[1]; var retval = api.WriteFrames(new IntPtr(1), buffer, Frames); Assert.AreEqual(Frames, 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 OpenWav_ReadWriteModeReturnsValidHandle() { var api = new LibsndfileApi(); var info = TestConfiguration.GetValidWavFileInfo(); Assert.That(File.Exists(TestConfiguration.ValidWavFile)); var open = api.Open(TestConfiguration.ValidWavFile, LibsndfileMode.Rdwr, ref info); Assert.That(open != IntPtr.Zero); var close = api.Close(open); Assert.That(close == LibsndfileError.NoError); }
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 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 OpenWav_WriteModeReturnsValidHandle() { var api = new LibsndfileApi(); var info = TestConfiguration.GetValidWavFileInfo(); var filename = string.Format("tmp_{0}", TestConfiguration.ValidWavFile); var open = api.Open(filename, LibsndfileMode.Write, ref info); Assert.That(open != IntPtr.Zero); Assert.That(File.Exists(filename)); var close = api.Close(open); Assert.That(close == LibsndfileError.NoError); File.Delete(filename); Assert.That(!File.Exists(filename)); }
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 ReadRaw_ShouldReturnLessThanItemsRequestedThenZeroOnNextRead() { const long Bytes = 10; const long PartialBytes = 10 - 5; var mock = new Mock<ILibsndfileApi>(); mock.Setup(x => x.ReadRaw(It.IsAny<IntPtr>(), It.IsAny<byte[]>(), It.IsAny<long>())).Returns(PartialBytes); var api = new LibsndfileApi(mock.Object); var buffer = new byte[1]; var retval = api.ReadRaw(new IntPtr(1), buffer, Bytes); Assert.AreEqual(PartialBytes, retval); mock.Setup(x => x.ReadRaw(It.IsAny<IntPtr>(), It.IsAny<byte[]>(), It.IsAny<long>())).Returns(0); retval = api.ReadRaw(new IntPtr(1), buffer, Bytes); Assert.AreEqual(0, retval); }
public void ReadRaw_ShouldThrowExceptionOnLessThanZeroItems() { var api = new LibsndfileApi(); var buffer = new byte[1]; api.ReadRaw(new IntPtr(1), buffer, -1); }
public void ReadRaw_ShouldThrowExceptionOnNullBuffer() { var api = new LibsndfileApi(); byte[] buffer = null; api.ReadRaw(new IntPtr(1), buffer, It.IsAny<long>()); }
public void ReadRaw_ShouldThrowExceptionOnZeroHandle() { var api = new LibsndfileApi(); api.ReadRaw(IntPtr.Zero, It.IsAny<byte[]>(), It.IsAny<long>()); }