当前位置: 首页>>代码示例>>C#>>正文


C# ErrorLog.GetErrors方法代码示例

本文整理汇总了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));
        }
开发者ID:kodofish,项目名称:elmah.io,代码行数:32,代码来源:ErrorLogCoreElmahMethodsTest.cs

示例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));
        }
开发者ID:nordineb,项目名称:elmah.io,代码行数:32,代码来源:ErrorLogCoreElmahMethodsTest.cs


注:本文中的ErrorLog.GetErrors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。