public void Public_FileHasNoApplicationAttribute_ApplicationShouldBeEmptyString()
		{
			var parser = new ErrorLogFileParser(new FakeLog(), new ClientInformationResolver());

			// act
			var result = parser.Parse(GetValidFileWithNoApplication());

			// assert
			Assert.That(result.Application, Is.EqualTo(string.Empty));
		}
		public void Parse_FileIsMissingServervariables()
		{
			// arrange
			var parser = new ErrorLogFileParser(new FakeLog(), new ClientInformationResolver());

			// act
			var result = parser.Parse(GetValidFileWithNoServerVaiables());

			// assert
			Assert.That(result.ServerVariables.Count, Is.EqualTo(0));
		}
	    public void Parse_ErrorIdIsMissingInFile()
	    {
	        // arrange
            var parser = new ErrorLogFileParser(new FakeLog(), new ClientInformationResolver());

	        // act
            var result = parser.Parse(GetValidFileWithNoErrorId());

	        // assert
	        Assert.That(result.ErrorId, Is.EqualTo(Guid.Empty));
        }
		public void Parse_FileIsNotInCorrectFormat_ReturnsNull()
		{
			// arrange
			var parser = new ErrorLogFileParser(new FakeLog(), new ClientInformationResolver());

			// act
			var result = parser.Parse(GetInvalidFileContent());
			
			// assert
			Assert.That(result, Is.Null);
		}
		protected ErrorLogRepository CreateRepository(int maxNumberOfLogs = -1)
		{
			var fileSystemHelper = new FileSystemHelper();
			var log = new FakeLog();
			var settings = new FakeSettingsManager();
			settings.SetMaxNumberOfLogs(maxNumberOfLogs);

			var parser = new ErrorLogFileParser(log, new ClientInformationResolver());
			var datasource = new FileErrorLogSource(TestFilesDirectory, fileSystemHelper, parser, settings, log);

			var repository = new ErrorLogRepository(datasource);
			return repository;
		}
		public void Parse_ReturnsErrorLogWithFileContent()
		{
			// arrange
			var parser = new ErrorLogFileParser(new FakeLog(), new ClientInformationResolver());

			// act
			var result = parser.Parse(GetValidFileContent());

			// assert
			Assert.That(result.ErrorId, Is.EqualTo(new Guid("dce7f8f3-ac74-4ad9-9435-a344be794c7e")));
			Assert.That(result.Application, Is.EqualTo("/LM/W3SVC/24/ROOT"));
			Assert.That(result.Host, Is.EqualTo("ALVA"));
			Assert.That(result.User, Is.EqualTo(@"alva\per"));
			Assert.That(result.Url, Is.EqualTo("/"));
			Assert.That(result.Type, Is.EqualTo("System.Data.SqlClient.SqlException"));
			Assert.That(result.Message, Is.EqualTo("A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)"));
			Assert.That(result.StatusCode, Is.EqualTo("404"));
			Assert.That(result.Source, Is.EqualTo(".Net SqlClient Data Provider"));
			Assert.That(result.ServerVariables.Count > 0);
			Assert.That(result.Cookies.Count, Is.EqualTo(5));
			Assert.That(result.FormValues.Count, Is.EqualTo(16));
			Assert.That(result.QuerystringValues.Count, Is.EqualTo(1));
		}
		public void Parse_FileHasStatusCode_LooksUpCodeAndSetsStatusCodeInformation()
		{
			// arrange
			var parser = new ErrorLogFileParser(new FakeLog(), new ClientInformationResolver());

			// act
			var result = parser.Parse(GetValidFileContent());

			// assert
			Assert.That(result.StatusCode, Is.EqualTo("404"));
			Assert.That(result.StatusCodeInformation, Is.Not.Null);
			Assert.That(result.StatusCodeInformation.Code, Is.EqualTo("404"));
		}
		public void Parse_SetsClientInformation()
		{
			// arrange
			var parser = new ErrorLogFileParser(new FakeLog(), new ClientInformationResolver());

			// act
			var result = parser.Parse(GetValidFileContent());

			// assert
			Assert.That(result.ClientInformation, Is.Not.Null);
		}
		public void Parse_SetsServerInformation()
		{
			// arrange
			var parser = new ErrorLogFileParser(new FakeLog(), new ClientInformationResolver());

			// act
			var result = parser.Parse(GetValidFileContent());

			// assert
			Assert.That(result.ServerInformation.Host, Is.EqualTo("ALVA"));
			Assert.That(result.ServerInformation.Name, Is.EqualTo("localhost"));
			Assert.That(result.ServerInformation.Port, Is.EqualTo("53197"));
			Assert.That(result.ServerInformation.Software, Is.EqualTo(string.Empty));
		}