mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 06:03:12 +00:00
fix(users): compose full Name on user list
This commit is contained in:
parent
b605d5be02
commit
e3a2507908
2 changed files with 41 additions and 1 deletions
40
Api.SeaHavenIndustries.Tests/UserDataServiceTests.cs
Normal file
40
Api.SeaHavenIndustries.Tests/UserDataServiceTests.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
using Data.SeaHavenIndustries;
|
||||||
|
using FluentAssertions;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using SeaHaven.DataServices.Implementation;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Api.SeaHavenIndustries.Tests;
|
||||||
|
|
||||||
|
public class UserDataServiceTests
|
||||||
|
{
|
||||||
|
private static ApplicationDbContext NewContext()
|
||||||
|
{
|
||||||
|
var options = new DbContextOptionsBuilder<ApplicationDbContext>()
|
||||||
|
.UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
|
||||||
|
.Options;
|
||||||
|
return new ApplicationDbContext(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetAllForListAsync_ComposesFullDisplayName()
|
||||||
|
{
|
||||||
|
await using var context = NewContext();
|
||||||
|
context.Users.Add(new ApplicationUser
|
||||||
|
{
|
||||||
|
Id = "s1",
|
||||||
|
UserName = "alex.smith",
|
||||||
|
Email = "alex.smith@example.com",
|
||||||
|
FirstName = "Alex",
|
||||||
|
LastName = "Smith"
|
||||||
|
});
|
||||||
|
await context.SaveChangesAsync();
|
||||||
|
|
||||||
|
var service = new UserDataService(context);
|
||||||
|
var rows = await service.GetAllForListAsync(CancellationToken.None);
|
||||||
|
|
||||||
|
rows.Should().ContainSingle();
|
||||||
|
rows[0].Id.Should().Be("s1");
|
||||||
|
rows[0].Name.Should().Be("Alex Smith");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -44,7 +44,7 @@ namespace SeaHaven.DataServices.Implementation
|
||||||
Id = user.Id,
|
Id = user.Id,
|
||||||
RoleName = user.PhoneNumber,
|
RoleName = user.PhoneNumber,
|
||||||
Email = user.Email,
|
Email = user.Email,
|
||||||
Name = user.FirstName,
|
Name = ((user.FirstName ?? "") + " " + (user.LastName ?? "")).Trim(),
|
||||||
CreatedDate = user.CreatedDate,
|
CreatedDate = user.CreatedDate,
|
||||||
Status = user.UniqueName
|
Status = user.UniqueName
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue