本文整理汇总了C#中BaseClient.Notify方法的典型用法代码示例。如果您正苦于以下问题:C# BaseClient.Notify方法的具体用法?C# BaseClient.Notify怎么用?C# BaseClient.Notify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseClient
的用法示例。
在下文中一共展示了BaseClient.Notify方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckBasicPropertiesOfNotifications
public void CheckBasicPropertiesOfNotifications(Exception exp)
{
// Arrange
var client = new BaseClient(StaticData.TestApiKey);
// Act
JObject json;
using (var server = new TestServer(client))
{
client.Notify(exp);
json = server.GetLastResponse();
}
// Assert
Assert.Equal(StaticData.TestApiKey, json["apiKey"]);
Assert.Equal(Notifier.Name, json["notifier"]["name"]);
Assert.Equal(Notifier.Version, json["notifier"]["version"]);
Assert.Equal(Notifier.Url.AbsoluteUri, json["notifier"]["url"]);
}
示例2: CheckInnerExceptionsAreNotified
public void CheckInnerExceptionsAreNotified()
{
// Arrange
var client = new BaseClient(StaticData.TestApiKey);
// Act
JObject json;
using (var server = new TestServer(client))
{
client.Notify(StaticData.TestInnerException);
json = server.GetLastResponse();
}
// Assert
Assert.Equal(StaticData.TestApiKey, json["apiKey"]);
Assert.Equal(3, json["events"][0]["exceptions"].Count());
Assert.Equal("ArithmeticException", json["events"][0]["exceptions"][0]["errorClass"]);
Assert.Equal("DivideByZeroException", json["events"][0]["exceptions"][1]["errorClass"]);
Assert.Equal("TypeAccessException", json["events"][0]["exceptions"][2]["errorClass"]);
}
示例3: CheckInnerExceptionsForBasicAggregateException
public void CheckInnerExceptionsForBasicAggregateException()
{
// Arrange
var client = new BaseClient(StaticData.TestApiKey);
AggregateException testAggregateException = null;
var task1 = Task.Factory.StartNew(() => { throw new FieldAccessException("Task 1 Exception"); });
var task2 = Task.Factory.StartNew(() => { throw new StackOverflowException("Task 2 Exception"); });
var task3 = Task.Factory.StartNew(() => { throw new AccessViolationException("Task 3 Exception"); });
try
{
Task.WaitAll(task1, task2, task3);
}
catch (AggregateException ae)
{
testAggregateException = ae;
}
// Act
JObject json;
using (var server = new TestServer(client))
{
client.Notify(testAggregateException);
json = server.GetLastResponse();
}
// Assert
Assert.Equal(StaticData.TestApiKey, json["apiKey"]);
Assert.Equal(1, json["events"].Count());
// Check that 3 events are created, each having the Aggregate exception as the root exception
var task1Exps = json["events"][0]["exceptions"].First(x => x["errorClass"].Value<string>() == "FieldAccessException");
var task2Exps = json["events"][0]["exceptions"].First(x => x["errorClass"].Value<string>() == "StackOverflowException");
var task3Exps = json["events"][0]["exceptions"].First(x => x["errorClass"].Value<string>() == "AccessViolationException");
Assert.Equal("AggregateException", json["events"][0]["exceptions"][0]["errorClass"]);
Assert.Equal("Task 1 Exception", task1Exps["message"]);
Assert.Equal("Task 2 Exception", task2Exps["message"]);
Assert.Equal("Task 3 Exception", task3Exps["message"]);
}
示例4: AddSimpleMetadataToANotifications
public void AddSimpleMetadataToANotifications()
{
// Arrange
var client = new BaseClient(StaticData.TestApiKey);
var testMetadata = new Metadata();
testMetadata.AddToTab("Test Tab 1", "Key 1", "Value 1");
testMetadata.AddToTab("Test Tab 1", "Key 2", "Value 2");
testMetadata.AddToTab("Test Tab 2", "Key 1", "Value 1");
// Act
JObject json;
using (var server = new TestServer(client))
{
client.Notify(StaticData.TestThrowException, testMetadata);
json = server.GetLastResponse();
}
// Assert
var actData = json["events"][0]["metaData"];
Assert.Equal("Value 1", actData["Test Tab 1"]["Key 1"]);
Assert.Equal("Value 2", actData["Test Tab 1"]["Key 2"]);
Assert.Equal("Value 1", actData["Test Tab 2"]["Key 1"]);
}
示例5: DefaultSeverityForManuallyNotifiedExceptionsIsWarning
public void DefaultSeverityForManuallyNotifiedExceptionsIsWarning()
{
// Arrange
var client = new BaseClient(StaticData.TestApiKey);
// Act
JObject json;
using (var server = new TestServer(client))
{
client.Notify(StaticData.TestThrowException);
json = server.GetLastResponse();
}
// Assert
Assert.Equal("warning", json["events"][0]["severity"]);
}
示例6: TestNoExceptionLeaks
public void TestNoExceptionLeaks()
{
// Arrange
var client = new BaseClient(StaticData.TestApiKey);
// Act
using (var server = new TestServer(client))
{
server.Stop();
try
{
client.Notify(StaticData.TestThrowException);
}
catch (Exception e)
{
// Assert
Assert.True(false, "No network shouldn't throw: " + e.ToString());
}
}
}
示例7: SeveritySetManuallyIsUsedInTheNotification
public void SeveritySetManuallyIsUsedInTheNotification(Severity severity, string expJsonString)
{
// Arrange
var client = new BaseClient(StaticData.TestApiKey);
// Act
JObject json;
using (var server = new TestServer(client))
{
client.Notify(StaticData.TestThrowException, severity);
json = server.GetLastResponse();
}
// Assert
Assert.Equal(expJsonString, json["events"][0]["severity"]);
}
示例8: CheckCallStacksAreReportedCorrectly
public void CheckCallStacksAreReportedCorrectly()
{
// Arrange
var client = new BaseClient(StaticData.TestApiKey);
// Act
JObject json;
using (var server = new TestServer(client))
{
client.Notify(StaticData.TestCallStackException);
json = server.GetLastResponse();
}
// Assert
Assert.Equal(StaticData.TestApiKey, json["apiKey"]);
var traceJson = json["events"][0]["exceptions"][0]["stacktrace"];
Assert.Equal(3, traceJson.Count());
Assert.Equal("TestNamespace.ClassGamma.ThrowException()", traceJson[0]["method"]);
Assert.Equal("TestNamespace.ClassBeta.ThrowException()", traceJson[1]["method"]);
Assert.Equal("TestNamespace.ClassAlpha.ThrowException()", traceJson[2]["method"]);
}