예제 #1
0
        public void OpenFileDescriptor_ShouldThrowExceptionOnZeroHandle()
        {
            var api = new LibsndfileApi();
            var info = new LibsndfileInfo();

            api.OpenFileDescriptor(0, LibsndfileMode.Read, ref info, 0);
        }
예제 #2
0
        public void Open_ShouldThrowExceptionOnEmptyPath()
        {
            var api = new LibsndfileApi();
            var info = new LibsndfileInfo();

            api.Open(string.Empty, LibsndfileMode.Read, ref info);
        }
예제 #3
0
        public void Open_ShouldThrowExceptionOnEmptyPath()
        {
            var api  = new LibsndfileApi();
            var info = new LibsndfileInfo();

            api.Open(string.Empty, LibsndfileMode.Read, ref info);
        }
예제 #4
0
        public void Open_ShouldThrowExceptionOnNullPath()
        {
            var api = new LibsndfileApi();
            var info = new LibsndfileInfo();

            api.Open(null, LibsndfileMode.Read, ref info);
        }
예제 #5
0
        public void FormatCheck_ShouldThrowExceptionOnDefaultInfoStruct()
        {
            var api = new LibsndfileApi();
            var info = new LibsndfileInfo();

            api.FormatCheck(ref info);
        }
예제 #6
0
        public void Open_ShouldThrowExceptionOnNullPath()
        {
            var api  = new LibsndfileApi();
            var info = new LibsndfileInfo();

            api.Open(null, LibsndfileMode.Read, ref info);
        }
예제 #7
0
        public void OpenFileDescriptor_ShouldThrowExceptionOnNegativeOneHandle()
        {
            var api  = new LibsndfileApi();
            var info = new LibsndfileInfo();

            api.OpenFileDescriptor(-1, LibsndfileMode.Read, ref info, 0);
        }
예제 #8
0
        public void FormatCheck_ShouldThrowExceptionOnDefaultInfoStruct()
        {
            var api  = new LibsndfileApi();
            var info = new LibsndfileInfo();

            api.FormatCheck(ref info);
        }
예제 #9
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);
        }
예제 #10
0
        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);
        }
예제 #11
0
        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);
        }
예제 #12
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);
        }
예제 #13
0
        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);
        }
예제 #14
0
        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);
        }
예제 #15
0
        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);
        }
예제 #16
0
        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);
        }
예제 #17
0
        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);
        }
예제 #19
0
        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);
        }
예제 #20
0
        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);
        }