public void FormatDisplayName_FormatsCorrectly(string initialDisplayName, string expectedFormattedName) { // Act var actualFormattedName = NameFormattingHelper.FormatDisplayName(initialDisplayName); // Assert Assert.Equal(expectedFormattedName, actualFormattedName); }
public string GetUserDisplayName(ClaimsPrincipal user) { var displayName = NameFormattingHelper.FormatDisplayName(user.Identity?.Name); if (displayName.IsNullOrEmpty() || displayName.Contains("@")) { var nameClaim = user.Claims.FirstOrDefault(c => c.Type == "name"); if (nameClaim != null) { displayName = NameFormattingHelper.FormatDisplayName(nameClaim.Value); } } return(displayName); }