public void ResolveElmahRootUrl_UsingCustomHandlerName_ReturnsTheCustomHandlderNameInUrl()
        {
            // arrange
            var helper = new ElmahUrlHelper();
            const string url = "http://www.test.com/bugs.axd";

            // act
            var result = helper.ResolveElmahRootUrl(url);

            // assert
            Assert.That(result, Is.EqualTo("http://www.test.com/bugs.axd"));
        }
        public void ResolveElmahRootUrl_UrlIsMissingElmahExtension_ReturnWithAddedElmahExtension()
        {
            // arrange
            var helper = new ElmahUrlHelper();
            const string url = "http://www.test.com";

            // act
            var result = helper.ResolveElmahRootUrl(url);

            // assert
            Assert.That(result, Is.EqualTo("http://www.test.com/elmah.axd"));
        }
        public void ResolveElmahRootUrl_UrlIsDefaultRoot_ReturnsUrl()
        {
            // arrange
            var helper = new ElmahUrlHelper();
            var url = "http://www.test.com/elmah.axd";

            // act
            var result = helper.ResolveElmahRootUrl(url);

            // assert
            Assert.That(result, Is.EqualTo(url));
        }
        public void ResolveCsvDownloadUrl_ServerUriEndsWithSlash_ReturnUrl()
        {
            // arrange
            var helper = new ElmahUrlHelper();
            var serverUri = new Uri("http://www.test.com/elmah.axd/");

            // act
            var result = helper.ResolveCsvDownloadUrl(serverUri);

            // assert
            Assert.That(result.AbsoluteUri, Is.EqualTo("http://www.test.com/elmah.axd/download"));
        }
        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);
            }
        }
        private void ResolveLogsAvailableForDownload()
        {
            var downloadUrl = new ElmahUrlHelper().ResolveCsvDownloadUrl(Connection.Uri);
            var connection = Connection.CopyWithCredentials(downloadUrl.AbsoluteUri);

            var csvContent = _webRequst.Uri(connection);
            CsvContent = _csvParser.Parse(csvContent).ToList(/* materialize */);
        }