Reacting to HttpAbstractions' StringValues change
This commit is contained in:
parent
0972116697
commit
aa3795de86
|
|
@ -4,6 +4,7 @@ using Microsoft.AspNet.Http;
|
||||||
using Microsoft.AspNet.Http.Features;
|
using Microsoft.AspNet.Http.Features;
|
||||||
using Microsoft.AspNet.Http.Features.Internal;
|
using Microsoft.AspNet.Http.Features.Internal;
|
||||||
using Microsoft.AspNet.Http.Internal;
|
using Microsoft.AspNet.Http.Internal;
|
||||||
|
using Microsoft.Framework.Primitives;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace MusicStore.Models
|
namespace MusicStore.Models
|
||||||
|
|
@ -35,7 +36,7 @@ namespace MusicStore.Models
|
||||||
|
|
||||||
public CookiesFeature(string key, string value)
|
public CookiesFeature(string key, string value)
|
||||||
{
|
{
|
||||||
_cookies = new ReadableStringCollection(new Dictionary<string, string[]>()
|
_cookies = new ReadableStringCollection(new Dictionary<string, StringValues>()
|
||||||
{
|
{
|
||||||
{ key, new[] { value } }
|
{ key, new[] { value } }
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,11 @@ using System.Security.Claims;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Http;
|
using Microsoft.AspNet.Http;
|
||||||
using Microsoft.AspNet.Http.Features;
|
|
||||||
using Microsoft.AspNet.Http.Internal;
|
using Microsoft.AspNet.Http.Internal;
|
||||||
using Microsoft.AspNet.Mvc;
|
using Microsoft.AspNet.Mvc;
|
||||||
using Microsoft.Data.Entity;
|
using Microsoft.Data.Entity;
|
||||||
using Microsoft.Framework.DependencyInjection;
|
using Microsoft.Framework.DependencyInjection;
|
||||||
|
using Microsoft.Framework.Primitives;
|
||||||
using MusicStore.Models;
|
using MusicStore.Models;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
|
|
@ -64,14 +64,14 @@ namespace MusicStore.Controllers
|
||||||
// FormCollection initialization
|
// FormCollection initialization
|
||||||
httpContext.Request.Form =
|
httpContext.Request.Form =
|
||||||
new FormCollection(
|
new FormCollection(
|
||||||
new Dictionary<string, string[]>()
|
new Dictionary<string, StringValues>()
|
||||||
{ { "PromoCode", new string[] { "FREE" } } }
|
{ { "PromoCode", new[] { "FREE" } } }
|
||||||
);
|
);
|
||||||
|
|
||||||
// UserName initialization
|
// UserName initialization
|
||||||
var claims = new List<Claim> { new Claim(ClaimTypes.Name, "TestUserName") };
|
var claims = new List<Claim> { new Claim(ClaimTypes.Name, "TestUserName") };
|
||||||
httpContext.User = new ClaimsPrincipal(new ClaimsIdentity(claims));
|
httpContext.User = new ClaimsPrincipal(new ClaimsIdentity(claims));
|
||||||
|
|
||||||
// DbContext initialization
|
// DbContext initialization
|
||||||
var dbContext = _serviceProvider.GetRequiredService<MusicStoreContext>();
|
var dbContext = _serviceProvider.GetRequiredService<MusicStoreContext>();
|
||||||
var cartItems = CreateTestCartItems(
|
var cartItems = CreateTestCartItems(
|
||||||
|
|
@ -87,7 +87,7 @@ namespace MusicStore.Controllers
|
||||||
DbContext = dbContext,
|
DbContext = dbContext,
|
||||||
};
|
};
|
||||||
controller.ActionContext.HttpContext = httpContext;
|
controller.ActionContext.HttpContext = httpContext;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = await controller.AddressAndPayment(order, CancellationToken.None);
|
var result = await controller.AddressAndPayment(order, CancellationToken.None);
|
||||||
|
|
||||||
|
|
@ -108,7 +108,7 @@ namespace MusicStore.Controllers
|
||||||
|
|
||||||
// AddressAndPayment action reads the Promo code from FormCollection.
|
// AddressAndPayment action reads the Promo code from FormCollection.
|
||||||
context.Request.Form =
|
context.Request.Form =
|
||||||
new FormCollection(new Dictionary<string, string[]>());
|
new FormCollection(new Dictionary<string, StringValues>());
|
||||||
|
|
||||||
var controller = new CheckoutController();
|
var controller = new CheckoutController();
|
||||||
controller.ActionContext.HttpContext = context;
|
controller.ActionContext.HttpContext = context;
|
||||||
|
|
@ -133,7 +133,7 @@ namespace MusicStore.Controllers
|
||||||
// Arrange
|
// Arrange
|
||||||
var context = new DefaultHttpContext();
|
var context = new DefaultHttpContext();
|
||||||
context.Request.Form =
|
context.Request.Form =
|
||||||
new FormCollection(new Dictionary<string, string[]>());
|
new FormCollection(new Dictionary<string, StringValues>());
|
||||||
|
|
||||||
var controller = new CheckoutController();
|
var controller = new CheckoutController();
|
||||||
controller.ActionContext.HttpContext = context;
|
controller.ActionContext.HttpContext = context;
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ using Microsoft.AspNet.Http.Internal;
|
||||||
using Microsoft.AspNet.Mvc;
|
using Microsoft.AspNet.Mvc;
|
||||||
using Microsoft.Data.Entity;
|
using Microsoft.Data.Entity;
|
||||||
using Microsoft.Framework.DependencyInjection;
|
using Microsoft.Framework.DependencyInjection;
|
||||||
|
using Microsoft.Framework.Primitives;
|
||||||
using MusicStore.Models;
|
using MusicStore.Models;
|
||||||
using MusicStore.ViewModels;
|
using MusicStore.ViewModels;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
@ -189,7 +190,7 @@ namespace MusicStore.Controllers
|
||||||
var tokens = antiForgery.GetTokens(httpContext);
|
var tokens = antiForgery.GetTokens(httpContext);
|
||||||
|
|
||||||
// Header initialization for AntiForgery
|
// Header initialization for AntiForgery
|
||||||
var headers = new KeyValuePair<string, string[]>(
|
var headers = new KeyValuePair<string, StringValues>(
|
||||||
"RequestVerificationToken",
|
"RequestVerificationToken",
|
||||||
new string[] { tokens.CookieToken + ":" + tokens.FormToken });
|
new string[] { tokens.CookieToken + ":" + tokens.FormToken });
|
||||||
httpContext.Request.Headers.Add(headers);
|
httpContext.Request.Headers.Add(headers);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue