Ejemplo n.º 1
0
        // Async save with bytes[] provider test
        private async Task TestSaveBufferProviderAsync()
        {
            var tempFile = await File.CreateTemporaryFileAsync();

            byte[] buffer = new byte[] { 5, 4, 3, 2, 1 };

            var provider = new SaveProviderMock<byte[]>(tempFile, buffer);

            await File.SaveAsync(provider);

            var reader = DataReader.FromBuffer(await FileIO.ReadBufferAsync(tempFile));
            byte[] read = new byte[5];
            reader.ReadBytes(read);

            for (int i = 0; i < buffer.Length; i++)
            {
                Assert.AreEqual(buffer[i], read[i]);
            }
        }
Ejemplo n.º 2
0
        // Async save with string provider test
        private async Task TestSaveStringProviderAsync()
        {
            var tempFile = await File.CreateTemporaryFileAsync();

            string content = "Content";

            var provider = new SaveProviderMock<string>(tempFile, content);

            await File.SaveAsync(provider);

            string read = await FileIO.ReadTextAsync(tempFile);

            Assert.AreEqual(content, read);
        }