Exemplo n.º 1
0
        public void OpretKonto_With_Correct_RVM_call_proxy_Right_Email()
        {
            //Arrange


            /*User savedUser = null;*/
            _fakeUserProxy.CreateInstanceAsync(Arg.Do <User>(x => _savedUser.Email = x.Email));

            //Ack
            _uut.OpretKonto(_rvm);
            //Assert
            Assert.That(_savedUser.Email, Is.EqualTo(_rvm.Email));
        }
        public IActionResult OpretKonto(RegistorViewModel vm)
        {
            //Check for valid inpit
            if (ModelState.IsValid)
            {
                var user = new User
                {
                    Username  = vm.Username,
                    Email     = vm.Email,
                    GivenName = vm.GivenName,
                    LastName  = vm.LastName,
                    Password  = vm.Password
                };

                //Try to create user
                try
                {
                    var sendUser = _proxy.CreateInstanceAsync(user);
                    sendUser.Wait();
                    if (sendUser.Result != null)
                    {
                        return(RedirectToAction("LogInd", "Home"));
                    }

                    //return RedirectToAction("OpretKonto");
                    return(RedirectToAction("OpretKonto", "Konto"));
                }

                catch (ArgumentException)
                {
                    return(RedirectToAction("OpretKonto", "Konto"));
                }
            }
            return(View(vm));
        }