From dd774366f6fb18af9382ca84c276e6eb73c66b3a Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Thu, 3 Dec 2015 13:59:34 -0800 Subject: [PATCH] Addressed feedback --- .../TempDataTest.cs | 19 ------------------- .../Controllers/TempDataController.cs | 19 ------------------- test/WebSites/BasicWebSite/Startup.cs | 4 +++- 3 files changed, 3 insertions(+), 39 deletions(-) diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/TempDataTest.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/TempDataTest.cs index 0199f60993..69d854f752 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/TempDataTest.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/TempDataTest.cs @@ -173,25 +173,6 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests Assert.Equal($"Foo 10 3 10/10/2010 00:00:00 {testGuid.ToString()}", body); } - [Fact] - public async Task TempData_InvalidType_Throws() - { - // Arrange - var nameValueCollection = new List> - { - new KeyValuePair("value", "Foo"), - }; - var content = new FormUrlEncodedContent(nameValueCollection); - - // Act & Assert - var exception = await Assert.ThrowsAsync(async () => - { - await Client.PostAsync("/TempData/SetTempDataInvalidType", content); - }); - Assert.Equal("The '" + typeof(SessionStateTempDataProvider).FullName + "' cannot serialize an object of type '" + - typeof(BasicWebSite.Controllers.TempDataController.NonSerializableType).FullName + "' to session state.", exception.Message); - } - private HttpRequestMessage GetRequest(string path, HttpResponseMessage response) { var request = new HttpRequestMessage(HttpMethod.Get, path); diff --git a/test/WebSites/BasicWebSite/Controllers/TempDataController.cs b/test/WebSites/BasicWebSite/Controllers/TempDataController.cs index 68b1659067..23699ae781 100644 --- a/test/WebSites/BasicWebSite/Controllers/TempDataController.cs +++ b/test/WebSites/BasicWebSite/Controllers/TempDataController.cs @@ -68,24 +68,5 @@ namespace BasicWebSite.Controllers var value5 = (Guid)TempData["key5"]; return $"{value1} {value2.ToString()} {value3.Count.ToString()} {value4.ToString()} {value5.ToString()}"; } - - public string SetTempDataInvalidType() - { - var exception = ""; - try - { - TempData["key"] = new NonSerializableType(); - } - catch (Exception e) - { - exception = e.Message; - } - - return exception; - } - - public class NonSerializableType - { - } } } diff --git a/test/WebSites/BasicWebSite/Startup.cs b/test/WebSites/BasicWebSite/Startup.cs index 3ddcafecee..bb7c295b9f 100644 --- a/test/WebSites/BasicWebSite/Startup.cs +++ b/test/WebSites/BasicWebSite/Startup.cs @@ -2,6 +2,8 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Http; +using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.Mvc.Abstractions; using Microsoft.Extensions.DependencyInjection; @@ -18,7 +20,7 @@ namespace BasicWebSite }); services.AddLogging(); services.AddSingleton(); - + services.AddSingleton(); services.AddScoped(); services.AddCaching(); services.AddSession();