Beispiel #1
0
        public async Task TestWriter_getContentAsync()
        {
            LongAdder       byteCount = new LongAdder();
            BlobHttpContent body      = testBlobPusher.CreateWriter(mockURL, byteCount.Add).GetContent();

            Assert.IsNotNull(body);
            Assert.AreEqual("application/octet-stream", body.Headers.ContentType.MediaType);

            using (MemoryStream byteArrayOutputStream = new MemoryStream())
            {
                await body.CopyToAsync(byteArrayOutputStream).ConfigureAwait(false);

                Assert.AreEqual(
                    TEST_BLOB_CONTENT, Encoding.UTF8.GetString(byteArrayOutputStream.ToArray()));
                Assert.AreEqual(TEST_BLOB_CONTENT.Length, byteCount.Sum());
            }
        }
        public async Task TestGetContentAsync()
        {
            BlobHttpContent body = testManifestPusher.GetContent();

            Assert.IsNotNull(body);
            Assert.AreEqual(V22ManifestTemplate.ManifestMediaType, body.Headers.ContentType.MediaType);

            using (MemoryStream bodyCaptureStream = new MemoryStream())
            {
                await body.CopyToAsync(bodyCaptureStream).ConfigureAwait(false);

                string v22manifestJson =
                    Encoding.UTF8.GetString(Files.ReadAllBytes(v22manifestJsonFile));
                Assert.AreEqual(
                    v22manifestJson, Encoding.UTF8.GetString(bodyCaptureStream.ToArray()));
            }
        }