public void GetLibVersion_ShouldThrowExceptionOnNegativeResult() { var marshallerMock = new Mock<ILibsndfileMarshaller>(); marshallerMock.Setup(x => x.Allocate(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.GetLibVersion(); }
public void GetLibVersion_ShouldThrowExceptionOnZeroResult() { var marshallerMock = new Mock <ILibsndfileMarshaller>(); marshallerMock.Setup(x => x.Allocate(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(0); var api = new LibsndfileCommandApiNativeWrapper(mock.Object, marshallerMock.Object); api.GetLibVersion(); }
public void GetLibVersion_ShouldPassOnValidResult() { const string Version = "1.0"; var memoryMock = new Mock<UnmanagedMemoryHandle>(); var marshallerMock = new Mock<ILibsndfileMarshaller>(); marshallerMock.Setup(x => x.Allocate(It.IsAny<int>())).Returns(memoryMock.Object); marshallerMock.Setup(x => x.MemoryHandleToString(It.IsAny<UnmanagedMemoryHandle>())).Returns(Version); 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.GetLibVersion(); Assert.AreEqual(Version, retval); }
public void GetLibVersion_ShouldPassOnValidResult() { const string Version = "1.0"; var memoryMock = new Mock <UnmanagedMemoryHandle>(); var marshallerMock = new Mock <ILibsndfileMarshaller>(); marshallerMock.Setup(x => x.Allocate(It.IsAny <int>())).Returns(memoryMock.Object); marshallerMock.Setup(x => x.MemoryHandleToString(It.IsAny <UnmanagedMemoryHandle>())).Returns(Version); 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.GetLibVersion(); Assert.AreEqual(Version, retval); }