コード例 #1
0
        public void LoginUnitOfWorkReconnectThrowsExceptionReturnsFalse()
        {
            UserLoginDTO userLogin = new UserLoginDTO();

            unitOfWork.Setup(u => u.Reconnect(It.IsAny <string>(), It.IsAny <string>())).Throws(new Exception());

            LoginServiceMessage result = service.Login(userLogin);

            Assert.IsFalse(result.IsSuccessful);
        }
コード例 #2
0
        private void Login()
        {
            using (IAuthService authService = new AuthService())
            {
                string login    = loginTxt.Text;
                string password = passwordTxt.Password;

                UserLoginDTO userLogin = new UserLoginDTO
                {
                    Login    = login,
                    Password = password
                };

                LoginServiceMessage result = authService.Login(userLogin);

                if (result.IsSuccessful)
                {
                    loginTxt.Clear();
                    passwordTxt.Clear();

                    LoginType      loginType = result.LoginType;
                    ServiceFactory factory   = result.Factory;

                    ControllerFactory controllerFactory = new ControllerFactory(factory, loginType, login);

                    ILogger logger = new Logger();

                    SignOutWindowBase window = Create(controllerFactory, logger, loginType, login);

                    window.SignedOut += (s, e) =>
                    {
                        this.Show();
                        shouldBeClosed = false;
                        window.Close();
                    };
                    window.Closed += (s, e) => this.Close();

                    window.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Could not login: " + result.Message);
                }
            }
        }
コード例 #3
0
        public void LoginAsClientReturnsResultForClient()
        {
            UserLoginDTO userLogin  = new UserLoginDTO();
            UserEntity   userEntity = new UserEntity
            {
                Role = new RoleEntity {
                    Name = "Client"
                }
            };

            unitOfWork.Setup(u => u.Users.GetAll(It.IsAny <Expression <Func <UserEntity, bool> > >())).Returns(new List <UserEntity>()
            {
                userEntity
            });

            LoginServiceMessage result = service.Login(userLogin);

            Assert.IsTrue(result.IsSuccessful);
            Assert.AreEqual <LoginType>(result.LoginType, LoginType.Client);
            Assert.IsInstanceOfType(result.Factory, typeof(ClientServiceFactory));
        }