예제 #1
0
        public void ReturnErrorWhenUserNameNotUnique()
        {
            _userService.Setup(x => x.UserNameAvailable(It.IsAny <int>(), It.IsAny <string>())).Returns(false);

            var form   = new RegisterForm();
            var result = _validator.Validate(form);

            Assert.False(result.IsValid);
        }
예제 #2
0
        public async void Register()
        {
            var registerModel = new RegisterFormModel
            {
                Username        = Username,
                Email           = Email,
                Password        = Password,
                ConfirmPassword = ConfirmPassword,
                FirstName       = FirstName,
                LastName        = LastName
            };

            var result = _registerValidator.Validate(registerModel);

            if (result.IsValid)
            {
                if (await _registerService.Register(registerModel))
                {
                    _events.PublishOnUIThread(new UserHasRegisteredEvent());
                    this.TryClose();
                }
                else
                {
                    MessageBox.Show("Wystąpił błąd. Spróbuj ponownie");
                }
            }
            else
            {
                MessageBox.Show("Błąd walidacji danych.");
            }
        }