コード例 #1
0
        public async Task GetAll_InvalidFrom_Todates_ReturnsBadRequest(string fromUtc, string toUtc)
        {
            var l    = new Mock <ILogger <LogRecordController> >();
            var ctrl = new LogRecordController(null, l.Object);

            var res = await ctrl.GetAll(fromUtc : fromUtc, toUtc : toUtc);

            res.ShouldBeOfType <BadRequestResult>();
        }
コード例 #2
0
        public async Task GetAll_UnknownLogRecordType_ReturnsBadRequest(string LogRecordTypes)
        {
            var l    = new Mock <ILogger <LogRecordController> >();
            var ctrl = new LogRecordController(null, l.Object);

            var res = await ctrl.GetAll(logLevels : LogRecordTypes);

            res.ShouldBeOfType <BadRequestResult>();
        }
コード例 #3
0
        public async Task GetAll_ReturnsPage()
        {
            var page = new LogRecordPagination
            {
                Data = new[]
                {
                    new LogRecord {
                        Id = "a"
                    },
                    new LogRecord {
                        Id = "b"
                    },
                    new LogRecord {
                        Id = "c"
                    },
                    new LogRecord {
                        Id = "d"
                    },
                }
            };
            var lm = new Mock <ILogRecordManager>();

            lm.Setup(c => c.GetAll(It.IsAny <LogRecordPagination>()))
            .ReturnsAsync(page);

            var l    = new Mock <ILogger <LogRecordController> >();
            var ctrl = new LogRecordController(lm.Object, l.Object);

            var res = await ctrl.GetAll(logLevels : LogRecordLevel.Information);

            var ok = res.ShouldBeOfType <OkObjectResult>();
            var v  = ok.Value as LogRecordPagination;

            v.Data.Count().ShouldBe(page.Data.Count());
            for (int i = 0; i < v.Data.Count(); i++)
            {
                page.Data.ShouldContain(x => x.Id == v.Data.ElementAt(i).Id);
            }
        }