public ErrorLog Parse(string content)
		{
			try
			{
				_document = new XmlDocument();
				_document.LoadXml(content);
				_documentRoot = _document.DocumentElement;

				_errorLog = new ErrorLog();

			    ParseId();
				ParseApplication();
				ParseAttributes();
				ParseServerVariables();
				ParseFormValues();
				ParseQuerystringValues();
				ParseCookies();
			    ParseCustomDataValues();

				SetStatusCodeInformation();
				SetServerInformation();
				SetClientInformation();

				return _errorLog;
			}
			catch (Exception ex)
			{
				_log.Error(ex);
				return null;
			}
		}
		private static void CreateErrorLogNode(TreeNode dateFolderNode, ErrorLog errorLog)
		{
			var node = dateFolderNode.Nodes.Add(errorLog.Time.ToString());
			node.Tag = errorLog;
			node.ImageIndex = 1;
			node.SelectedImageIndex = 1;
		}
		public void Ctor_HasDefaultUserValueUnknown()
		{
			// act
			var error = new ErrorLog();

			// assert
			Assert.That(error.User, Is.EqualTo("UNKNOWN"));
		}
		public void Ctor_HasEmptyServerVariablesList()
		{
			// act
			var error = new ErrorLog();

			// assert
			Assert.That(error.ServerVariables.Count, Is.EqualTo(0));
		}
		public void Ctor_HasEmptyCookiesList()
		{
			// act
			var error = new ErrorLog();

			// assert
			Assert.That(error.Cookies.Count, Is.EqualTo(0));
		}
		public void Ctor_HasEmptyQuerystringValuesList()
		{
			// act
			var error = new ErrorLog();

			// assert
			Assert.That(error.QuerystringValues.Count, Is.EqualTo(0));
		}
		public void Ctor_HasClientInformation()
		{
			// arrange
			var error = new ErrorLog();
			
			// assert
			Assert.That(error.ClientInformation, Is.Not.Null);
		}
        public void Ctor_ShouldSetErrorLog()
        {
            // arrange
            var error = new ErrorLog();

            // act
            var args = new ErrorLogSelectedEventArgs(error);

            // assert
            Assert.That(args.ErrorLog, Is.EqualTo(error));
        }
        public void OnErrorSelected_ShouldDisplayErrorDetails()
        {
            // arrange
            var presenter = BuildPresenter();
            var error = new ErrorLog();

            // act
            _view.Raise(x => x.OnErrorLogSelected += null, new ErrorLogSelectedEventArgs(error));

            // assert
            _view.Verify(x => x.DisplayErrorDetails(error), Times.Once());
        }
        public void AddQueryStringValue_Adds()
        {
            // arrange
            var error = new ErrorLog();

            // act
            error.AddQuerystringValue("name", "value");

            // assert
            Assert.That(error.QuerystringValues.Count, Is.EqualTo(1));
            Assert.That(error.QuerystringValues[0].Name, Is.EqualTo("name"));
            Assert.That(error.QuerystringValues[0].Value, Is.EqualTo("value"));
        }
        public void AddServerVariable_AddsVariable()
        {
            // arrange
            var error = new ErrorLog();

            // act
            error.AddServerVariable("name", "value");

            // assert
            Assert.That(error.ServerVariables.Count, Is.EqualTo(1));

            var variable = error.ServerVariables[0];
            Assert.That(variable.Name, Is.EqualTo("name"));
            Assert.That(variable.Value, Is.EqualTo("value"));
        }
        public void AddCustomDataValue_AddsCustomData()
        {
            // arrange
            var error = new ErrorLog();

            // act
            error.AddCustomDataValue("name", "value");

            // assert
            Assert.That(error.CustomDataValues.Count, Is.EqualTo(1));

            var variable = error.CustomDataValues[0];
            Assert.That(variable.Name, Is.EqualTo("name"));
            Assert.That(variable.Value, Is.EqualTo("value"));
        }
		private void AddToLogs(string type, string message, string source, DateTime time, string user, string url, ClientInformation clientInformation)
		{
			var errorLog = new ErrorLog { ErrorId = Guid.NewGuid(), Application = "/", Type = type, Message = message, Source = source, Time = time };
			
			if (user.HasValue())
			{
				errorLog.AddServerVariable(HttpServerVariables.LogonUser, user);
			}

			if (url.HasValue())
			{
				errorLog.AddServerVariable(HttpServerVariables.Url, url);
			}

			errorLog.SetClientInformation(clientInformation);

			_logs.Add(errorLog);
		}
		public static ErrorLog CreateFakeErrorLog()
		{
			var errorLog = new ErrorLog();
			errorLog.Time = new DateTime(2011, 6, 4, 11, 6, 0);
			errorLog.Type = "System.InvalidOperationException";
			errorLog.Source = "System.Web.Mvc";
			errorLog.SetStatusCodeInformation(new HttpStatusCodeInformation("500", "Internal error"));

			errorLog.AddServerVariable(HttpServerVariables.Url, "/some/url");

			errorLog.Message =
				"The IControllerFactory 'Sodra.PP.Web.Helpers.UnityMapControllerFactory' did not return a controller for the name 'seh'.";

			errorLog.Details = @"System.InvalidOperationException: The IControllerFactory 'Sodra.PP.Web.Helpers.UnityMapControllerFactory' did not return a controller for the name 'seh'.
   at System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory)
   at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)";

			return errorLog;
		}
        public void DisplayError(ErrorLog error)
        {
            ErrorLog = error;

            Clear();

            _timeLabel.Text = ErrorLog.Time.ToString();
            _urlLabel.Text = ErrorLog.Url;
            _typeLabel.Text = ErrorLog.Type;
            _sourceLabel.Text = ErrorLog.Source;
            _httpStatusCodeTextBox.Text = ErrorLog.StatusCodeInformation.DisplayName;

            _messageTextBox.Text = ErrorLog.Message;
            _detailsTextBox.Text = ErrorLog.Details;

            _userLabel.Text = ErrorLog.User;
            _platformLabel.Text = ErrorLog.ClientInformation.Platform;
            _operatingSystemLabel.Text = ErrorLog.ClientInformation.OperatingSystem;
            _browserLabel.Text = ErrorLog.ClientInformation.Browser;
            _ipAddressLabel.Text = ErrorLog.ClientIpAddress;
            _useragentLabel.Text = ErrorLog.ClientInformation.HttpUserAgentString;

            _clientDetailsOnlineGroupBox.Visible = true;

            _formsListView.LoadValues(ErrorLog.FormValues);
            _cookiesListView.LoadValues(ErrorLog.Cookies);
            _querystringListView.LoadValues(ErrorLog.QuerystringValues);
            _serverVariablesListView.LoadValues(ErrorLog.ServerVariables);
            _customDataValuesListView.LoadValues(ErrorLog.CustomDataValues);

            _hostTextBox.Text = ErrorLog.ServerInformation.Host;
            _nameTextBox.Text = ErrorLog.ServerInformation.Name;
            _portTextBox.Text = ErrorLog.ServerInformation.Port;
            _softwareTextBox.Text = ErrorLog.ServerInformation.Software;

            _browser.DocumentText = new YellowScreenOfDeathBuilder(ErrorLog).GetHtml();
        }
		public void AddServerVariable_NameIsHttpUserAgent_SetAsHttpUserAgent()
		{
			// arrange
			var error = new ErrorLog();

			// act
			error.AddServerVariable(HttpServerVariables.HttpUserAgent, @"/some/kind/of/monster");

			// assert
			Assert.That(error.HttpUserAgent, Is.EqualTo(@"/some/kind/of/monster"));
		}
		public YellowScreenOfDeathBuilder(ErrorLog errorlog)
		{
			ErrorLog = errorlog;
		}
