public void GetFormatSubtypeCount_ShouldThrowExceptionOnNegativeResult()
        {
            var marshallerMock = new Mock<ILibsndfileMarshaller>();
            marshallerMock.Setup(x => x.Allocate<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.GetFormatSubtypeCount();
        }
Esempio n. 2
0
        public void GetFormatSubtypeCount_ShouldThrowExceptionOnGreaterThanOneResult()
        {
            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            marshallerMock.Setup(x => x.Allocate <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(2);

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

            api.GetFormatSubtypeCount();
        }
        public void GetFormatSubtypeCount_ShouldPassOnZeroResult()
        {
            const int Count = 10;

            var marshallerMock = new Mock<ILibsndfileMarshaller>();
            marshallerMock.Setup(x => x.Allocate<int>()).Returns(It.IsAny<IntPtr>());
            marshallerMock.Setup(x => x.MemoryHandleTo<int>(It.IsAny<UnmanagedMemoryHandle>())).Returns(Count);

            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.GetFormatSubtypeCount();

            Assert.AreEqual(Count, retval);
        }
Esempio n. 4
0
        public void GetFormatSubtypeCount_ShouldPassOnZeroResult()
        {
            const int Count = 10;

            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            marshallerMock.Setup(x => x.Allocate <int>()).Returns(It.IsAny <IntPtr>());
            marshallerMock.Setup(x => x.MemoryHandleTo <int>(It.IsAny <UnmanagedMemoryHandle>())).Returns(Count);

            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.GetFormatSubtypeCount();

            Assert.AreEqual(Count, retval);
        }