本文整理汇总了C#中ErrorLog.GetErrors方法的典型用法代码示例。如果您正苦于以下问题:C# ErrorLog.GetErrors方法的具体用法?C# ErrorLog.GetErrors怎么用?C# ErrorLog.GetErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorLog
的用法示例。
在下文中一共展示了ErrorLog.GetErrors方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanGetErrors
public void CanGetErrors()
{
// Arrange
var message1 = _fixture.Create<Message>();
var message2 = _fixture.Create<Message>();
var pageIndex = _fixture.Create<int>();
var pageSize = _fixture.Create<int>();
var messages = new MessagesResult()
{
Total = 3,
Messages = new List<Message> { message1, message2, }
};
var results = new ArrayList();
var loggerMock = new Mock<ILogger>();
var taskCompletionSource = new TaskCompletionSource<MessagesResult>(results);
taskCompletionSource.SetResult(messages);
loggerMock
.Setup(x => x.BeginGetMessages(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<AsyncCallback>(), It.IsAny<object>()))
.Returns(taskCompletionSource.Task);
var errorLog = new ErrorLog(loggerMock.Object);
// Act
var count = errorLog.GetErrors(pageIndex, pageSize, results);
// Assert
Assert.That(count, Is.EqualTo(3));
Assert.That(results, Is.Not.Null);
Assert.That(results.Count, Is.EqualTo(2));
}
示例2: CanGetErrors
public void CanGetErrors()
{
var pageIndex = _fixture.Create<int>();
var pageSize = _fixture.Create<int>();
var logId = _fixture.Create<Guid>().ToString();
var errors = new {
Total = 3,
Errors = new[]
{
new { Id = _fixture.Create<string>(), ErrorXml },
new { Id = _fixture.Create<string>(), ErrorXml },
new { Id = _fixture.Create<string>(), 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(errors)));
var errorLog = new ErrorLog(new Hashtable { { "LogId", logId } }, webClientMock.Object);
var results = new ArrayList();
var count = errorLog.GetErrors(pageIndex, pageSize, results);
Assert.That(actualUri.AbsoluteUri, Is.Not.Null.And.StringEnding(string.Format("api/errors?logId={0}&pageindex={1}&pagesize={2}", logId, pageIndex, pageSize)));
Assert.That(count, Is.EqualTo(3));
Assert.That(results, Is.Not.Null);
Assert.That(results.Count, Is.EqualTo(3));
}