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);
        }
        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);
        }
        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));
        }
Exemple #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>());
        }
        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();
        }
        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));
        }
        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 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);
        }
        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>());
        }
        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));
        }
Exemple #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>());
        }
Exemple #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>());
        }
        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);
        }
        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);
        }
        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>());
        }
        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);
        }
        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>());
        }
        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));
        }
        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);
        }
        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>());
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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>());
        }
Exemple #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);
        }
        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);
        }
Exemple #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));
        }
Exemple #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);
        }
        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));
        }
        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);
        }
        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();
        }
Exemple #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);
        }
Exemple #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));
        }
Exemple #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>());
        }
        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);
        }
        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);
        }
        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);
        }
        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);
        }
        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);
        }
        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);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
        }
        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>());
        }
        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);
        }
Exemple #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>());
        }
        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));
        }
        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);
        }
        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);
        }
        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 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 #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);
        }
Exemple #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);
        }
        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 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);
        }
        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 #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);
        }
        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);
        }
        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);
        }