public void HasCredentials_DomainHasValue_IsTrue()
		{
			// arrange
			var args = new ConnectToServerEventArgs("http://www.test.com/elmah.axd", string.Empty, string.Empty, "domain1");

			// act
			var result = args.HasCredentials;

			// assert
			Assert.That(result, Is.True);
		}
		public void HasCredentials_OnlyUrlHasValue_IsFalse()
		{
			// arrange
			var args = new ConnectToServerEventArgs("http://www.test.com/elmah.axd", string.Empty, null, " ");

			// act
			var result = args.HasCredentials;
			
			// assert
			Assert.That(result, Is.False);
		}
		private void ConnectButtonClick(object sender, EventArgs e)
		{
			if (OnConnectToServer != null)
			{
				var args = new ConnectToServerEventArgs(
					_urlComboBox.Text, 
					_userNameTextBox.Text, 
					_passwordTextBox.Text,
				    _domainTextBox.Text);

				OnConnectToServer(this, args);
			}
		}
		public void Ctor_ShouldSetUrlUserNamePasswordAndDomain()
		{
			// arrange
			const string url = "http://www.test.com/elmah.axd";
			const string username = "******";
			const string password = "******";
			const string domain = "domain1";

			// act
			var args = new ConnectToServerEventArgs(url, username, password, domain);

			// assert
			Assert.That(args.Url, Is.EqualTo(url));
			Assert.That(args.UserName, Is.EqualTo(username));
			Assert.That(args.Password, Is.EqualTo(password));
			Assert.That(args.Domain, Is.EqualTo(domain));
		}
        private void View_OnConnectToServer(object sender, ConnectToServerEventArgs e)
        {
            View.ClearErrorMessage();

            if (!e.Url.HasValue())
            {
                View.DisplayErrorMessage("Invalid url");
                return;
            }

            try
            {
                var elmahUrl = new ElmahUrlHelper().ResolveElmahRootUrl(e.Url);
                var connection = new NetworkConnection(elmahUrl);

                if (e.HasCredentials)
                {
                    connection.SetCredentials(e.UserName, e.Password, e.Domain);
                }

                var serverResponded = _urlPing.Ping(connection);

                if (!serverResponded.Item1)
                {
                    View.DisplayErrorMessage(serverResponded.Item2);
                    return;
                }

                Connnection = connection;

                View.CloseView();
            }
            catch (ArgumentException)
            {
                View.DisplayErrorMessage("Invalid url");
            }
            catch (Exception ex)
            {
                View.DisplayErrorMessage(ex.Message);
            }
        }