aboutsummaryrefslogtreecommitdiff
path: root/Timeline.Tests/IntegratedTests/UserDetailTest.cs
diff options
context:
space:
mode:
author杨宇千 <crupest@outlook.com>2019-08-22 15:06:15 +0800
committer杨宇千 <crupest@outlook.com>2019-08-22 15:06:15 +0800
commit56ce7def278aef513204f6b4817f3de63d58cf60 (patch)
treec04c6d10452389cd88387e1076c08002bbd60414 /Timeline.Tests/IntegratedTests/UserDetailTest.cs
parent2541f11b5d637d47b39f25cc03dc4173a6b7efe6 (diff)
downloadtimeline-56ce7def278aef513204f6b4817f3de63d58cf60.tar.gz
timeline-56ce7def278aef513204f6b4817f3de63d58cf60.tar.bz2
timeline-56ce7def278aef513204f6b4817f3de63d58cf60.zip
Add nickname in detail controller.
Diffstat (limited to 'Timeline.Tests/IntegratedTests/UserDetailTest.cs')
-rw-r--r--Timeline.Tests/IntegratedTests/UserDetailTest.cs33
1 files changed, 28 insertions, 5 deletions
diff --git a/Timeline.Tests/IntegratedTests/UserDetailTest.cs b/Timeline.Tests/IntegratedTests/UserDetailTest.cs
index 571f200f..4923cd06 100644
--- a/Timeline.Tests/IntegratedTests/UserDetailTest.cs
+++ b/Timeline.Tests/IntegratedTests/UserDetailTest.cs
@@ -1,8 +1,6 @@
using FluentAssertions;
using Microsoft.AspNetCore.Mvc.Testing;
using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Net;
using System.Threading.Tasks;
using Timeline.Controllers;
@@ -37,6 +35,12 @@ namespace Timeline.Tests.IntegratedTests
using (var client = await _factory.CreateClientAsUser())
{
{
+ var res = await client.GetAsync($"users/usernotexist/nickname");
+ res.Should().HaveStatusCodeNotFound()
+ .And.Should().HaveBodyAsCommonResponseWithCode(UserDetailController.ErrorCodes.GetNickname_UserNotExist);
+ }
+
+ {
var res = await client.GetAsync($"users/usernotexist/details");
res.Should().HaveStatusCodeNotFound()
.And.Should().HaveBodyAsCommonResponseWithCode(UserDetailController.ErrorCodes.Get_UserNotExist);
@@ -61,15 +65,24 @@ namespace Timeline.Tests.IntegratedTests
{
var res = await client.PatchAsJsonAsync($"users/{MockUsers.UserUsername}/details", new UserDetail
{
+ Nickname = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
QQ = "aaaaaaa",
- EMail = "aaaaaa"
+ EMail = "aaaaaa",
+ PhoneNumber = "aaaaaaaa"
});
- res.Should().HaveStatusCode(HttpStatusCode.BadRequest)
- .And.Should().HaveBodyAsCommonResponseWithCode(CommonResponse.ErrorCodes.InvalidModel);
+ var body = res.Should().HaveStatusCode(HttpStatusCode.BadRequest)
+ .And.Should().HaveBodyAsCommonResponse().Which;
+ body.Code.Should().Be(CommonResponse.ErrorCodes.InvalidModel);
+ foreach (var key in new string[] { "nickname", "qq", "email", "phonenumber" })
+ {
+ body.Message.Should().ContainEquivalentOf(key);
+ }
}
+
var detail = new UserDetail
{
+ Nickname = "aaa",
QQ = "1234567",
EMail = "aaaa@aaa.net",
Description = "aaaaaaaaa"
@@ -81,6 +94,15 @@ namespace Timeline.Tests.IntegratedTests
await GetAndTest(detail);
}
+ {
+ var res = await client.GetAsync($"users/{MockUsers.UserUsername}/nickname");
+ res.Should().HaveStatusCodeOk().And.Should().HaveBodyAsJson<UserDetail>()
+ .Which.Should().BeEquivalentTo(new UserDetail
+ {
+ Nickname = detail.Nickname
+ });
+ }
+
var detail2 = new UserDetail
{
QQ = "",
@@ -93,6 +115,7 @@ namespace Timeline.Tests.IntegratedTests
res.Should().HaveStatusCodeOk();
await GetAndTest(new UserDetail
{
+ Nickname = detail.Nickname,
QQ = null,
EMail = detail.EMail,
PhoneNumber = detail2.PhoneNumber,