public void RethrowConfigOptionWorks() { this.Reset(); RollbarConfig config = this.ProvideLiveRollbarConfig() as RollbarConfig; using (IRollbar rollbar = this.ProvideDisposableRollbar()) { rollbar.Configure(config); this.IncrementCount <CommunicationEventArgs>(); rollbar.Critical(ExceptionSimulator.GetExceptionWith(5, "Exception logged async!")); this.IncrementCount <CommunicationEventArgs>(); rollbar.AsBlockingLogger(TimeSpan.FromSeconds(3)) .Critical(ExceptionSimulator.GetExceptionWith(5, "Exception logged sync!")); int rethrowCount = 0; config.RethrowExceptionsAfterReporting = true; rollbar.Configure(config); try { this.IncrementCount <CommunicationEventArgs>(); rollbar.Critical(ExceptionSimulator.GetExceptionWith(5, "Exception logged async with rethrow!")); } catch { rethrowCount++; } try { this.IncrementCount <CommunicationEventArgs>(); rollbar.AsBlockingLogger(TimeSpan.FromSeconds(3)) .Critical(ExceptionSimulator.GetExceptionWith(5, "Exception logged sync with rethrow!")); } catch { rethrowCount++; } config.RethrowExceptionsAfterReporting = false; rollbar.Configure(config); this.IncrementCount <CommunicationEventArgs>(); rollbar.Critical(ExceptionSimulator.GetExceptionWith(5, "Exception logged async!")); this.IncrementCount <CommunicationEventArgs>(); rollbar.AsBlockingLogger(TimeSpan.FromSeconds(3)) .Critical(ExceptionSimulator.GetExceptionWith(5, "Exception logged sync!")); Assert.AreEqual(2, rethrowCount, "matching total of rethrows..."); } }
public void ExceptionObjectPackageTest() { const int totalExceptionFrames = 5; System.Exception exceptionObj = ExceptionSimulator.GetExceptionWith(totalExceptionFrames); IRollbarPackage package = new ObjectPackage(exceptionObj, true); Assert.IsTrue(package.MustApplySynchronously); Assert.IsNull(package.RollbarData); var rollbarData = package.PackageAsRollbarData(); Assert.AreSame(rollbarData, package.RollbarData); //TODO: compare more relevant data DTO properties to exceptionObj.... }
public void BasicPayloadBundleTest() { const int totalExceptionFrames = 5; System.Exception exceptionObj = ExceptionSimulator.GetExceptionWith(totalExceptionFrames); IRollbarPackage package = new ObjectPackage(exceptionObj, true); Assert.IsTrue(package.MustApplySynchronously); Assert.IsNull(package.RollbarData); //var rollbarData = package.PackageAsRollbarData(); //Assert.AreSame(rollbarData, package.RollbarData); RollbarConfig config = new RollbarConfig("ACCESS_TOKEN") { Environment = "ENV", }; PayloadBundle bundle = new PayloadBundle(config, package, ErrorLevel.Critical); var payload = bundle.GetPayload(); }
public void BasicPayloadBundleTest() { const int totalExceptionFrames = 5; System.Exception exceptionObj = ExceptionSimulator.GetExceptionWith(totalExceptionFrames); IRollbarPackage package = new ObjectPackage(exceptionObj, true); Assert.IsTrue(package.MustApplySynchronously); Assert.IsNull(package.RollbarData); //var rollbarData = package.PackageAsRollbarData(); //Assert.AreSame(rollbarData, package.RollbarData); RollbarDestinationOptions destinationOptions = new RollbarDestinationOptions("ACCESS_TOKEN", "ENV"); IRollbarLoggerConfig config = infrastructureConfig.RollbarLoggerConfig; config.RollbarDestinationOptions.Reconfigure(destinationOptions); using (IRollbar rollbarLogger = RollbarFactory.CreateNew(config)) { PayloadBundle bundle = new PayloadBundle(rollbarLogger as RollbarLogger, package, ErrorLevel.Critical); var payload = bundle.GetPayload(); } }