public void Deve_interromper_a_execucao_quando_o_username_nao_tiver_cadastrado()
        {
            _command.Username = "******";
            var result = (GenericCommandResult)_accountHandler.Handle(_command);

            Assert.AreEqual(result.Message, "Email não cadastrado.");
        }
예제 #2
0
		public void RemoveAccount()
		{
			var accountName = new AccountName("Account");
			_accountCollection.GetOrCreate(accountName);
			Assert.IsTrue(_accountCollection.Any(c => c.Name == accountName.Value));
			_accountHandler.Handle(new AccountRemovedMessage(accountName.Value));
			_accountHandler.Handle(_bus.PluginCommands.OfType<AccountRemovedLastStepMessage>().Single());
			Assert.IsFalse(_accountCollection.Any(c => c.Name == accountName.Value));
		}
예제 #3
0
        public void GivenAnInvalidCommandShouldNotCreateAccount()
        {
            //Given
            var command = new CreateAccountCommand("", "");

            //When
            var result = (GenericCommandResult)_accountHandler.Handle(command);

            //Then
            Assert.False(result.Success);
        }
예제 #4
0
        public async Task <IActionResult> SignUp([FromBody] CreateAccountCommand command)
        {
            var result = _accountHandler.Handle(command);

            return(await Response(result));

            //var actionResult = await Response(result);
            //if (!result.Success)
            //return await Response(result);
            //return await SignIn(new AuthenticateUserCommand() { Email = command.Email, Password = command.Password, KeepLoggedIn = false });
        }
예제 #5
0
        public void RemoveAccount(RoutableTransportMode mode, bool isQueueDelete)
        {
            _msmqTransport.RoutableTransportMode = mode;
            var accountName = new AccountName("Account");

            _accountCollection.GetOrCreate(accountName);
            Assert.IsTrue(_accountCollection.Any(c => c.Name == accountName.Value));
            _accountHandler.Handle(new AccountRemovedMessage(accountName.Value));
            _accountHandler.Handle(_bus.PluginCommands.OfType <AccountRemovedLastStepMessage>().Single());
            Assert.IsFalse(_accountCollection.Any(c => c.Name == accountName.Value));
            Assert.AreEqual(_msmqTransport.IsQueueDeleted, isQueueDelete);
        }
예제 #6
0
        public ICommandResult Login([FromBody] LoginCommand command)
        {
            ICommandResult loginResult = _handler.Handle(command);

            if (loginResult.Status == false)
            {
                return(loginResult);
            }

            UserAuthQuery user  = (UserAuthQuery)loginResult.Data;
            string        token = TokenService.GenerateToken(user);
            object        data  = new { token = token, user = user };

            return(new CommandResult(loginResult.Status, loginResult.Message, data: data));
        }
        public async Task <IActionResult> Post([FromBody] CreateAccountCommand command)
        {
            try
            {
                _uow.OpenTransaction();
                var result = await _handler.Handle(command);

                return(await Response(result, _handler.Notifications));
            }

            catch (Exception ex)
            {
                return(await TryErrors(ex));
            }
        }
예제 #8
0
        public void Deve_Criar_Uma_Nova_Conta()
        {
            var command = new CreateAccountCommand
            {
                Hostname        = "localhost:43500",
                CompanyName     = "TreezeBit",
                Password        = "******",
                ConfirmPassword = "******",
                Email           = "*****@*****.**",
                FirstName       = "Victor",
                LastName        = "Domingues"
            };

            var accountHandler = new AccountHandler(_tenantRepository, _userRepository, _createAccountEmailService);

            var result = accountHandler.Handle(command);

            Assert.IsTrue(result.Success);
            Assert.AreEqual(accountHandler.Notifications.Count, 0);
            Assert.AreEqual(_tenants.Count, 1);
            Assert.AreEqual(_users.Count, 1);
        }
예제 #9
0
 public GenericCommandResult CreateAccount(CreateAccountCommand createAccountCommand)
 {
     return((GenericCommandResult)_handler.Handle(createAccountCommand));
 }
예제 #10
0
        public void Can_create_an_account()
        {
            var id      = Guid.NewGuid();
            var holder  = "someone";
            var command = new CreateAccount(id, holder);
            var reply   = _service.Handle(command);

            Assert.Equal(typeof(Success), reply.GetType());
            Assert.True(_repo.TryGetById(command.AccountId, out TestAccount account));
        }
예제 #11
0
        public async Task <IActionResult> Register([FromBody] RegisterCommand command)
        {
            var result = _accountHandler.Handle(command);

            return(await CreateResponse(result, _accountHandler.Notifications));
        }
예제 #12
0
        public async Task <ICommandResult> Post([FromBody] CreateAccountCommand command)
        {
            ICommandResult result = await _handler.Handle(command);

            return(result);
        }
 public GenericCommandResult Login(
     [FromBody] AccountLoginCommand command,
     [FromServices] AccountHandler handler)
 {
     return((GenericCommandResult)handler.Handle(command));
 }