Exemplo n.º 1
0
        public void SerializeJsonIntoStream_LeavesStreamIntactWhenContentIsNull()
        {
            HttpClient     httpClient     = new HttpClient();
            HttpClientBase httpClientBase = new HttpClientBase(httpClient, loggerMock.Object);

            using (MemoryStream ms = new MemoryStream())
            {
                httpClientBase.SerializeJsonIntoStream(null, ms);

                ms.Should().NotBeNull();

                ms.Length.Should().Be(0);
            }
        }
Exemplo n.º 2
0
        public void SerializeJsonIntoStream_FillsInStreamWithData()
        {
            HttpClient     httpClient     = new HttpClient();
            HttpClientBase httpClientBase = new HttpClientBase(httpClient, loggerMock.Object);

            using (MemoryStream ms = new MemoryStream())
            {
                httpClientBase.SerializeJsonIntoStream("value", ms); // stream actually contains "value"

                ms.Should().NotBeNull();

                var msValue = System.Text.Encoding.UTF8.GetString(ms.ToArray());
                msValue.Should().Be("\"value\"");
            }
        }