Updating tests to use moq.netcore
This commit is contained in:
parent
e2632d47f0
commit
130e8f0398
|
|
@ -8,9 +8,7 @@ using Microsoft.AspNet.Http;
|
|||
using Microsoft.AspNet.Http.Internal;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using Microsoft.Extensions.WebEncoders.Testing;
|
||||
#if DNX451
|
||||
using Moq;
|
||||
#endif
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Antiforgery
|
||||
|
|
@ -149,8 +147,6 @@ namespace Microsoft.AspNet.Antiforgery
|
|||
exception.Message);
|
||||
}
|
||||
|
||||
#if DNX451
|
||||
|
||||
[Fact]
|
||||
public void GetHtml_ExistingInvalidCookieToken_GeneratesANewCookieAndAnAntiforgeryToken()
|
||||
{
|
||||
|
|
@ -496,8 +492,6 @@ namespace Microsoft.AspNet.Antiforgery
|
|||
Assert.Equal(expectedHeaderValue, xFrameOptions);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
private DefaultAntiforgery GetAntiforgery(
|
||||
AntiforgeryOptions options = null,
|
||||
IAntiforgeryTokenGenerator tokenGenerator = null,
|
||||
|
|
@ -525,8 +519,6 @@ namespace Microsoft.AspNet.Antiforgery
|
|||
return httpContext;
|
||||
}
|
||||
|
||||
#if DNX451
|
||||
|
||||
private DefaultAntiforgery GetAntiforgery(AntiforgeryMockContext context)
|
||||
{
|
||||
return GetAntiforgery(
|
||||
|
|
@ -667,8 +659,6 @@ namespace Microsoft.AspNet.Antiforgery
|
|||
public Mock<IAntiforgeryTokenSerializer> TokenSerializer { get; set; }
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
private class TestOptionsManager : IOptions<AntiforgeryOptions>
|
||||
{
|
||||
public AntiforgeryOptions Value { get; set; } = new AntiforgeryOptions();
|
||||
|
|
|
|||
|
|
@ -5,9 +5,7 @@ using System;
|
|||
using System.Security.Claims;
|
||||
using System.Security.Cryptography;
|
||||
using Microsoft.AspNet.Http.Internal;
|
||||
#if DNX451
|
||||
using Moq;
|
||||
#endif
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Antiforgery
|
||||
|
|
@ -54,8 +52,6 @@ namespace Microsoft.AspNet.Antiforgery
|
|||
Assert.Empty(fieldToken.AdditionalData);
|
||||
}
|
||||
|
||||
#if DNX451
|
||||
|
||||
[Fact]
|
||||
public void GenerateFormToken_AuthenticatedWithoutUsernameAndNoAdditionalData_NoAdditionalData()
|
||||
{
|
||||
|
|
@ -191,7 +187,6 @@ namespace Microsoft.AspNet.Antiforgery
|
|||
Assert.Null(fieldToken.ClaimUid);
|
||||
Assert.Empty(fieldToken.AdditionalData);
|
||||
}
|
||||
#endif
|
||||
|
||||
[Fact]
|
||||
public void IsCookieTokenValid_FieldToken_ReturnsFalse()
|
||||
|
|
@ -346,8 +341,6 @@ namespace Microsoft.AspNet.Antiforgery
|
|||
exception.Message);
|
||||
}
|
||||
|
||||
#if DNX451
|
||||
|
||||
[Theory]
|
||||
[InlineData("the-user", "the-other-user")]
|
||||
[InlineData("http://example.com/uri-casing", "http://example.com/URI-casing")]
|
||||
|
|
@ -542,7 +535,6 @@ namespace Microsoft.AspNet.Antiforgery
|
|||
// Assert
|
||||
// Nothing to assert - if we got this far, success!
|
||||
}
|
||||
#endif
|
||||
|
||||
private static ClaimsIdentity GetAuthenticatedIdentity(string identityUsername)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
// 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.
|
||||
|
||||
#if DNX451
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
|
@ -185,5 +184,3 @@ namespace Microsoft.AspNet.Antiforgery
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
// 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.
|
||||
|
||||
#if DNX451
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -446,5 +445,3 @@ namespace Microsoft.AspNet.Antiforgery
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -4,9 +4,7 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
#if DNX451
|
||||
using Moq;
|
||||
#endif
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Antiforgery
|
||||
|
|
@ -26,7 +24,6 @@ namespace Microsoft.AspNet.Antiforgery
|
|||
Assert.Null(claimUid);
|
||||
}
|
||||
|
||||
#if DNX451
|
||||
[Fact]
|
||||
public void ExtractClaimUid_Unauthenticated()
|
||||
{
|
||||
|
|
@ -61,7 +58,6 @@ namespace Microsoft.AspNet.Antiforgery
|
|||
Assert.NotNull(claimUid);
|
||||
Assert.Equal("47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=", claimUid);
|
||||
}
|
||||
#endif
|
||||
|
||||
[Fact]
|
||||
public void DefaultUniqueClaimTypes_NotPresent_SerializesAllClaimTypes()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
// 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;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
|
||||
namespace Microsoft.AspNet.Antiforgery
|
||||
|
|
|
|||
|
|
@ -1,24 +1,28 @@
|
|||
{
|
||||
"compilationOptions": {
|
||||
"warningsAsErrors": true,
|
||||
"keyFile": "../../tools/Key.snk"
|
||||
"compilationOptions": {
|
||||
"warningsAsErrors": true,
|
||||
"keyFile": "../../tools/Key.snk"
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.Antiforgery": "1.0.0-*",
|
||||
"Microsoft.AspNet.Http": "1.0.0-*",
|
||||
"Microsoft.Extensions.DependencyInjection": "1.0.0-*",
|
||||
"xunit.runner.aspnet": "2.0.0-aspnet-*"
|
||||
},
|
||||
"commands": {
|
||||
"run": "xunit.runner.aspnet",
|
||||
"test": "xunit.runner.aspnet"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": {
|
||||
"dependencies": {
|
||||
"Moq": "4.2.1312.1622"
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.Antiforgery": "1.0.0-*",
|
||||
"Microsoft.AspNet.Http": "1.0.0-*",
|
||||
"Microsoft.Extensions.DependencyInjection": "1.0.0-*",
|
||||
"xunit.runner.aspnet": "2.0.0-aspnet-*"
|
||||
},
|
||||
"commands": {
|
||||
"run": "xunit.runner.aspnet",
|
||||
"test": "xunit.runner.aspnet"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": {
|
||||
"dependencies": {
|
||||
"Moq": "4.2.1312.1622"
|
||||
}
|
||||
},
|
||||
"dnxcore50": { }
|
||||
"dnxcore50": {
|
||||
"dependencies": {
|
||||
"moq.netcore": "4.4.0-beta8"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue