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

            int[] buffer = null;
            api.ReadItems(new IntPtr(1), buffer, It.IsAny <long>());
        }
예제 #2
0
        public void ReadShortItems_ShouldThrowExceptionOnLessThanZeroItems()
        {
            var api    = new LibsndfileApi();
            var buffer = new short[1];

            api.ReadItems(new IntPtr(1), buffer, -1);
        }
예제 #3
0
        public void ReadShortItems_ShouldThrowExceptionOnEmptyBuffer()
        {
            var api    = new LibsndfileApi();
            var buffer = new short[] { };

            api.ReadItems(new IntPtr(1), buffer, It.IsAny <long>());
        }
예제 #4
0
        public void ReadDoubleItems_ShouldReturnLessThanItemsRequestedThenZeroOnNextRead()
        {
            const long Items = 10;
            const long PartialItems = 10 - 5;

            var mock = new Mock<ILibsndfileApi>();
            mock.Setup(x => x.ReadItems(It.IsAny<IntPtr>(), It.IsAny<double[]>(), It.IsAny<long>())).Returns(PartialItems);

            var api = new LibsndfileApi(mock.Object);
            var buffer = new double[1];
            var retval = api.ReadItems(new IntPtr(1), buffer, Items);

            Assert.AreEqual(PartialItems, retval);

            mock.Setup(x => x.ReadItems(It.IsAny<IntPtr>(), It.IsAny<double[]>(), It.IsAny<long>())).Returns(0);
            retval = api.ReadItems(new IntPtr(1), buffer, Items);

            Assert.AreEqual(0, retval);
        }
예제 #5
0
        public void ReadShortItems_ShouldReturnLessThanItemsRequestedThenZeroOnNextRead()
        {
            const long Items        = 10;
            const long PartialItems = 10 - 5;

            var mock = new Mock <ILibsndfileApi>();

            mock.Setup(x => x.ReadItems(It.IsAny <IntPtr>(), It.IsAny <short[]>(), It.IsAny <long>())).Returns(PartialItems);

            var api    = new LibsndfileApi(mock.Object);
            var buffer = new short[1];
            var retval = api.ReadItems(new IntPtr(1), buffer, Items);

            Assert.AreEqual(PartialItems, retval);

            mock.Setup(x => x.ReadItems(It.IsAny <IntPtr>(), It.IsAny <short[]>(), It.IsAny <long>())).Returns(0);
            retval = api.ReadItems(new IntPtr(1), buffer, Items);

            Assert.AreEqual(0, retval);
        }
예제 #6
0
        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);
        }
예제 #7
0
        public void ReadShortItems_ShouldReturnSameAsItemsRequested()
        {
            const long Items = 10;

            var mock = new Mock <ILibsndfileApi>();

            mock.Setup(x => x.ReadItems(It.IsAny <IntPtr>(), It.IsAny <short[]>(), It.IsAny <long>())).Returns(Items);

            var api    = new LibsndfileApi(mock.Object);
            var buffer = new short[1];
            var retval = api.ReadItems(new IntPtr(1), buffer, Items);

            Assert.AreEqual(Items, retval);
        }
예제 #8
0
        public void ReadItemsInt_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.ReadItems(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);
        }
예제 #9
0
        public void ReadItemsDouble_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.ReadItems(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);
        }
예제 #10
0
        public void ReadIntItems_ShouldThrowExceptionOnZeroHandle()
        {
            var api = new LibsndfileApi();

            api.ReadItems(IntPtr.Zero, It.IsAny <int[]>(), It.IsAny <long>());
        }
예제 #11
0
 public void ReadDoubleItems_ShouldThrowExceptionOnZeroHandle()
 {
     var api = new LibsndfileApi();
     api.ReadItems(IntPtr.Zero, It.IsAny<double[]>(), It.IsAny<long>());
 }
예제 #12
0
 public void ReadDoubleItems_ShouldThrowExceptionOnNullBuffer()
 {
     var api = new LibsndfileApi();
     double[] buffer = null;
     api.ReadItems(new IntPtr(1), buffer, It.IsAny<long>());
 }
예제 #13
0
 public void ReadDoubleItems_ShouldThrowExceptionOnLessThanZeroItems()
 {
     var api = new LibsndfileApi();
     var buffer = new double[1];
     api.ReadItems(new IntPtr(1), buffer, -1);
 }
예제 #14
0
 public void ReadShortItems_ShouldThrowExceptionOnEmptyBuffer()
 {
     var api = new LibsndfileApi();
     var buffer = new short[] { };
     api.ReadItems(new IntPtr(1), buffer, It.IsAny<long>());
 }