public async Task Can_Write_the_spec_sample()
        {
            // Arrange
            var sample = TestHelper.SPEC_SAMPLE_JSON;
            var sampleDoc = SirenJson.Parse(sample);
            var content = new StringContent("42");
            var contentStream = new MemoryStream();
            var nonDisposeContentStream = new NonDisposableStream(contentStream);

            // Act
            await Formatter.WriteToStreamAsync(typeof(ISirenEntity), sampleDoc, nonDisposeContentStream, content, null);
            contentStream.Seek(0, SeekOrigin.Begin);
            string contentString;
            using (var rdr = new StreamReader(contentStream))
            {
                contentString = rdr.ReadToEnd();
            }
            var restoredSample = SirenJson.Parse(contentString);

            // Assert
            TestHelper.AssertIsSpecSample(restoredSample);
        }
Beispiel #2
0
        public async Task Can_Write_the_spec_sample()
        {
            // Arrange
            var sample                  = TestHelper.SPEC_SAMPLE_JSON;
            var sampleDoc               = SirenJson.Parse(sample);
            var content                 = new StringContent("42");
            var contentStream           = new MemoryStream();
            var nonDisposeContentStream = new NonDisposableStream(contentStream);

            // Act
            await Formatter.WriteToStreamAsync(typeof(ISirenEntity), sampleDoc, nonDisposeContentStream, content, null);

            contentStream.Seek(0, SeekOrigin.Begin);
            string contentString;

            using (var rdr = new StreamReader(contentStream))
            {
                contentString = rdr.ReadToEnd();
            }
            var restoredSample = SirenJson.Parse(contentString);

            // Assert
            TestHelper.AssertIsSpecSample(restoredSample);
        }