Пример #1
0
        public async Task GetBody_Post_ReturnsSecretMethodUrl()
        {
            //Arrange
            var context = new DefaultHttpContext();
            var request = new DefaultHttpRequest(context)
            {
                Method = "POST",
                Path   = new PathString("/api/test")
            };

            request.Headers.Add(_nonceHeader, _nonceValue);

            request.Body = new MemoryStream();
            await using var bodyWriter = new StreamWriter(request.Body);
            bodyWriter.Write(Body);
            bodyWriter.Flush();
            request.Body.Position = 0;

            //Act
            var result = await request.GetBodyAsync();

            //Assert
            Assert.Equal(0, request.Body.Position);
            Assert.Equal(Body, result);
        }
Пример #2
0
        public async Task GetBody_Get_ReturnsSecretMethodUrl()
        {
            //Arrange
            var context = new DefaultHttpContext();
            var request = new DefaultHttpRequest(context)
            {
                Method = "GET",
                Path   = new PathString("/api/test")
            };

            request.Headers.Add(_nonceHeader, _nonceValue);

            //Act
            var result = await request.GetBodyAsync();

            //Assert
            Assert.Equal(string.Empty, result);
        }