コード例 #1
0
        public async Task WhenValidCreateCatalogFileRequest_ThenReturnTrueReponse()
        {
            byte[] byteContent = new byte[100];
            var    salesCatalogueDataResponse    = GetSalesCatalogueDataResponse();
            var    salesCatalogueProductResponse = GetSalesCatalogueProductResponse();
            var    fulfilmentDataResponse        = new List <FulfilmentDataResponse>()
            {
                new FulfilmentDataResponse {
                    BatchId = "63d38bde-5191-4a59-82d5-aa22ca1cc6dc", EditionNumber = 10, ProductName = "10000002", UpdateNumber = 3, FileUri = new List <string> {
                        "http://ffs-demo.azurewebsites.net"
                    }, Files = GetFiles()
                },
                new FulfilmentDataResponse {
                    BatchId = "63d38bde-5191-4a59-82d5-aa22ca1cc6dc", EditionNumber = 10, ProductName = "10000003", UpdateNumber = 3, FileUri = new List <string> {
                        "http://ffs-demo.azurewebsites.net"
                    }, Files = GetFiles()
                }
            };

            fakeFileHelper.CheckAndCreateFolder(fakeExchangeSetRootPath);
            fakeFileHelper.CreateFileContentWithBytes(fakeFileName, byteContent);

            A.CallTo(() => fakeFileSystemHelper.CheckFileExists(A <string> .Ignored)).Returns(true);
            A.CallTo(() => fakeFileSystemHelper.ReadAllBytes(A <string> .Ignored)).Returns(byteContent);

            var response = await fulfilmentAncillaryFiles.CreateCatalogFile(fakeBatchId, fakeExchangeSetRootPath, null, fulfilmentDataResponse, salesCatalogueDataResponse, salesCatalogueProductResponse);

            Assert.AreEqual(true, response);
            Assert.AreEqual(true, fakeFileHelper.CheckAndCreateFolderIsCalled);
            Assert.AreEqual(true, fakeFileHelper.CreateFileContentWithBytesIsCalled);
            Assert.AreEqual(byteContent, fakeFileHelper.ReadAllBytes(fakeFileName));
        }
コード例 #2
0
        public IFrameData ProcessFile()
        {
            var bytes  = _fileSystemHelper.ReadAllBytes(_path);
            var frames = bytes.Length / 4;

            var left  = new float[frames];
            var right = new float[frames];

            var j = 0;

            for (var i = 0; i < bytes.Length; i += 4)
            {
                var l = BitConverter.ToInt16(bytes, i);
                left[j] = l / 32768f;

                var r = BitConverter.ToInt16(bytes, i + 2);
                right[j] = r / 32768f;

                ++j;
            }

            return(new FrameData(left, right));
        }
コード例 #3
0
        private string GetCrcString(string fullFilePath)
        {
            var crcHash = Crc32CheckSumProvider.Instance.Compute(fileSystemHelper.ReadAllBytes(fullFilePath));

            return(crcHash.ToString("X").PadLeft(crcLength, '0'));
        }