Exemplo n.º 1
0
        public void GetFormatSubtype_ShouldPassOnZeroResult()
        {
            var formatInfo = new LibsndfileFormatInfo {
                Format = LibsndfileFormat.Wav, Name = "Wav", Extension = ".wav"
            };

            var allocatedFormatInfo = new LibsndfileFormatInfo {
                Format = LibsndfileFormat.Wav
            };

            var memoryMock = new Mock <UnmanagedMemoryHandle>();

            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            marshallerMock.Setup(x => x.Allocate(allocatedFormatInfo)).Returns(memoryMock.Object);
            marshallerMock.Setup(x => x.MemoryHandleTo <LibsndfileFormatInfo>(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.GetFormatSubtype(LibsndfileFormat.Wav);

            Assert.AreEqual(formatInfo, retval);
        }
Exemplo n.º 2
0
        public void SetAmbisonic_ShouldThrowExceptionOnOneResult()
        {
            var marshallerMock = new Mock<ILibsndfileMarshaller>();

            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.SetAmbisonic(new IntPtr(1), LibsndfileMode.AmbisonicBFormat);
        }
Exemplo n.º 3
0
        public void GetNormFloat_ShouldThrowExceptionOnNegativeResult()
        {
            var marshallerMock = new Mock<ILibsndfileMarshaller>();

            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.GetNormFloat(new IntPtr(1));
        }
Exemplo n.º 4
0
        public void SetClipping_ShouldThrowExceptionOnGreaterThanOneResult()
        {
            var marshallerMock = new Mock<ILibsndfileMarshaller>();

            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.SetClipping(new IntPtr(1), It.IsAny<bool>());
        }
Exemplo n.º 5
0
        public void GetSimpleFormatCount_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.GetSimpleFormatCount();
        }
Exemplo n.º 6
0
        public void GetSignalMax_ShouldThrowExceptionOnGreaterThanZeroResult()
        {
            var marshallerMock = new Mock<ILibsndfileMarshaller>();
            marshallerMock.Setup(x => x.Allocate<double>()).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.GetSignalMax(new IntPtr(1));
        }
Exemplo n.º 7
0
        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));
        }
Exemplo n.º 8
0
        public void GetFormatMajor_ShouldThrowExceptionOnNegativeResult()
        {
            var marshallerMock = new Mock<ILibsndfileMarshaller>();
            marshallerMock.Setup(x => x.Allocate(It.IsAny<LibsndfileFormatInfo>())).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.GetFormatMajor(LibsndfileFormat.Wav);
        }
Exemplo n.º 9
0
        public void SetRawStartOffset_ShouldThrowExceptionOnGreaterThanZeroResult()
        {
            var marshallerMock = new Mock<ILibsndfileMarshaller>();
            marshallerMock.Setup(x => x.Allocate(It.IsAny<long>())).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.SetRawStartOffset(new IntPtr(1), It.IsAny<long>());
        }
Exemplo n.º 10
0
        public void UpdateHeaderNow_ShouldPassOnZeroResult()
        {
            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(0);

            var api = new LibsndfileCommandApiNativeWrapper(mock.Object, marshallerMock.Object);
            api.UpdateHeaderNow(new IntPtr(1));
        }
Exemplo n.º 11
0
        public void FileTruncate_ShouldThrowExceptionOnNegativeResult()
        {
            var marshallerMock = new Mock<ILibsndfileMarshaller>();
            marshallerMock.Setup(x => x.Allocate(It.IsAny<long>())).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.FileTruncate(new IntPtr(1), It.IsAny<long>());
        }
Exemplo n.º 12
0
        public void SetNormFloat_ShouldThrowExceptionOnGreaterThanOneResult()
        {
            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            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.SetNormFloat(new IntPtr(1), It.IsAny <bool>());
        }
Exemplo n.º 13
0
        public void RawNeedsEndianSwap_ShouldPassOnZeroResult()
        {
            var marshallerMock = new Mock<ILibsndfileMarshaller>();

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

            Assert.IsFalse(retval);
        }
Exemplo n.º 14
0
        public void SetAmbisonic_ShouldThrowExceptionOnOneResult()
        {
            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            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.SetAmbisonic(new IntPtr(1), LibsndfileMode.AmbisonicBFormat);
        }
Exemplo n.º 15
0
        public void SetAddPeakChunk_ShouldThrowExceptionOnNegativeResult()
        {
            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            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.SetAddPeakChunk(new IntPtr(1), It.IsAny <bool>());
        }
