Addressed feedback
This commit is contained in:
parent
6712f9d9ff
commit
dd774366f6
|
|
@ -173,25 +173,6 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||||
Assert.Equal($"Foo 10 3 10/10/2010 00:00:00 {testGuid.ToString()}", body);
|
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<KeyValuePair<string, string>>
|
|
||||||
{
|
|
||||||
new KeyValuePair<string, string>("value", "Foo"),
|
|
||||||
};
|
|
||||||
var content = new FormUrlEncodedContent(nameValueCollection);
|
|
||||||
|
|
||||||
// Act & Assert
|
|
||||||
var exception = await Assert.ThrowsAsync<InvalidOperationException>(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)
|
private HttpRequestMessage GetRequest(string path, HttpResponseMessage response)
|
||||||
{
|
{
|
||||||
var request = new HttpRequestMessage(HttpMethod.Get, path);
|
var request = new HttpRequestMessage(HttpMethod.Get, path);
|
||||||
|
|
|
||||||
|
|
@ -68,24 +68,5 @@ namespace BasicWebSite.Controllers
|
||||||
var value5 = (Guid)TempData["key5"];
|
var value5 = (Guid)TempData["key5"];
|
||||||
return $"{value1} {value2.ToString()} {value3.Count.ToString()} {value4.ToString()} {value5.ToString()}";
|
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
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// 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.Builder;
|
||||||
|
using Microsoft.AspNet.Http;
|
||||||
|
using Microsoft.AspNet.Http.Internal;
|
||||||
using Microsoft.AspNet.Mvc.Abstractions;
|
using Microsoft.AspNet.Mvc.Abstractions;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
|
@ -18,7 +20,7 @@ namespace BasicWebSite
|
||||||
});
|
});
|
||||||
services.AddLogging();
|
services.AddLogging();
|
||||||
services.AddSingleton<IActionDescriptorProvider, ActionDescriptorCreationCounter>();
|
services.AddSingleton<IActionDescriptorProvider, ActionDescriptorCreationCounter>();
|
||||||
|
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||||
services.AddScoped<RequestIdService>();
|
services.AddScoped<RequestIdService>();
|
||||||
services.AddCaching();
|
services.AddCaching();
|
||||||
services.AddSession();
|
services.AddSession();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue