// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; using System.Net; using System.Net.Http; using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Xunit; namespace Microsoft.AspNet.Mvc.FunctionalTests { public class TempDataTest { private const string SiteName = nameof(TempDataWebSite); private readonly Action _app = new TempDataWebSite.Startup().Configure; [Fact] public async Task ViewRendersTempData() { // Arrange var server = TestHelper.CreateServer(_app, SiteName); var client = server.CreateClient(); var nameValueCollection = new List> { new KeyValuePair("value", "Foo"), }; var content = new FormUrlEncodedContent(nameValueCollection); // Act var response = await client.PostAsync("http://localhost/Home/DisplayTempData", content); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); var body = await response.Content.ReadAsStringAsync(); Assert.Equal("Foo", body); } } }