public void TestCommandHandle() { var accountName = "testName"; var accountServiceMock = new Mock <IAggregateService <AccountAggregate> >(); accountServiceMock.Setup(m => m.Load(It.IsAny <Guid>())).Returns((Guid guid) => new AccountAggregate()); var eventPublisherMock = new Mock <IEventPublisher>(); eventPublisherMock.Setup(m => m.Publish(It.IsAny <CreateAccountEvent>())).Callback((IEvent e) => { Assert.IsType <CreateAccountEvent>(e); CreateAccountEvent createAccountEvent = (CreateAccountEvent)e; Assert.Equal(accountName, createAccountEvent.AccountName); Assert.NotEqual(Guid.Empty, createAccountEvent.ItemGuid); Assert.Equal(Guid.Empty, createAccountEvent.EventGuid); }); var commandHandler = new CreateAccountCommandHandler(accountServiceMock.Object, eventPublisherMock.Object); ICommand command = new CreateAccountCommand { Name = accountName }; commandHandler.Handle((CreateAccountCommand)command); eventPublisherMock.VerifyAll(); }
public static IEnumerator CreateAccount( Client client, string accountNamespaceName, CreateAccountEvent onCreateAccount, ErrorEvent onError ) { AsyncResult <EzCreateResult> result = null; yield return(client.Account.Create( r => { result = r; }, accountNamespaceName )); if (result.Error != null) { onError.Invoke( result.Error ); yield break; } var account = result.Result.Item; onCreateAccount.Invoke(account); }
private void ProcessCreateAccount(CreateAccountEvent newUserData) { Console.WriteLine("Processing CreateAccountEvent..."); _processSuccess = _dbManager.CreateAccount(newUserData.UserEmail, newUserData.UserPassword); ServerReply(new ResponseEvent(_processSuccess)); }
void ISCPacketHandler.HANDLE_SC_CreateAccount(long accountId) { if (accountId == -1) { Log.I.Debug($"계정 생성실패"); } ClientJobManager.I.ReserveJob(async() => { m_AccountId = accountId; CreateAccountEvent?.Invoke(accountId); }); }
public override void Handle(ICommand command) { var createAccountCommand = (CreateAccountCommand)command; var accountGuid = GetAccountGuid(); var accountName = createAccountCommand.Name; var createAccountEvent = new CreateAccountEvent { ItemGuid = accountGuid, AccountName = accountName }; _eventPublisher.Publish(createAccountEvent); }
public void TestCreateAccountEvent() { var accountGuid = Guid.NewGuid(); var accountName = "TestName"; var createAccountEvent = new CreateAccountEvent { EventGuid = Guid.NewGuid(), ItemGuid = accountGuid, AccountName = accountName }; var accountAggregate = new AccountAggregate(); accountAggregate.From(new List <IEvent>() { createAccountEvent }); Assert.Equal(accountGuid, accountAggregate.Guid); Assert.Equal(accountName, accountAggregate.Name); }
public void TestHandle() { var accountGuid = Guid.NewGuid(); var accountName = "testName"; var createAccountEvent = new CreateAccountEvent { EventGuid = Guid.NewGuid(), ItemGuid = accountGuid, AccountName = accountName }; var accountServiceMock = new ServiceMock(); var eventHandler = new CreateAccountEventHandler(accountServiceMock); eventHandler.Handle(createAccountEvent); Assert.Single(ServiceMock.Saved); var accountModel = ServiceMock.Saved.First(); Assert.True(accountModel.Guid.Equals(accountGuid)); Assert.True(accountModel.Name.Equals(accountName)); }
public static IEnumerator AutoLogin( Client client, IAccountRepository repository, string accountNamespaceName, string accountEncryptionKeyId, CreateAccountEvent onCreateAccount, LoginEvent onLogin, ErrorEvent onError ) { var error = false; void OnCreateAccount(EzAccount account) { repository.SaveAccount( new PersistAccount { UserId = account.UserId, Password = account.Password, } ); } void OnError(Gs2Exception e) { error = true; } onCreateAccount.AddListener(OnCreateAccount); onError.AddListener(OnError); try { if (!repository.IsExistsAccount()) { yield return(CreateAccount( client, accountNamespaceName, onCreateAccount, onError )); } if (error) { yield break; } var account = repository.LoadAccount(); yield return(Login( client, account?.UserId, account?.Password, accountNamespaceName, accountEncryptionKeyId, onLogin, onError )); } finally { onError.RemoveListener(OnError); onCreateAccount.RemoveListener(OnCreateAccount); } }