public void Crash_report_works_correctly() {
     var rollbarBody = new RollbarBody("Crash happened");
     var json = JsonConvert.SerializeObject(rollbarBody);
     Assert.Equal("{\"crash_report\":{\"raw\":\"Crash happened\"}}", json);
     Assert.DoesNotContain("\"trace\":{", json);
     Assert.DoesNotContain("\"trace_chain\":{", json);
     Assert.DoesNotContain("\"message\":{", json);
 }
 public void Trace_works_correctly() {
     var rollbarBody = new RollbarBody(GetException());
     var json = JsonConvert.SerializeObject(rollbarBody);
     Assert.Contains("\"trace\":{", json);
     Assert.Contains("\"Rollbar.Test.RollbarBodyFixture.GetException()\"", json);
     Assert.DoesNotContain("\"crash_report\":{", json);
     Assert.DoesNotContain("\"trace_chain\":{", json);
     Assert.DoesNotContain("\"message\":{", json);
 }
 public void Message_works_correctly() {
     var rollbarBody = new RollbarBody(new RollbarMessage("Body of the message") {
         {"key", "value"}
     });
     var json = JsonConvert.SerializeObject(rollbarBody);
     Assert.Contains("{\"message\":{", json);
     Assert.Contains("\"Body of the message\"", json);
     Assert.Contains("\"key\":\"value\"", json);
     Assert.DoesNotContain("\"trace\":{", json);
     Assert.DoesNotContain("\"trace_chain\":{", json);
     Assert.DoesNotContain("\"crash_report\":{", json);
 }
示例#4
0
 public RollbarData(string environment, RollbarBody body) {
     if (string.IsNullOrWhiteSpace(environment)) {
         throw new ArgumentNullException("environment");
     }
     if (body == null) {
         throw new ArgumentNullException("body");
     }
     Environment = environment;
     Body = body;
     Timestamp = (long) DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
     Platform = DefaultPlatform;
     Language = DefaultLanguage;
 }
 public void Crash_report_cannot_be_whitespace() {
     Assert.Throws<ArgumentNullException>(() => {
         var rb = new RollbarBody("    \t\n");
     });
 }
 public void Crash_report_cannot_be_null() {
     Assert.Throws<ArgumentNullException>(() => {
         var rb = new RollbarBody((string) null);
     });
 }
 public void Message_cannot_be_null() {
     Assert.Throws<ArgumentNullException>(() => {
         var rb = new RollbarBody((RollbarMessage) null);
     });
 }
 public void Exceptions_cannot_be_empty() {
     Assert.Throws<ArgumentException>(() => {
         var rb = new RollbarBody(new Exception[0]);
     });
 }
 public void Exceptions_cannot_be_null() {
     Assert.Throws<ArgumentNullException>(() => {
         var rb = new RollbarBody((IEnumerable<Exception>) null);
     });
 }