public void SetBroadcastInfo_ShouldThrowExceptionOnNegativeResult()
        {
            var broadcastInfo = new LibsndfileBroadcastInfo();

            var unmanagedMemoryMock = new Mock<UnmanagedMemoryHandle>();

            var marshallerMock = new Mock<ILibsndfileMarshaller>();
            marshallerMock.Setup(x => x.Allocate(broadcastInfo)).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.SetBroadcastInfo(new IntPtr(1), It.IsAny<LibsndfileBroadcastInfo>());
        }
        public void SetBroadcastInfo_ShouldReturnFalseOnZeroResult()
        {
            var broadcastInfo = new LibsndfileBroadcastInfo();

            var unmanagedMemoryMock = new Mock<UnmanagedMemoryHandle>();

            var marshallerMock = new Mock<ILibsndfileMarshaller>();
            marshallerMock.Setup(x => x.Allocate(It.IsAny<LibsndfileBroadcastInfo>())).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.SetBroadcastInfo(new IntPtr(1), It.IsAny<LibsndfileBroadcastInfo>());

            Assert.IsFalse(retval);
        }
        public void GetBroadcastInfo_ShouldPassOnOneResult()
        {
            var broadcastInfo = new LibsndfileBroadcastInfo();

            var unmanagedMemoryMock = new Mock<UnmanagedMemoryHandle>();

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

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

            Assert.AreEqual(broadcastInfo, retval);
        }
Exemple #4
0
        public void SetBroadcastInfo_ShouldThrowExceptionOnGreaterThanOneResult()
        {
            var broadcastInfo = new LibsndfileBroadcastInfo();

            var unmanagedMemoryMock = new Mock <UnmanagedMemoryHandle>();

            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            marshallerMock.Setup(x => x.Allocate(broadcastInfo)).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.SetBroadcastInfo(new IntPtr(1), It.IsAny <LibsndfileBroadcastInfo>());
        }
Exemple #5
0
        public void SetBroadcastInfo_ShouldReturnTrueOnOneResult()
        {
            var broadcastInfo = new LibsndfileBroadcastInfo();

            var unmanagedMemoryMock = new Mock <UnmanagedMemoryHandle>();

            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            marshallerMock.Setup(x => x.Allocate(broadcastInfo)).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);
            var retval = api.SetBroadcastInfo(new IntPtr(1), It.IsAny <LibsndfileBroadcastInfo>());

            Assert.IsTrue(retval);
        }