public void WhenGoodFormat_ThenGetTheExceptionTypeCorrectly() { // ARRANGE var block = new ExceptionBlock(1, ErrorConstants.NonNestedErrorCorrectCutMessage, ParserMode.Standard); // ACT var parser = CreateSut(); var result = parser.GetException(block); // ASSERT Assert.AreEqual("System.ArgumentOutOfRangeException", result.ExceptionType); }
public void WhenDeveloperComment_ThenGetTheExceptionTypeCorrectly() { // ARRANGE var block = new ExceptionBlock(1, ErrorConstants.DeveloperComment, ParserMode.Standard); // ACT var parser = CreateSut(); var result = parser.GetException(block); // ASSERT Assert.AreEqual("Logari.Ingestor.ErrorGenerator.Exceptions.JobException", result.ExceptionType); }
public void WhenGoodFormat_ThenGetTheExceptionMessageCorrectly() { // ARRANGE var block = new ExceptionBlock(1, ErrorConstants.NonNestedErrorCorrectCutMessage, ParserMode.Standard); string expectedMessage = @"startIndex cannot be larger than length of string. Parameter name: startIndex"; // ACT var parser = CreateSut(); var result = parser.GetException(block); // ASSERT Assert.AreEqual(expectedMessage, result.Message); }
private Tuple<int, int, string> GetExceptionType(ExceptionBlock exceptionBlock) { int start = -1; int end = -1; string exceptionType = string.Empty; if (exceptionBlock.ParserMode == ParserMode.FaultException) { start = exceptionBlock.Text.IndexOf(_configuration.FaultExceptionWithDetailMarker, StringComparison.Ordinal); end = start + _configuration.FaultExceptionWithDetailMarker.Length; exceptionType = "System.ServiceModel.FaultException"; } else { var match = FindExceptionTypeRegex.Match(exceptionBlock.Text); if (match.Success) { start = match.Index; end = match.Index + match.Value.Length; exceptionType = match.Value.Substring(0, match.Value.Length - 1); } else { var sqlExMatch = FindSqlExceptionRegex.Match(exceptionBlock.Text); if (sqlExMatch.Success) { start = match.Index; end = match.Index + match.Value.Length; exceptionType = SqlException; } else { exceptionType = "CouldNotFind"; } } } return new Tuple<int, int, string>(start, end, exceptionType); }
public ExceptionEntity GetException(ExceptionBlock exceptionBlock) { var exceptionTypeInfo = GetExceptionType(exceptionBlock); var exception = new ExceptionEntity(); exception.Depth = (short)exceptionBlock.Depth; exception.ExceptionType = exceptionTypeInfo.Item3; exception.Message = GetExceptionMessage(exceptionBlock.Text, exceptionTypeInfo.Item1, exceptionTypeInfo.Item2); var stackFrames = ExtractStackFrames(exceptionBlock.Text); if (exceptionBlock.ParserMode == ParserMode.FaultException) stackFrames = FilterUnstableStackFrames(stackFrames); exception.StackFrames = stackFrames; return exception; }
public void WhenHasDeveloperComment_ThenGetTheExceptionMessageCorrectly() { // ARRANGE var block = new ExceptionBlock(1, ErrorConstants.DeveloperComment, ParserMode.Standard); string expectedMessage = @"The job failed"; // ACT var parser = CreateSut(); var result = parser.GetException(block); // ASSERT Assert.AreEqual(expectedMessage, result.Message); }
public void WhenFaultExceptionWithExceptionDetail_ThenGetStackFramesCorrectly() { // ARRANGE var block = new ExceptionBlock(1, ErrorConstants.FaultExceptionWithDetail1Block, ParserMode.FaultException); // ACT var parser = CreateSut(); var result = parser.GetException(block); var stackFrames = result.StackFrames.OrderBy(x => x.Depth).ToList(); // ASSERT Assert.AreEqual(2, stackFrames.Count); Assert.AreEqual("SyncInvokeGetRandomDouble(Object , Object[] , Object[] )", stackFrames[0].Path); Assert.AreEqual(1, stackFrames[0].Depth); Assert.AreEqual("ErrorGenerator.WCF.WebService.NumberGenerator.GetRandomDouble()", stackFrames[1].Path); Assert.AreEqual(2, stackFrames[1].Depth); }
public void WhenFaultExceptionWithExceptionDetail_ThenGetTheExceptionTypeCorrectly() { // ARRANGE var block = new ExceptionBlock(1, ErrorConstants.FaultExceptionWithDetail1Block, ParserMode.FaultException); // ACT var parser = CreateSut(); var result = parser.GetException(block); // ASSERT Assert.AreEqual("System.ServiceModel.FaultException", result.ExceptionType); }
public void WhenFaultExceptionWithExceptionDetail_ThenGetTheExceptionMessageCorrectly() { // ARRANGE var block = new ExceptionBlock(1, ErrorConstants.FaultExceptionWithDetail1Block, ParserMode.FaultException); string expectedMessage = @"Object reference not set to an instance of an object. (Fault Detail is equal to An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is: System.NullReferenceException: Object reference not set to an instance of an object."; // ACT var parser = CreateSut(); var result = parser.GetException(block); // ASSERT Assert.AreEqual(expectedMessage, result.Message); }
public void WhenTopBlockInRemotingTimeoutException_ThenGetStackFramesCorrectly() { // ARRANGE var block = new ExceptionBlock(1, ErrorConstants.WcfTimeoutOuter, ParserMode.RemoteException); // ACT var parser = CreateSut(); var result = parser.GetException(block); var stackFrames = result.StackFrames.OrderBy(x => x.Depth).ToList(); // ASSERT Assert.AreEqual(10, stackFrames.Count); Assert.AreEqual("ErrorGenerator.ConsoleApp.Program.GetRandomWholeNumber()", stackFrames[0].Path); Assert.AreEqual(1, stackFrames[0].Depth); Assert.AreEqual("ErrorGenerator.ConsoleApp.CrapRMG.NumberGeneratorClient.GetRandomInt()", stackFrames[1].Path); Assert.AreEqual(2, stackFrames[1].Depth); Assert.AreEqual("ErrorGenerator.ConsoleApp.CrapRMG.INumberGenerator.GetRandomInt()", stackFrames[2].Path); Assert.AreEqual(3, stackFrames[2].Depth); Assert.AreEqual("System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)", stackFrames[3].Path); Assert.AreEqual(4, stackFrames[3].Depth); }
public void WhenTopBlockInRemotingTimeoutException_ThenGetTheExceptionMessageCorrectly() { // ARRANGE var block = new ExceptionBlock(1, ErrorConstants.WcfTimeoutOuter, ParserMode.RemoteException); string expectedMessage = @"The request channel timed out while waiting for a reply after 00:00:59.9269475. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout."; // ACT var parser = CreateSut(); var result = parser.GetException(block); // ASSERT Assert.AreEqual(expectedMessage, result.Message); }
public void WhenTopBlockInRemotingTimeoutException_ThenGetTheExceptionTypeCorrectly() { // ARRANGE var block = new ExceptionBlock(1, ErrorConstants.WcfTimeoutOuter, ParserMode.RemoteException); // ACT var parser = CreateSut(); var result = parser.GetException(block); // ASSERT Assert.AreEqual("System.TimeoutException", result.ExceptionType); }
public void WhenLessUsualFormat_ThenGetStackFramesCorrectly() { // ARRANGE var block = new ExceptionBlock(1, ErrorConstants.VariedStackFrameCharacters, ParserMode.Standard); // ACT var parser = CreateSut(); var result = parser.GetException(block); var stackFrames = result.StackFrames.OrderBy(x => x.Depth).ToList(); // ASSERT Assert.AreEqual(5, stackFrames.Count); Assert.AreEqual("Autofac.Core.Activators.Reflection.ReflectionActivator.<>c__DisplayClass5.<GetConstructorBindings>b__4(ConstructorInfo ci)", stackFrames[0].Path); Assert.AreEqual(1, stackFrames[0].Depth); Assert.AreEqual("Autofac.Core.Activators.Reflection.ConstructorParameterBinding..ctor(ConstructorInfo ci, IEnumerable`1 availableParameters, IComponentContext context)", stackFrames[1].Path); Assert.AreEqual(2, stackFrames[1].Depth); Assert.AreEqual("Autofac.Core.Activators.Reflection.AutowiringParameter.CanSupplyValue(ParameterInfo pi, IComponentContext context, Func`1& valueProvider)", stackFrames[2].Path); Assert.AreEqual(3, stackFrames[2].Depth); Assert.AreEqual("Autofac.Core.Registration.ComponentRegistry.TryGetRegistration(Service service, IComponentRegistration& registration)", stackFrames[3].Path); Assert.AreEqual(4, stackFrames[3].Depth); Assert.AreEqual("System.Threading.Monitor.Enter(Object obj)", stackFrames[4].Path); Assert.AreEqual(5, stackFrames[4].Depth); }
public void WhenGoodFormat_ThenGetStackFramesCorrectly() { // ARRANGE var block = new ExceptionBlock(1, ErrorConstants.NonNestedErrorCorrectCutMessage, ParserMode.Standard); // ACT var parser = CreateSut(); var result = parser.GetException(block); var stackFrames = result.StackFrames.OrderBy(x => x.Depth).ToList(); // ASSERT Assert.AreEqual(4, stackFrames.Count); Assert.AreEqual("Logari.Ingestor.ErrorGenerator.Program.ProvokeNonNestedError()", stackFrames[0].Path); Assert.AreEqual(1, stackFrames[0].Depth); Assert.AreEqual("Logari.Ingestor.ErrorGenerator.Services.StringFunctions.GetSubstring(String input, Int32 sliceLength)", stackFrames[1].Path); Assert.AreEqual(2, stackFrames[1].Depth); Assert.AreEqual("System.String.Substring(Int32 startIndex)", stackFrames[2].Path); Assert.AreEqual(3, stackFrames[2].Depth); Assert.AreEqual("System.String.Substring(Int32 startIndex, Int32 length)", stackFrames[3].Path); Assert.AreEqual(4, stackFrames[3].Depth); }