예제 #1
0
        private void Login(object obj)
        {
            var manager = new AlertsManager();

            try
            {
                Database.Instance.Connect();
                var gateway = new UsersGateway();

                if (gateway.IsValid(_nick, _password, Database.Instance))
                {
                    var user = new User(_nick);
                    OnUserLogged(user);
                    Visible = false;
                }
                else
                {
                    manager.Show("Niepoprawna nazwa użytkownika lub hasło.", Alerts.Warning);
                }
            }
            catch (Exception)
            {
                manager.Show("Problem z połączeniem z internetem.", Alerts.Warning);
            }
        }
예제 #2
0
        public void IsValidTest()
        {
            _connection.Open();

            // Arrange:
            var mock = new Mock <IDatabase>();

            mock.SetupGet(x => x.Connection).Returns(_connection);

            var gateway = new UsersGateway();

            // Act:
            bool result = gateway.IsValid("TestUser", "test", mock.Object);

            // Assert:
            Assert.AreEqual(true, result);

            _connection.Close();
        }