From e1e7e298e28a3222ede15beaaa4a99d0f1e3d71e Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Tue, 8 Sep 2015 12:25:18 -0700 Subject: [PATCH] Add micro `FormReader` stress test. --- .../SmokeTest.cs | 32 +++++++++++++++++++ .../project.json | 3 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/test/Microsoft.AspNet.Stress.Tests/SmokeTest.cs b/test/Microsoft.AspNet.Stress.Tests/SmokeTest.cs index e921e1a..484eb5e 100644 --- a/test/Microsoft.AspNet.Stress.Tests/SmokeTest.cs +++ b/test/Microsoft.AspNet.Stress.Tests/SmokeTest.cs @@ -1,7 +1,12 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; using Microsoft.AspNet.StressFramework; +using Microsoft.AspNet.WebUtilities; using Xunit; namespace Microsoft.AspNet.Stress.Tests @@ -13,5 +18,32 @@ namespace Microsoft.AspNet.Stress.Tests { Assert.True(true); } + + [StressTest] + public async Task SmokeyHttpAbstractionsSmokeTest() + { + // Arrange + var formData = "first=second&third=fourth&fifth=sixth"; + var formReader = new FormReader(formData); + var pairs = new List>(); + var cancellationToken = new CancellationToken(); + var expectedPairs = new Dictionary + { + { "first", "second" }, + { "third", "fourth" }, + { "fifth", "sixth" }, + }.ToList(); + + // Act + var pair = await formReader.ReadNextPairAsync(cancellationToken); + while (pair != null) + { + pairs.Add(pair.Value); + pair = await formReader.ReadNextPairAsync(cancellationToken); + } + + // Assert + Assert.Equal(expectedPairs, pairs); + } } } diff --git a/test/Microsoft.AspNet.Stress.Tests/project.json b/test/Microsoft.AspNet.Stress.Tests/project.json index 79c7ab6..3eb527a 100644 --- a/test/Microsoft.AspNet.Stress.Tests/project.json +++ b/test/Microsoft.AspNet.Stress.Tests/project.json @@ -4,7 +4,8 @@ "test": "xunit.runner.aspnet" }, "dependencies": { - "Microsoft.AspNet.StressFramework": "" + "Microsoft.AspNet.StressFramework": "", + "Microsoft.AspNet.WebUtilities": "1.0.0-*" }, "frameworks": { "dnx451": { },