Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(auth sdk):add UpsertUser #141

Merged
merged 1 commit into from
Jul 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -20,6 +20,12 @@ public UserService(ICallerProvider callerProvider, IUserContext userContext)
return await _callerProvider.PostAsync<AddUserModel, UserModel>(requestUri, user);
}

public async Task<UserModel?> UpsertAsync(UpsertUserModel user)
{
var requestUri = $"api/user/upsertExternal";
return await _callerProvider.PostAsync<UpsertUserModel, UserModel>(requestUri, user);
}

public async Task<List<StaffModel>> GetListByDepartmentAsync(Guid departmentId)
{
var requestUri = $"api/staff/getListByDepartment";
15 changes: 15 additions & 0 deletions test/Masa.Contrib.BasicAbility.Auth.Tests/UserServiceTest.cs
Original file line number Diff line number Diff line change
@@ -21,6 +21,21 @@ public async Task TestAddAsync()
Assert.IsTrue(result is not null);
}

[TestMethod]
public async Task UpsertAsync()
{
var upsertUser = new UpsertUserModel();
var user = new UserModel();
var requestUri = $"api/user/upsertExternal";
var callerProvider = new Mock<ICallerProvider>();
callerProvider.Setup(provider => provider.PostAsync<UpsertUserModel, UserModel>(requestUri, upsertUser, default)).ReturnsAsync(user).Verifiable();
var userContext = new Mock<IUserContext>();
var userService = new UserService(callerProvider.Object, userContext.Object);
var result = await userService.UpsertAsync(upsertUser);
callerProvider.Verify(provider => provider.PostAsync<UpsertUserModel, UserModel>(requestUri, upsertUser, default), Times.Once);
Assert.IsTrue(result is not null);
}

[TestMethod]
public async Task TestGetListByDepartmentAsync()
{