public void GetFormatInfo_ShouldThrowExceptionOnNegativeResult() { var marshallerMock = new Mock<ILibsndfileMarshaller>(); marshallerMock.Setup(x => x.Allocate(It.IsAny<LibsndfileEmbedFileInfo>())).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.GetEmbedFileInfo(new IntPtr(1)); }
public void GetFormatInfo_ShouldThrowExceptionOnGreaterThanOneResult() { var marshallerMock = new Mock <ILibsndfileMarshaller>(); marshallerMock.Setup(x => x.Allocate(It.IsAny <LibsndfileEmbedFileInfo>())).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.GetEmbedFileInfo(new IntPtr(1)); }
public void GetFormatInfo_ShouldPassOnZeroResult() { var formatInfo = new LibsndfileEmbedFileInfo(); var memoryMock = new Mock<UnmanagedMemoryHandle>(); var marshallerMock = new Mock<ILibsndfileMarshaller>(); marshallerMock.Setup(x => x.Allocate(It.IsAny<LibsndfileEmbedFileInfo>())).Returns(memoryMock.Object); marshallerMock.Setup(x => x.MemoryHandleTo<LibsndfileEmbedFileInfo>(It.IsAny<UnmanagedMemoryHandle>())).Returns(formatInfo); 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.GetEmbedFileInfo(new IntPtr(1)); Assert.AreEqual(formatInfo, retval); }
public void GetFormatInfo_ShouldPassOnZeroResult() { var formatInfo = new LibsndfileEmbedFileInfo(); var memoryMock = new Mock <UnmanagedMemoryHandle>(); var marshallerMock = new Mock <ILibsndfileMarshaller>(); marshallerMock.Setup(x => x.Allocate(It.IsAny <LibsndfileEmbedFileInfo>())).Returns(memoryMock.Object); marshallerMock.Setup(x => x.MemoryHandleTo <LibsndfileEmbedFileInfo>(It.IsAny <UnmanagedMemoryHandle>())).Returns(formatInfo); 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.GetEmbedFileInfo(new IntPtr(1)); Assert.AreEqual(formatInfo, retval); }