本文整理汇总了C#中ErrorLog.GetError方法的典型用法代码示例。如果您正苦于以下问题:C# ErrorLog.GetError方法的具体用法?C# ErrorLog.GetError怎么用?C# ErrorLog.GetError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorLog
的用法示例。
在下文中一共展示了ErrorLog.GetError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanGetError
public void CanGetError()
{
// Arrange
var id = _fixture.Create<string>();
var logMessage = _fixture.Create<string>();
var loggerMock = new Mock<ILogger>();
loggerMock
.Setup(x => x.BeginGetMessage(It.IsAny<string>(), It.IsAny<AsyncCallback>(), It.IsAny<object>()))
.Returns(Task.FromResult(new Message(logMessage) {Id = id}));
var errorLog = new ErrorLog(loggerMock.Object);
// Act
var result = errorLog.GetError(id);
// Assert
Assert.That(result, Is.Not.Null);
Assert.That(result.Error, Is.Not.Null);
Assert.That(result.Error.Message, Is.EqualTo(logMessage));
}
示例2: CanGetError
public void CanGetError()
{
var id = _fixture.Create<string>();
var logId = _fixture.Create<Guid>().ToString();
var error = new { Id = id, ErrorXml };
Uri actualUri = null;
var webClientMock = new Mock<IWebClient>();
webClientMock
.Setup(x => x.Get(It.IsAny<WebHeaderCollection>(), It.IsAny<Uri>(), It.IsAny<Func<WebHeaderCollection, string, string>>()))
.Callback<WebHeaderCollection, Uri, Func<WebHeaderCollection, string, string>>((headers, uri, resultor) => { actualUri = uri; })
.Returns(Task.FromResult(JsonConvert.SerializeObject(error)));
var errorLog = new ErrorLog(new Hashtable { { "LogId", logId } }, webClientMock.Object);
var result = errorLog.GetError(id);
Assert.That(result, Is.Not.Null);
Assert.That(actualUri.AbsoluteUri, Is.Not.Null.And.StringEnding(string.Format("api/errors?logId={1}&id={0}", id, logId)));
Assert.That(result, Is.Not.Null);
Assert.That(result.Error, Is.Not.Null);
Assert.That(result.Error.Type, Is.EqualTo("System.ApplicationException"));
}