コード例 #1
0
        public void UserInsertCommand_invalid_login_invalid(string param)
        {
            UserInsertCommand _command = new UserInsertCommand();

            _command.Email    = "*****@*****.**";
            _command.Login    = param;
            _command.Name     = "carlos";
            _command.Password = "******";
            _command.Role     = "role";

            _command.Validate();
            var _notification = (List <Flunt.Notifications.Notification>)_command.Notifications;

            Assert.False(_command.Valid);
            Assert.True(_command.Invalid);

            Assert.NotEmpty(_command.Email);

            if (param == null)
            {
                Assert.Null(_command.Login);
            }
            else
            {
                Assert.Empty(_command.Login);
            }

            Assert.NotEmpty(_command.Name);
            Assert.NotEmpty(_command.Password);
            Assert.NotEmpty(_command.Role);
            Assert.True(((List <Flunt.Notifications.Notification>)_command.Notifications).Count == 1);
            Assert.Equal("Login not be null.", _notification[0].Message);
        }
コード例 #2
0
        public void TranslateExternalInsertCommandToAkkaMessage(HTTPSourcedCommand cmdExternal)
        {
            UserState cs;

            if (ExtractStateObject(cmdExternal, out cs))
            {
                UserInsertCommand insertCommand = new UserInsertCommand(cs, cmdExternal.User, cmdExternal.ConnectionId);
                SendTo.Tell(insertCommand, ReplyTo);
            }
        }
コード例 #3
0
        public void UserInsertCommand_valid()
        {
            UserInsertCommand _command = new UserInsertCommand();

            _command.Email    = "*****@*****.**";
            _command.Login    = "******";
            _command.Name     = "carlos";
            _command.Password = "******";
            _command.Role     = "role";

            _command.Validate();
            var _notification = (List <Flunt.Notifications.Notification>)_command.Notifications;

            Assert.True(_command.Valid);
            Assert.False(_command.Invalid);

            Assert.NotEmpty(_command.Email);
            Assert.NotEmpty(_command.Login);
            Assert.NotEmpty(_command.Name);
            Assert.NotEmpty(_command.Password);
            Assert.NotEmpty(_command.Role);
            Assert.True(((List <Flunt.Notifications.Notification>)_command.Notifications).Count == 0);
        }
コード例 #4
0
        public async Task TruckHandler_insert_invalid()
        {
            var mockContextRepository = new Mock <IContextRepository>();
            var mockUserRepository    = new Mock <IUserRepository>();

            UserInsertCommand userInsertCommand = new UserInsertCommand();

            userInsertCommand.Login    = "******";
            userInsertCommand.Email    = "*****@*****.**";
            userInsertCommand.Password = "******";
            userInsertCommand.Name     = "Name";
            userInsertCommand.Role     = "Role";

            mockContextRepository.Setup(x => x.Add(It.IsAny <User>())).ReturnsAsync(false);

            UserHandler _handler = new UserHandler(mockContextRepository.Object, mockUserRepository.Object);

            var _return = await _handler.Handle(userInsertCommand);

            Assert.False(_return.Success);
            Assert.False((bool)_return.Data);
            Assert.Equal(HttpStatusCode.BadRequest, _return.Code);
        }
コード例 #5
0
 public async Task <GenericCommandResult> PostUser(
     [FromBody] UserInsertCommand command,
     [FromServices] IHandler <UserInsertCommand> handler)
 {
     return((GenericCommandResult)await handler.Handle(command));
 }
コード例 #6
0
        public async Task <IActionResult> AddAsync([FromBody] UserInsertCommand userInsertCommand)
        {
            var result = await _mediator.Send(userInsertCommand);

            return(result ? Json(new { HttpStatusCode.OK }) : (IActionResult)BadRequest());
        }
コード例 #7
0
 private void InsertNewUserRecoveryCommand(UserInsertCommand c)
 {
     // When recovering set the state of the actor
     _ActorState = c.UserStateData;
 }
コード例 #8
0
 public UserInsertRecordedEvent(IActorRef sender, UserInsertCommand c, string user, string connectionId)
     : base(c.Id, null, UserActor.ActorType, MicroServices.Area.User, "User Insert Recorded", c, user, connectionId)
 {
     Sender = sender;
 }