diff options
author | crupest <crupest@outlook.com> | 2020-01-18 00:50:31 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-01-18 00:50:31 +0800 |
commit | c5f3c69b3a008ab87542e523e2a59f37801bd65a (patch) | |
tree | 8479cc9af91a7e7b1c0c60a0abc778244359bdbd /Timeline.Tests | |
parent | 289c7e1fada1f4dae6ce5e421e997ebddd55c2df (diff) | |
download | timeline-c5f3c69b3a008ab87542e523e2a59f37801bd65a.tar.gz timeline-c5f3c69b3a008ab87542e523e2a59f37801bd65a.tar.bz2 timeline-c5f3c69b3a008ab87542e523e2a59f37801bd65a.zip |
...
Diffstat (limited to 'Timeline.Tests')
-rw-r--r-- | Timeline.Tests/Controllers/TokenControllerTest.cs | 4 | ||||
-rw-r--r-- | Timeline.Tests/Controllers/UserControllerTest.cs | 13 |
2 files changed, 9 insertions, 8 deletions
diff --git a/Timeline.Tests/Controllers/TokenControllerTest.cs b/Timeline.Tests/Controllers/TokenControllerTest.cs index 238fc237..371884bb 100644 --- a/Timeline.Tests/Controllers/TokenControllerTest.cs +++ b/Timeline.Tests/Controllers/TokenControllerTest.cs @@ -10,7 +10,7 @@ using Timeline.Models.Http; using Timeline.Services;
using Timeline.Tests.Helpers;
using Xunit;
-using static Timeline.ErrorCodes.Http.Token;
+using static Timeline.ErrorCodes.Token;
namespace Timeline.Tests.Controllers
{
@@ -98,7 +98,7 @@ namespace Timeline.Tests.Controllers public static IEnumerable<object[]> Verify_BadRequest_Data()
{
- yield return new object[] { new JwtVerifyException(JwtVerifyException.ErrorCodes.Expired), Verify.Expired };
+ yield return new object[] { new JwtVerifyException(JwtVerifyException.ErrorCodes.Expired), Verify.TimeExpired };
yield return new object[] { new JwtVerifyException(JwtVerifyException.ErrorCodes.IdClaimBadFormat), Verify.BadFormat };
yield return new object[] { new JwtVerifyException(JwtVerifyException.ErrorCodes.OldVersion), Verify.OldVersion };
yield return new object[] { new UserNotExistException(), Verify.UserNotExist };
diff --git a/Timeline.Tests/Controllers/UserControllerTest.cs b/Timeline.Tests/Controllers/UserControllerTest.cs index a5ca7a2b..7a6541fb 100644 --- a/Timeline.Tests/Controllers/UserControllerTest.cs +++ b/Timeline.Tests/Controllers/UserControllerTest.cs @@ -13,7 +13,8 @@ using Timeline.Models.Http; using Timeline.Services;
using Timeline.Tests.Helpers;
using Xunit;
-using static Timeline.ErrorCodes.Http.User;
+using static Timeline.ErrorCodes.User;
+using static Timeline.ErrorCodes.UserCommon;
namespace Timeline.Tests.Controllers
{
@@ -61,7 +62,7 @@ namespace Timeline.Tests.Controllers var action = await _controller.Get(username);
action.Result.Should().BeAssignableTo<NotFoundObjectResult>()
.Which.Value.Should().BeAssignableTo<CommonResponse>()
- .Which.Code.Should().Be(Get.NotExist);
+ .Which.Code.Should().Be(UserNotExist);
}
[Theory]
@@ -114,7 +115,7 @@ namespace Timeline.Tests.Controllers }, username);
action.Should().BeAssignableTo<NotFoundObjectResult>()
.Which.Value.Should().BeAssignableTo<CommonResponse>()
- .Which.Code.Should().Be(Patch.NotExist);
+ .Which.Code.Should().Be(UserNotExist);
}
[Fact]
@@ -154,8 +155,8 @@ namespace Timeline.Tests.Controllers }
[Theory]
- [InlineData(typeof(UserNotExistException), Op.ChangeUsername.NotExist)]
- [InlineData(typeof(UsernameConfictException), Op.ChangeUsername.AlreadyExist)]
+ [InlineData(typeof(UserNotExistException), UserNotExist)]
+ [InlineData(typeof(UsernameConfictException), ChangeUsername_Conflict)]
public async Task Op_ChangeUsername_Failure(Type exceptionType, int code)
{
const string oldUsername = "aaa";
@@ -212,7 +213,7 @@ namespace Timeline.Tests.Controllers var action = await _controller.ChangePassword(new ChangePasswordRequest { OldPassword = oldPassword, NewPassword = newPassword });
action.Should().BeAssignableTo<BadRequestObjectResult>()
.Which.Value.Should().BeAssignableTo<CommonResponse>()
- .Which.Code.Should().Be(Op.ChangePassword.BadOldPassword);
+ .Which.Code.Should().Be(ChangePassword_BadOldPassword);
}
}
}
|