コード例 #1
0
        public void It_Should_Read_Errors_Async()
        {
            var initialLogMessages   = new LogMessageV1[] { Model.SampleMessage1, Model.SampleErrorMessage1 };
            var initialErrorMessages = initialLogMessages.Where(m => m.Level <= LogLevel.Error).ToArray();

            var filter = new FilterParams();

            filter.SetAsObject("errors_only", true);

            _moqLoggingPersistence.Setup(p => p.GetPageByFilterAsync(Model.CorrelationId, filter, null)).Returns(Task.FromResult(initialErrorMessages));
            _moqLoggingPersistence.Setup(p => p.GetPageByFilterAsync(Model.CorrelationId, null, null)).Returns(Task.FromResult(initialLogMessages));

            var resultLogMessages = _loggingController.ReadErrorsAsync(Model.CorrelationId, null, null).Result;

            Assert.Equal(initialErrorMessages.Length, resultLogMessages.Length);
        }