public static void AddData(object obj, string objectName, IEnumerable <FieldInfo> fields) { var item = new ObjectPackage(objectName); foreach (var field in fields) { item.Data.Add(new ObjectData(field.Name, field.GetValue(obj).ToString())); } _data.Add(item); }
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(); } }