本文整理汇总了C#中IdentityRole.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# IdentityRole.ToString方法的具体用法?C# IdentityRole.ToString怎么用?C# IdentityRole.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IdentityRole
的用法示例。
在下文中一共展示了IdentityRole.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Creating_same_role_twice_returns_DuplicateRoleName_error
public async Task Creating_same_role_twice_returns_DuplicateRoleName_error()
{
// arrange
var role = new IdentityRole("Creating_same_role_twice_returns_DuplicateRoleName_error");
// act
var result1 = await _roleStore.CreateAsync(role);
role.Name = "a different name, but same Id";
var result2 = await _roleStore.CreateAsync(role);
// assert
IdentityResultAssert.IsSuccess(result1);
var expectedError = IdentityResult.Failed(_errorDescriber.DuplicateRoleName(role.ToString()));
IdentityResultAssert.IsFailure(result2, expectedError.Errors.FirstOrDefault());
}
示例2: Updating_role_name_to_existing_name_returns_DuplicateRoleName_error
public async Task Updating_role_name_to_existing_name_returns_DuplicateRoleName_error()
{
// arrange
var role1 = new IdentityRole("Updating_role_name_to_existing_name_returns_DuplicateRoleName_error");
var role2 = new IdentityRole("Updating_role_name_to_existing_name_returns_DuplicateRoleName_error different");
await _roleStore.CreateAsync(role1);
await _roleStore.CreateAsync(role2);
// act
role2.Name = role1.Name;
var result3= await _roleStore.UpdateAsync(role2);
// assert
var expectedError = IdentityResult.Failed(_errorDescriber.DuplicateRoleName(role2.ToString()));
IdentityResultAssert.IsFailure(result3, expectedError.Errors.FirstOrDefault());
}
示例3: Creating_two_different_roles_with_same_Name_different_casing_returns_DuplicateRoleName_error
public async Task Creating_two_different_roles_with_same_Name_different_casing_returns_DuplicateRoleName_error()
{
// arrange
var role1 = new IdentityRole("Creating_two_different_roles_with_same_Name_different_casing_returns_DuplicateRoleName_error");
var role2 = new IdentityRole(role1.Name.ToUpper());
// act
var result1 = await _roleStore.CreateAsync(role1);
var result2 = await _roleStore.CreateAsync(role2);
// assert
IdentityResultAssert.IsSuccess(result1);
var expectedError = IdentityResult.Failed(_errorDescriber.DuplicateRoleName(role2.ToString()));
IdentityResultAssert.IsFailure(result2, expectedError.Errors.FirstOrDefault());
}