Example #18
0
		public void DisplayErrorDetails(ErrorLog error)
		{
			_detailsView.DisplayError(error);
		}
		public ErrorLogSelectedEventArgs(ErrorLog errorLog)
		{
			ErrorLog = errorLog;
		}
	    public void Ctor_HasEmptyCustomDataValuesList()
	    {
            // arrange
	        var error = new ErrorLog();

            // assert
            Assert.That(error.CustomDataValues.Count, Is.EqualTo(0));
	    }
		public void SetServerInformation_SetsInformation()
		{
			// arrange
			var error = new ErrorLog();
			var info = new ServerInformation();

			// act
			error.SetServerInformation(info);

			// assert
			Assert.That(error.ServerInformation, Is.EqualTo(info));
		}
		public void Ctor_HasStatusCodeInformation()
		{
			// arrange
			var error = new ErrorLog();

			// assert
			Assert.That(error.StatusCodeInformation, Is.Not.Null);
		}
		public void AddServerVariable_NameIsLogon_User_SetAsUserInLowerCase()
		{
			// arrange
			var error = new ErrorLog();

			// act
			error.AddServerVariable(HttpServerVariables.LogonUser, @"DOMAIN\user");
			
			// assert
			Assert.That(error.User, Is.EqualTo(@"domain\user"));
		}
		public void SetServerInformation_InformationIsNull_Throws()
		{
			// arrange
			var error = new ErrorLog();

			// act
			var result = Assert.Throws<ArgumentNullException>(() => error.SetServerInformation(null));

			// assert
			Assert.That(result, Is.Not.Null);
			Assert.That(result.ParamName, Is.EqualTo("information"));
		}
		public void AddServerVariable_NameIsLogon_User_ValueIsEmpty_ShouldUseTheDefaultUserValue()
		{
			// arrange
			var error = new ErrorLog();

			// act
			error.AddServerVariable(HttpServerVariables.LogonUser, string.Empty);

			// assert
			Assert.That(error.User, Is.EqualTo("UNKNOWN"));
		}
		public void AddServerVariable_NameIsURL_SetAsUrlInLowerCase()
		{
			// arrange
			var error = new ErrorLog();

			// act
			error.AddServerVariable(HttpServerVariables.Url, @"/Some/Kind/Of/Monster");

			// assert
			Assert.That(error.Url, Is.EqualTo(@"/some/kind/of/monster"));
		}
		public void AddServerVariable_NameIsOnIgnoreList_ShouldNotAdd()
		{
			// arrange
			var error = new ErrorLog();

			// act
			error.AddServerVariable("ALL_HTTP", "some values");
			
			// assert
			Assert.That(error.ServerVariables.Count, Is.EqualTo(0));
		}
		public void AddServerVariable_NameIsRemoteAddress_SetAsClientIpAddress()
		{
			// arrange
			var error = new ErrorLog();

			// act
			error.AddServerVariable(HttpServerVariables.RemoteAddress, "127.0.0.1");

			// assert
			Assert.That(error.ClientIpAddress, Is.EqualTo("127.0.0.1"));
		}
		public void AddServerVariable_NameIsURL_ValueIsEmpty_ShouldUseTheDefaultUrlValueForCleanUrl()
		{
			// arrange
			var error = new ErrorLog();

			// act
			error.AddServerVariable(HttpServerVariables.Url, string.Empty);

			// assert
			Assert.That(error.CleanUrl, Is.EqualTo("UNKNOWN"));
		}