public void AddException_RetrieveWithExceptionsProperty() { var errorAggregator = new ErrorAggregator<Exception>(); var exception1 = new Exception("test exception"); var exception2 = new Exception ("another text exception"); errorAggregator.AddException(exception1); errorAggregator.AddException(exception2); Assert.That(new[] { exception1, exception2 }, Is.EqualTo(errorAggregator.Exceptions.ToList())); }
public void AddException_RetrieveWithExceptionsProperty() { var errorAggregator = new ErrorAggregator <Exception>(); var exception1 = new Exception("test exception"); var exception2 = new Exception("another text exception"); errorAggregator.AddException(exception1); errorAggregator.AddException(exception2); Assert.That(new[] { exception1, exception2 }, Is.EqualTo(errorAggregator.Exceptions.ToList())); }
public ReflectedObject GetTargetClassDefinition(Type type, ReflectedObject classContext) { if (type.IsGenericTypeDefinition || type.IsInterface) { return(null); } try { // may throw ConfigurationException or ValidationException return(_remotionReflector.GetTargetClassDefinition(type, _mixinConfiguration, classContext)); } catch (Exception configurationOrValidationException) { if (_remotionReflector.IsConfigurationException(configurationOrValidationException)) { _configurationErrors.AddException(configurationOrValidationException); } else if (_remotionReflector.IsValidationException(configurationOrValidationException)) { _validationErrors.AddException(configurationOrValidationException); } else { throw; } } // MixinConfiguration is not valid return(null); }
public void GenerateXml_WithValidationLogNullObject() { var errorAggregator = new ErrorAggregator <Exception>(); var validationException1 = SetUpExceptionWithDummyStackTrace("test validation exception", new DefaultValidationLog()); errorAggregator.AddException(validationException1); var remotionReflectorStub = MockRepository.GenerateStub <IRemotionReflector>(); var reportGenerator = new ValidationErrorReportGenerator(errorAggregator, remotionReflectorStub); remotionReflectorStub.Stub(_ => _.GetValidationLogFromValidationException(null)).IgnoreArguments() .Return(new ReflectedObject(new ValidationLogNullObject())); var output = reportGenerator.GenerateXml(); var validationExceptionElement = new RecursiveExceptionReportGenerator(validationException1).GenerateXml(); validationExceptionElement.Add( new XElement( "ValidationLog", new XAttribute("number-of-rules-executed", 0), new XAttribute("number-of-failures", 0), new XAttribute("number-of-unexpected-exceptions", 0), new XAttribute("number-of-warnings", 0), new XAttribute("number-of-successes", 0))); var expectedOutput = new XElement("ValidationErrors", validationExceptionElement); Assert.That(output.ToString(), Is.EqualTo(expectedOutput.ToString())); }
public void GenerateXml_WithErrors() { var errorAggregator = new ErrorAggregator <Exception>(); var validationException1 = SetUpExceptionWithDummyStackTrace("test validation exception", new DefaultValidationLog()); errorAggregator.AddException(validationException1); var reportGenerator = new ValidationErrorReportGenerator(errorAggregator, Helpers.RemotionReflectorFactory.GetRemotionReflection()); var output = reportGenerator.GenerateXml(); var validationExceptionElement = new RecursiveExceptionReportGenerator(validationException1).GenerateXml(); validationExceptionElement.Add( new XElement("ValidationLog", new XAttribute("number-of-rules-executed", validationException1.ValidationLog.GetNumberOfRulesExecuted()), new XAttribute("number-of-failures", validationException1.ValidationLog.GetNumberOfFailures()), new XAttribute("number-of-unexpected-exceptions", validationException1.ValidationLog.GetNumberOfUnexpectedExceptions()), new XAttribute("number-of-warnings", validationException1.ValidationLog.GetNumberOfWarnings()), new XAttribute("number-of-successes", validationException1.ValidationLog.GetNumberOfSuccesses()) )); var expectedOutput = new XElement("ValidationErrors", validationExceptionElement); Assert.That(output.ToString(), Is.EqualTo(expectedOutput.ToString())); }
public void GenerateXml_WithErrors() { var errorAggregator = new ErrorAggregator <Exception>(); var innerException1 = SetUpExceptionWithDummyStackTrace("inner exception", null); var Exception1 = SetUpExceptionWithDummyStackTrace("test configuration exception 1", innerException1); var Exception2 = SetUpExceptionWithDummyStackTrace("test configuration excpetion 2", null); errorAggregator.AddException(Exception1); errorAggregator.AddException(Exception2); var reportGenerator = new ConfigurationErrorReportGenerator(errorAggregator); var output = reportGenerator.GenerateXml(); var expectedOutput = new XElement( "ConfigurationErrors", new RecursiveExceptionReportGenerator(Exception1).GenerateXml(), new RecursiveExceptionReportGenerator(Exception2).GenerateXml() ); Assert.That(output.ToString(), Is.EqualTo(expectedOutput.ToString())); }
public void GenerateXml_WithErrors() { var errorAggregator = new ErrorAggregator<Exception>(); var innerException1 = SetUpExceptionWithDummyStackTrace ("inner exception", null); var Exception1 = SetUpExceptionWithDummyStackTrace ("test configuration exception 1", innerException1); var Exception2 = SetUpExceptionWithDummyStackTrace ("test configuration excpetion 2", null); errorAggregator.AddException (Exception1); errorAggregator.AddException (Exception2); var reportGenerator = new ConfigurationErrorReportGenerator (errorAggregator); var output = reportGenerator.GenerateXml(); var expectedOutput = new XElement ( "ConfigurationErrors", new RecursiveExceptionReportGenerator (Exception1).GenerateXml(), new RecursiveExceptionReportGenerator (Exception2).GenerateXml() ); Assert.That (output.ToString(), Is.EqualTo (expectedOutput.ToString())); }