예제 #1
0
        public void CalcMaxAllChannels_ShouldThrowExceptionOnGreaterThanZeroResult()
        {
            var marshallerMock = new Mock<ILibsndfileMarshaller>();
            marshallerMock.Setup(x => x.AllocateArray<double>(It.IsAny<int>())).Returns(It.IsAny<IntPtr>());

            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 LibsndfileCommandApiNativeWrapper(mock.Object, marshallerMock.Object);
            api.CalcMaxAllChannels(new IntPtr(1), 1);
        }
        public void CalcMaxAllChannels_ShouldThrowExceptionOnNegativeResult()
        {
            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            marshallerMock.Setup(x => x.AllocateArray <double>(It.IsAny <int>())).Returns(It.IsAny <IntPtr>());

            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 LibsndfileCommandApiNativeWrapper(mock.Object, marshallerMock.Object);

            api.CalcMaxAllChannels(new IntPtr(1), 1);
        }
예제 #3
0
        public void CalcMaxAllChannels_ShouldPassOnZeroResult()
        {
            var Result = new[] { 1.0 };

            var memoryMock = new Mock<UnmanagedMemoryHandle>();

            var marshallerMock = new Mock<ILibsndfileMarshaller>();
            marshallerMock.Setup(x => x.AllocateArray<double>(It.IsAny<int>())).Returns(memoryMock.Object);
            marshallerMock.Setup(x => x.MemoryHandleToArray<double>(It.IsAny<UnmanagedMemoryHandle>())).Returns(Result);

            var mock = new Mock<ILibsndfileApi>();
            mock.Setup(x => x.Command(It.IsAny<IntPtr>(), It.IsAny<LibsndfileCommand>(), It.IsAny<IntPtr>(), It.IsAny<int>())).Returns(0);

            var api = new LibsndfileCommandApiNativeWrapper(mock.Object, marshallerMock.Object);
            var retval = api.CalcMaxAllChannels(new IntPtr(1), 1);

            Assert.AreEqual(Result, retval);
        }
예제 #4
0
        public void CalcMaxAllChannels_ShouldReturnArrayLengthEqualToChannelsRequested()
        {
            const int Channels = 2;
            var Result = new[] { 1.0, 2.0 };

            var memoryMock = new Mock<UnmanagedMemoryHandle>();

            var marshallerMock = new Mock<ILibsndfileMarshaller>();
            marshallerMock.Setup(x => x.AllocateArray<double>(It.IsAny<int>())).Returns(memoryMock.Object);
            marshallerMock.Setup(x => x.MemoryHandleToArray<double>(It.IsAny<UnmanagedMemoryHandle>())).Returns(Result);

            var mock = new Mock<ILibsndfileApi>();
            mock.Setup(x => x.Command(It.IsAny<IntPtr>(), It.IsAny<LibsndfileCommand>(), It.IsAny<IntPtr>(), It.IsAny<int>())).Returns(0);

            var api = new LibsndfileCommandApiNativeWrapper(mock.Object, marshallerMock.Object);
            var retval = api.CalcMaxAllChannels(new IntPtr(1), Channels);

            Assert.AreEqual(Result, retval);
            Assert.AreEqual(Channels, retval.Length);
        }
        public void CalcMaxAllChannels_ShouldPassOnZeroResult()
        {
            var Result = new[] { 1.0 };

            var memoryMock = new Mock <UnmanagedMemoryHandle>();

            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            marshallerMock.Setup(x => x.AllocateArray <double>(It.IsAny <int>())).Returns(memoryMock.Object);
            marshallerMock.Setup(x => x.MemoryHandleToArray <double>(It.IsAny <UnmanagedMemoryHandle>())).Returns(Result);

            var mock = new Mock <ILibsndfileApi>();

            mock.Setup(x => x.Command(It.IsAny <IntPtr>(), It.IsAny <LibsndfileCommand>(), It.IsAny <IntPtr>(), It.IsAny <int>())).Returns(0);

            var api    = new LibsndfileCommandApiNativeWrapper(mock.Object, marshallerMock.Object);
            var retval = api.CalcMaxAllChannels(new IntPtr(1), 1);

            Assert.AreEqual(Result, retval);
        }
        public void CalcMaxAllChannels_ShouldReturnArrayLengthEqualToChannelsRequested()
        {
            const int Channels = 2;
            var       Result   = new[] { 1.0, 2.0 };

            var memoryMock = new Mock <UnmanagedMemoryHandle>();

            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            marshallerMock.Setup(x => x.AllocateArray <double>(It.IsAny <int>())).Returns(memoryMock.Object);
            marshallerMock.Setup(x => x.MemoryHandleToArray <double>(It.IsAny <UnmanagedMemoryHandle>())).Returns(Result);

            var mock = new Mock <ILibsndfileApi>();

            mock.Setup(x => x.Command(It.IsAny <IntPtr>(), It.IsAny <LibsndfileCommand>(), It.IsAny <IntPtr>(), It.IsAny <int>())).Returns(0);

            var api    = new LibsndfileCommandApiNativeWrapper(mock.Object, marshallerMock.Object);
            var retval = api.CalcMaxAllChannels(new IntPtr(1), Channels);

            Assert.AreEqual(Result, retval);
            Assert.AreEqual(Channels, retval.Length);
        }