Exemplo n.º 16
0
        public void SetRawStartOffset_ShouldPassOnValidResult()
        {
            const int Result = 0;

            var marshallerMock = new Mock<ILibsndfileMarshaller>();
            marshallerMock.Setup(x => x.Allocate(It.IsAny<long>())).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(Result);

            var api = new LibsndfileCommandApiNativeWrapper(mock.Object, marshallerMock.Object);
            api.SetRawStartOffset(new IntPtr(1), 1);
        }
Exemplo n.º 17
0
        public void SetInstrument_ShouldThrowExceptionOnGreaterThanOneResult()
        {
            var unmanagedMemoryMock = new Mock<UnmanagedMemoryHandle>();

            var marshallerMock = new Mock<ILibsndfileMarshaller>();
            marshallerMock.Setup(x => x.Allocate(It.IsAny<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.SetInstrument(IntPtr.Zero, It.IsAny<LibsndfileInstrumentInfo>());
        }
Exemplo n.º 18
0
        public void GetBroadcastInfo_ShouldThrowExceptionOnNegativeResult()
        {
            var unmanagedMemoryMock = new Mock<UnmanagedMemoryHandle>();

            var marshallerMock = new Mock<ILibsndfileMarshaller>();
            marshallerMock.Setup(x => x.Allocate<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(-1);

            var api = new LibsndfileCommandApiNativeWrapper(mock.Object, marshallerMock.Object);
            api.GetBroadcastInfo(new IntPtr(1));
        }
Exemplo n.º 19
0
        public void RawNeedsEndianSwap_ShouldPassOnOneResult()
        {
            var marshallerMock = new Mock <ILibsndfileMarshaller>();

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

            Assert.IsTrue(retval);
        }
Exemplo n.º 20
0
        public void SetVbrEncodingQuality_ShouldThrowExceptionOnNegativeResult()
        {
            var unmanagedMemoryMock = new Mock<UnmanagedMemoryHandle>();

            var marshallerMock = new Mock<ILibsndfileMarshaller>();
            marshallerMock.Setup(x => x.Allocate(It.IsAny<double>())).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.SetVbrEncodingQuality(new IntPtr(1), It.IsAny<double>());
        }
Exemplo n.º 21
0
        public void FileTruncate_ShouldPassOnValidResult()
        {
            var marshallerMock = new Mock<ILibsndfileMarshaller>();
            marshallerMock.Setup(x => x.Allocate(It.IsAny<long>())).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);
            var retval = api.FileTruncate(new IntPtr(1), 1);

            Assert.AreEqual(true, retval);
        }
        public void CalcNormMaxAllChannels_ShouldThrowExceptionOnGreaterThanZeroResult()
        {
            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            marshallerMock.Setup(x => x.AllocateArray <double>(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.CalcNormMaxAllChannels(new IntPtr(1), 1);
        }
Exemplo n.º 23
0
        public void GetAmbisonic_ShouldPassOnZeroResult()
        {
            const int Result = 0;

            var marshallerMock = new Mock<ILibsndfileMarshaller>();

            var mock = new Mock<ILibsndfileApi>();
            mock.Setup(x => x.Command(It.IsAny<IntPtr>(), It.IsAny<LibsndfileCommand>(), It.IsAny<IntPtr>(), It.IsAny<int>())).Returns(Result);

            var api = new LibsndfileCommandApiNativeWrapper(mock.Object, marshallerMock.Object);
            var retval = api.GetAmbisonic(new IntPtr(1));

            Assert.AreEqual(Convert.ToBoolean(Result), retval);
        }
Exemplo n.º 24
0
        public void SetRawStartOffset_ShouldThrowExceptionOnNegativeResult()
        {
            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            marshallerMock.Setup(x => x.Allocate(It.IsAny <long>())).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.SetRawStartOffset(new IntPtr(1), It.IsAny <long>());
        }
Exemplo n.º 25
0
        public void SetAmbisonic_ShouldReturnTrueOnModeMatch()
        {
            const int Result = 0x40;

            var marshallerMock = new Mock<ILibsndfileMarshaller>();

            var mock = new Mock<ILibsndfileApi>();
            mock.Setup(x => x.Command(It.IsAny<IntPtr>(), It.IsAny<LibsndfileCommand>(), It.IsAny<IntPtr>(), It.IsAny<int>())).Returns(Result);

            var api = new LibsndfileCommandApiNativeWrapper(mock.Object, marshallerMock.Object);
            var retval = api.SetAmbisonic(new IntPtr(1), LibsndfileMode.AmbisonicNone);

            Assert.IsTrue(retval);
        }
Exemplo n.º 26
0
        public void SetUpdateHeaderAuto_ShouldPassOnZeroResult()
        {
            const int AutoUpdate = 0;

            var marshallerMock = new Mock<ILibsndfileMarshaller>();

            var mock = new Mock<ILibsndfileApi>();
            mock.Setup(x => x.Command(It.IsAny<IntPtr>(), It.IsAny<LibsndfileCommand>(), It.IsAny<IntPtr>(), It.IsAny<int>())).Returns(AutoUpdate);

            var api = new LibsndfileCommandApiNativeWrapper(mock.Object, marshallerMock.Object);
            var retval = api.SetUpdateHeaderAuto(new IntPtr(1), It.IsAny<bool>());

            Assert.AreEqual(Convert.ToBoolean(AutoUpdate), retval);
        }
Exemplo n.º 27
0
        public void UpdateHeaderNow_ShouldPassOnZeroResult()
        {
            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(0);

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

            api.UpdateHeaderNow(new IntPtr(1));
        }
Exemplo n.º 28
0
        public void SetClipping_ShouldPassOnZeroClipping()
        {
            const int Clipping = 0;

            var marshallerMock = new Mock<ILibsndfileMarshaller>();

            var mock = new Mock<ILibsndfileApi>();
            mock.Setup(x => x.Command(It.IsAny<IntPtr>(), It.IsAny<LibsndfileCommand>(), It.IsAny<IntPtr>(), It.IsAny<int>())).Returns(Clipping);

            var api = new LibsndfileCommandApiNativeWrapper(mock.Object, marshallerMock.Object);
            var retval = api.SetClipping(new IntPtr(1), It.IsAny<bool>());

            Assert.AreEqual(Convert.ToBoolean(Clipping), retval);
        }
Exemplo n.º 29
0
        public void CalcSignalMax_ShouldThrowExceptionOnNegativeResult()
        {
            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            marshallerMock.Setup(x => x.Allocate <double>()).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.CalcSignalMax(new IntPtr(1));
        }
Exemplo n.º 30
0
        public void GetFormatSubtype_ShouldThrowExceptionOnGreaterThanOneResult()
        {
            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            marshallerMock.Setup(x => x.Allocate(It.IsAny <LibsndfileFormatInfo>())).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.GetFormatSubtype(LibsndfileFormat.Wav);
        }
Exemplo n.º 31
0
        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();
        }
Exemplo n.º 32
0
        public void GetNormFloat_ShouldPassOnZeroNormalization()
        {
            const int Normalization = 0;

            var marshallerMock = new Mock<ILibsndfileMarshaller>();

            var mock = new Mock<ILibsndfileApi>();
            mock.Setup(x => x.Command(It.IsAny<IntPtr>(), It.IsAny<LibsndfileCommand>(), It.IsAny<IntPtr>(), It.IsAny<int>())).Returns(Normalization);

            var api = new LibsndfileCommandApiNativeWrapper(mock.Object, marshallerMock.Object);
            var retval = api.GetNormFloat(new IntPtr(1));

            Assert.AreEqual(Convert.ToBoolean(Normalization), retval);
        }
Exemplo n.º 33
0
        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));
        }
