Ejemplo n.º 1
0
        public async Task ReadNextPair_ReturnsNullOnEmptyStream(bool bufferRequest)
        {
            var body = MakeStream(bufferRequest, "");

            var reader = new FormReader(body);

            Assert.Null(await ReadPair(reader));
        }
Ejemplo n.º 2
0
        public async Task ReadSmallFormAsyncStream()
        {
            var bytes  = Encoding.UTF8.GetBytes("foo=bar&baz=boo");
            var stream = new MemoryStream(bytes);

            for (var i = 0; i < 1000; i++)
            {
                var formReader = new FormReader(stream);
                await formReader.ReadFormAsync();

                stream.Position = 0;
            }
        }
Ejemplo n.º 3
0
        public async Task ReadNextPair_ReadsAllPairs(bool bufferRequest)
        {
            var body = MakeStream(bufferRequest, "foo=&baz=2");

            var reader = new FormReader(body);

            var pair = (KeyValuePair <string, string>) await ReadPair(reader);

            Assert.Equal("foo", pair.Key);
            Assert.Equal("", pair.Value);

            pair = (KeyValuePair <string, string>) await ReadPair(reader);

            Assert.Equal("baz", pair.Key);
            Assert.Equal("2", pair.Value);

            Assert.Null(await ReadPair(reader));
        }
Ejemplo n.º 4
0
 protected override async Task <KeyValuePair <string, string>?> ReadPair(FormReader reader) => await reader.ReadNextPairAsync();
Ejemplo n.º 5
0
 protected override async Task <Dictionary <string, StringValues> > ReadFormAsync(FormReader reader) => await reader.ReadFormAsync();
Ejemplo n.º 6
0
 protected virtual Task <KeyValuePair <string, string>?> ReadPair(FormReader reader) => Task.FromResult(reader.ReadNextPair());
Ejemplo n.º 7
0
 protected virtual Task <Dictionary <string, StringValues> > ReadFormAsync(FormReader reader) => Task.FromResult(reader.ReadForm());