Esempio n. 1
0
        public async Task Read_Stream_EqualsTrue()
        {
            MS2SizeHeader expectedHeader    = new MS2SizeHeader(1, 2, 3);
            MS2SizeHeader expectedData      = new MS2SizeHeader(4, 5, 6);
            long          expectedFileCount = 7;

            using var ms = new MemoryStream();
            using var bw = new BinaryWriter(ms);
            bw.Write(0u);
            bw.Write(expectedData.CompressedSize);
            bw.Write(expectedData.EncodedSize);
            bw.Write(expectedHeader.Size);
            bw.Write(expectedHeader.CompressedSize);
            bw.Write(expectedHeader.EncodedSize);
            bw.Write(expectedFileCount);
            bw.Write(expectedData.Size);
            ms.Position = 0;

            var obj = new MS2ArchiveHeaderMS2F();

            var(actualFileInfoSize, actualFileDataSize, actualFileCount) = await obj.ReadAsync(ms);

            Assert.AreEqual(expectedHeader, actualFileInfoSize);
            Assert.AreEqual(expectedData, actualFileDataSize);
            Assert.AreEqual(expectedFileCount, actualFileCount);
        }
Esempio n. 2
0
        public async Task Write_FromRead_EqualsTrue()
        {
            byte[] bytes = Enumerable.Range(0, 100).SelectMany(i => BitConverter.GetBytes(i)).ToArray();
            using var ms = new MemoryStream(bytes);

            var obj = new MS2ArchiveHeaderMS2F();

            var(expectedHeader, expectedData, expectedFileCount) = await obj.ReadAsync(ms);

            ms.Position = 0;

            await obj.WriteAsync(ms, expectedHeader, expectedData, expectedFileCount);

            ms.Position = 0;

            var(actualFileInfoSize, actualFileDataSize, actualFileCount) = await obj.ReadAsync(ms);

            Assert.AreEqual(expectedHeader, actualFileInfoSize);
            Assert.AreEqual(expectedData, actualFileDataSize);
            Assert.AreEqual(expectedFileCount, actualFileCount);
        }
Esempio n. 3
0
        public async Task Read_FromWrite_EqualsTrue()
        {
            MS2SizeHeader expectedHeader    = new MS2SizeHeader(1, 2, 3);
            MS2SizeHeader expectedData      = new MS2SizeHeader(4, 5, 6);
            long          expectedFileCount = 7;
            var           obj = new MS2ArchiveHeaderMS2F();

            using var ms = new MemoryStream();
            await obj.WriteAsync(ms, expectedHeader, expectedData, expectedFileCount);

            ms.Position = 0;

            var(actualFileInfoSize, actualFileDataSize, actualFileCount) = await obj.ReadAsync(ms);

            Assert.AreEqual(expectedHeader, actualFileInfoSize);
            Assert.AreEqual(expectedData, actualFileDataSize);
            Assert.AreEqual(expectedFileCount, actualFileCount);
        }