using FluentAssertions; using Nashel.Modules.Identity.Domain.Aggregates; using Nashel.Modules.Identity.Domain.Enums; using Xunit; namespace Nashel.Modules.Identity.Tests.Domain; public class AccountTests { [Fact] public void Create_Should_Create_Account_With_User_Role() { // Arrange & Act (Подготовка и Действие) var phone = "1234567890"; var passwordHash = "hash"; var account = Account.Create(phone, passwordHash); // Assert (Проверка) account.Should().NotBeNull(); account.Roles.Should().ContainSingle(r => r == Role.User); account.Roles.Should().HaveCount(1); } [Fact] public void BecomePerformer_Should_Add_Candidate_Role() { // Arrange (Подготовка) var account = Account.Create("123", "hash"); // Act (Действие) account.BecomePerformer(); // Assert (Проверка) account.Roles.Should().Contain(Role.Candidate); account.Roles.Should().Contain(Role.User); account.Roles.Should().HaveCount(2); // User + Candidate } [Fact] public void BecomePerformer_Should_Do_Nothing_If_Already_Candidate() { // Arrange (Подготовка) var account = Account.Create("123", "hash"); account.BecomePerformer(); // Act (Действие) account.BecomePerformer(); // Assert (Проверка) account.Roles.Should().ContainSingle(r => r == Role.Candidate); account.Roles.Should().HaveCount(2); } [Fact] public void PromoteToMaster_Should_Replace_Candidate_With_Master() { // Arrange (Подготовка) var account = Account.Create("123", "hash"); account.BecomePerformer(); // Has Candidate // Act (Действие) account.PromoteToMaster(); // Assert (Проверка) account.Roles.Should().NotContain(Role.Candidate); account.Roles.Should().Contain(Role.Master); account.Roles.Should().Contain(Role.User); } }