示例#1
0
        public void GetInstrument_ShouldThrowExceptionOnNegativeResult()
        {
            var unmanagedMemoryMock = new Mock<UnmanagedMemoryHandle>();

            var marshallerMock = new Mock<ILibsndfileMarshaller>();
            marshallerMock.Setup(x => x.Allocate<LibsndfileInstrumentInfo>()).Returns(unmanagedMemoryMock.Object);

            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.GetInstrument(new IntPtr(1));
        }
示例#2
0
        public void GetInstrument_ShouldReturnNullOnZeroResult()
        {
            var unmanagedMemoryMock = new Mock<UnmanagedMemoryHandle>();

            var marshallerMock = new Mock<ILibsndfileMarshaller>();
            marshallerMock.Setup(x => x.Allocate<LibsndfileInstrumentInfo>()).Returns(unmanagedMemoryMock.Object);

            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.GetInstrument(new IntPtr(1));

            Assert.IsFalse(retval.HasValue);
        }
示例#3
0
        public void GetInstrument_ShouldThrowExceptionOnGreaterThanOneResult()
        {
            var unmanagedMemoryMock = new Mock <UnmanagedMemoryHandle>();

            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            marshallerMock.Setup(x => x.Allocate <LibsndfileInstrumentInfo>()).Returns(unmanagedMemoryMock.Object);

            var mock = new Mock <ILibsndfileApi>();

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

            var api = new LibsndfileCommandApiNativeWrapper(mock.Object, marshallerMock.Object);

            api.GetInstrument(new IntPtr(1));
        }
示例#4
0
        public void GetInstrument_ShouldReturnNullOnZeroResult()
        {
            var unmanagedMemoryMock = new Mock <UnmanagedMemoryHandle>();

            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            marshallerMock.Setup(x => x.Allocate <LibsndfileInstrumentInfo>()).Returns(unmanagedMemoryMock.Object);

            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.GetInstrument(new IntPtr(1));

            Assert.IsFalse(retval.HasValue);
        }
示例#5
0
        public void GetLoopInfo_ShouldPassOnOneResult()
        {
            var instrumentInfo      = new LibsndfileInstrumentInfo();
            var unmanagedMemoryMock = new Mock <UnmanagedMemoryHandle>();

            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            marshallerMock.Setup(x => x.Allocate <LibsndfileInstrumentInfo>()).Returns(unmanagedMemoryMock.Object);
            marshallerMock.Setup(x => x.MemoryHandleTo <LibsndfileInstrumentInfo>(unmanagedMemoryMock.Object)).Returns(instrumentInfo);

            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);
            var retval = api.GetInstrument(new IntPtr(1));

            Assert.IsTrue(retval.HasValue);
            Assert.AreEqual(instrumentInfo, retval.Value);
        }
示例#6
0
        public void GetLoopInfo_ShouldPassOnOneResult()
        {
            var instrumentInfo = new LibsndfileInstrumentInfo();
            var unmanagedMemoryMock = new Mock<UnmanagedMemoryHandle>();

            var marshallerMock = new Mock<ILibsndfileMarshaller>();
            marshallerMock.Setup(x => x.Allocate<LibsndfileInstrumentInfo>()).Returns(unmanagedMemoryMock.Object);
            marshallerMock.Setup(x => x.MemoryHandleTo<LibsndfileInstrumentInfo>(unmanagedMemoryMock.Object)).Returns(instrumentInfo);

            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);
            var retval = api.GetInstrument(new IntPtr(1));

            Assert.IsTrue(retval.HasValue);
            Assert.AreEqual(instrumentInfo, retval.Value);
        }