Esempio n. 1
0
        public async Task GetAll_InvalidFrom_Todates_ReturnsBadRequest(string fromUtc, string toUtc)
        {
            var l    = new Mock <ILogger <AuditController> >();
            var ctrl = new AuditController(null, l.Object, null, null);

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

            res.ShouldBeOfType <BadRequestResult>();
        }
Esempio n. 2
0
        public async Task GetAll_UnknownAuditRecordType_ReturnsBadRequest(string auditRecordTypes)
        {
            var l  = new Mock <ILogger <AuditController> >();
            var wc = new WorkContext {
                CurrentClientId = "1232"
            };
            var ctrl = new AuditController(null, l.Object, wc, null);

            var res = await ctrl.GetAll(auditRecordTypes : auditRecordTypes);

            res.ShouldBeOfType <BadRequestResult>();
        }
Esempio n. 3
0
        public async Task GetAll_ReturnsPage()
        {
            var page = new AuditPagination
            {
                Data = new[]
                {
                    new AuditRecord {
                        Id = "a"
                    },
                    new AuditRecord {
                        Id = "b"
                    },
                    new AuditRecord {
                        Id = "c"
                    },
                    new AuditRecord {
                        Id = "d"
                    },
                }
            };
            var aSrv = new Mock <IAuditManager>();

            aSrv.Setup(c => c.GetAll(It.IsAny <AuditPagination>()))
            .ReturnsAsync(new ServiceResponse <AuditPagination> {
                Payload = page, Result = ServiceResult.Ok
            });

            var l  = new Mock <ILogger <AuditController> >();
            var rm = new Mock <IServiceResponseMapper>();
            ServiceResponse <AuditPagination> srvRes = null;

            rm.Setup(r => r.MapServiceResponse(
                         It.Is <Type>(t => t == typeof(AuditPaginationModel)),
                         It.IsAny <ServiceResponse>()))
            .Returns(new OkResult())
            .Callback <Type, ServiceResponse>((t2, s) => srvRes = s as ServiceResponse <AuditPagination>);
            var wc = new WorkContext {
                CurrentClientId = "1232"
            };
            var ctrl = new AuditController(aSrv.Object, l.Object, wc, rm.Object);

            var res = await ctrl.GetAll(auditRecordTypes : AuditRecordTypes.CREATE);

            srvRes.Payload.ShouldBe(page);
        }