Exemplo n.º 34
0
        public void FileTruncate_ShouldThrowExceptionOnGreaterThanZeroResult()
        {
            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            marshallerMock.Setup(x => x.Allocate(It.IsAny <long>())).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.FileTruncate(new IntPtr(1), It.IsAny <long>());
        }
Exemplo n.º 35
0
        public void GetBroadcastInfo_ShouldReturnNullOnZeroResult()
        {
            var unmanagedMemoryMock = new Mock<UnmanagedMemoryHandle>();

            var marshallerMock = new Mock<ILibsndfileMarshaller>();
            marshallerMock.Setup(x => x.Allocate<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.GetBroadcastInfo(new IntPtr(1));

            Assert.IsFalse(retval.HasValue);
        }
Exemplo n.º 36
0
        public void SetUpdateHeaderAuto_ShouldPassOnOneResult()
        {
            const int AutoUpdate = 0;

            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            var mock = new Mock <ILibsndfileApi>();

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

            var api    = new LibsndfileCommandApiNativeWrapper(mock.Object, marshallerMock.Object);
            var retval = api.SetUpdateHeaderAuto(new IntPtr(1), It.IsAny <bool>());

            Assert.AreEqual(Convert.ToBoolean(AutoUpdate), retval);
        }
Exemplo n.º 37
0
        public void SetAmbisonic_ShouldReturnTrueOnModeMatch()
        {
            const int Result = 0x40;

            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            var mock = new Mock <ILibsndfileApi>();

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

            var api    = new LibsndfileCommandApiNativeWrapper(mock.Object, marshallerMock.Object);
            var retval = api.SetAmbisonic(new IntPtr(1), LibsndfileMode.AmbisonicNone);

            Assert.IsTrue(retval);
        }
Exemplo n.º 38
0
        public void GetClipping_ShouldPassOnOneClipping()
        {
            const int Clipping = 1;

            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            var mock = new Mock <ILibsndfileApi>();

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

            var api    = new LibsndfileCommandApiNativeWrapper(mock.Object, marshallerMock.Object);
            var retval = api.GetClipping(new IntPtr(1));

            Assert.AreEqual(Convert.ToBoolean(Clipping), retval);
        }
Exemplo n.º 39
0
        public void SetAddPeakChunk_ShouldPassOnOneResult()
        {
            const int Scaling = 0;

            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            var mock = new Mock <ILibsndfileApi>();

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

            var api    = new LibsndfileCommandApiNativeWrapper(mock.Object, marshallerMock.Object);
            var retval = api.SetAddPeakChunk(new IntPtr(1), It.IsAny <bool>());

            Assert.AreEqual(Convert.ToBoolean(Scaling), retval);
        }
Exemplo n.º 40
0
        public void SetInstrument_ShouldReturnTrueOnOneResult()
        {
            var unmanagedMemoryMock = new Mock<UnmanagedMemoryHandle>();

            var marshallerMock = new Mock<ILibsndfileMarshaller>();
            marshallerMock.Setup(x => x.Allocate(It.IsAny<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);
            var retval = api.SetInstrument(IntPtr.Zero, It.IsAny<LibsndfileInstrumentInfo>());

            Assert.IsTrue(retval);
        }
Exemplo n.º 41
0
        public void SetNormFloat_ShouldPassOnOneNormalization()
        {
            const int Normalization = 1;

            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            var mock = new Mock <ILibsndfileApi>();

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

            var api    = new LibsndfileCommandApiNativeWrapper(mock.Object, marshallerMock.Object);
            var retval = api.SetNormFloat(new IntPtr(1), It.IsAny <bool>());

            Assert.AreEqual(Convert.ToBoolean(Normalization), retval);
        }
Exemplo n.º 42
0
        public void GetAmbisonic_ShouldPassOnAmbisonicBResult()
        {
            const int Result = 0x41;

            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            var mock = new Mock <ILibsndfileApi>();

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

            var api    = new LibsndfileCommandApiNativeWrapper(mock.Object, marshallerMock.Object);
            var retval = api.GetAmbisonic(new IntPtr(1));

            Assert.IsTrue(retval);
        }
Exemplo n.º 43
0
        public void FileTruncate_ShouldPassOnValidResult()
        {
            var marshallerMock = new Mock <ILibsndfileMarshaller>();

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

            Assert.AreEqual(true, retval);
        }
Exemplo n.º 44
0
        public void SetRawStartOffset_ShouldPassOnValidResult()
        {
            const int Result = 0;

            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            marshallerMock.Setup(x => x.Allocate(It.IsAny <long>())).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(Result);

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

            api.SetRawStartOffset(new IntPtr(1), 1);
        }
Exemplo n.º 45
0
        public void SetInstrument_ShouldThrowExceptionOnNegativeResult()
        {
            var unmanagedMemoryMock = new Mock <UnmanagedMemoryHandle>();

            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            marshallerMock.Setup(x => x.Allocate(It.IsAny <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.SetInstrument(IntPtr.Zero, It.IsAny <LibsndfileInstrumentInfo>());
        }
Exemplo n.º 46
0
        public void GetSimpleFormatCount_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.GetSimpleFormatCount();

            Assert.AreEqual(Count, retval);
        }
Exemplo n.º 47
0
        public void SetVbrEncodingQuality_ShouldPassOnZeroResult()
        {
            var unmanagedMemoryMock = new Mock <UnmanagedMemoryHandle>();

            var marshallerMock = new Mock <ILibsndfileMarshaller>();

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

            api.SetVbrEncodingQuality(new IntPtr(1), It.IsAny <double>());
        }
Exemplo n.º 48
0
        public void GetBroadcastInfo_ShouldThrowExceptionOnGreaterThanOneResult()
        {
            var unmanagedMemoryMock = new Mock <UnmanagedMemoryHandle>();

            var marshallerMock = new Mock <ILibsndfileMarshaller>();

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

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

            api.GetBroadcastInfo(new IntPtr(1));
        }
Exemplo n.º 49
0
        public void SetInstrument_ShouldReturnTrueOnOneResult()
        {
            var unmanagedMemoryMock = new Mock <UnmanagedMemoryHandle>();

            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            marshallerMock.Setup(x => x.Allocate(It.IsAny <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);
            var retval = api.SetInstrument(IntPtr.Zero, It.IsAny <LibsndfileInstrumentInfo>());

            Assert.IsTrue(retval);
        }
Exemplo n.º 50
0
        public void GetBroadcastInfo_ShouldReturnNullOnZeroResult()
        {
            var unmanagedMemoryMock = new Mock <UnmanagedMemoryHandle>();

            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            marshallerMock.Setup(x => x.Allocate <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.GetBroadcastInfo(new IntPtr(1));

            Assert.IsFalse(retval.HasValue);
        }
Exemplo n.º 51
0
        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);
        }
Exemplo n.º 52
0
        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);
        }
Exemplo n.º 53
0
        public void GetSignalMax_ShouldPassOnZeroResult()
        {
            const double SignalMax = 1.0;

            var memoryMock = new Mock<UnmanagedMemoryHandle>();

            var marshallerMock = new Mock<ILibsndfileMarshaller>();
            marshallerMock.Setup(x => x.Allocate<double>()).Returns(memoryMock.Object);
            marshallerMock.Setup(x => x.MemoryHandleTo<double>(It.IsAny<UnmanagedMemoryHandle>())).Returns(SignalMax);

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

            Assert.AreEqual(SignalMax, retval);
        }
Exemplo n.º 54
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);
        }
Exemplo n.º 55
0
        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);
        }
Exemplo n.º 56
0
        public void GetMaxAllChannels_ShouldPassOnZeroResult()
        {
            var Result = new[] { 1.0 };

            var memoryMock = new Mock<UnmanagedMemoryHandle>();

            var marshallerMock = new Mock<ILibsndfileMarshaller>();
            marshallerMock.Setup(x => x.AllocateArray<double>(It.IsAny<int>())).Returns(memoryMock.Object);
            marshallerMock.Setup(x => x.MemoryHandleToArray<double>(It.IsAny<UnmanagedMemoryHandle>())).Returns(Result);

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

            Assert.AreEqual(Result, retval);
        }
Exemplo n.º 57
0
        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);
        }
Exemplo n.º 58
0
        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);
        }
Exemplo n.º 59
0
        public void CalcSignalMax_ShouldPassOnZeroResult()
        {
            const double SignalMax = 1.0;

            var memoryMock = new Mock <UnmanagedMemoryHandle>();

            var marshallerMock = new Mock <ILibsndfileMarshaller>();

            marshallerMock.Setup(x => x.Allocate <double>()).Returns(memoryMock.Object);
            marshallerMock.Setup(x => x.MemoryHandleTo <double>(It.IsAny <UnmanagedMemoryHandle>())).Returns(SignalMax);

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

            Assert.AreEqual(SignalMax, retval);
        }
Exemplo n.º 60
0
        public void GetFormatMajor_ShouldPassOnZeroResult()
        {
            var formatInfo = new LibsndfileFormatInfo { Format = LibsndfileFormat.Wav, Name = "Wav", Extension = ".wav" };

            var allocatedFormatInfo = new LibsndfileFormatInfo { Format = LibsndfileFormat.Wav };

            var memoryMock = new Mock<UnmanagedMemoryHandle>();

            var marshallerMock = new Mock<ILibsndfileMarshaller>();
            marshallerMock.Setup(x => x.Allocate(allocatedFormatInfo)).Returns(memoryMock.Object);
            marshallerMock.Setup(x => x.MemoryHandleTo<LibsndfileFormatInfo>(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.GetFormatMajor(LibsndfileFormat.Wav);

            Assert.AreEqual(formatInfo, retval);
        }