public async Task RunAsyncMethod(string since) { // preparation var config = new Mock <IConfiguration>(); var tekExportRepo = new Mock <ITemporaryExposureKeyExportRepository>(); var validationServer = new Mock <IValidationServerService>(); validationServer.Setup(_ => _.Validate(It.IsAny <HttpRequest>())).Returns(IValidationServerService.ValidateResult.Success); var resultModels = new List <TemporaryExposureKeyExportModel>(); for (var i = 0; i < 50; i++) { resultModels.Add(new TemporaryExposureKeyExportModel()); } tekExportRepo.Setup(_ => _.GetKeysAsync(It.IsAny <ulong>())) .ReturnsAsync(resultModels.ToArray()); var logger = new Mock.LoggerMock <TemporaryExposureKeysApi>(); var temporaryExposureKeysApi = new TemporaryExposureKeysApi(config.Object, tekExportRepo.Object, validationServer.Object, logger); var context = new Mock <HttpContext>(); var q = new Mock <IQueryCollection>(); q.SetupGet(_ => _["since"]).Returns(since); context.Setup(_ => _.Request.Query).Returns(q.Object); // action await temporaryExposureKeysApi.RunAsync(context.Object.Request); // assert }
public async Task RunAsyncMethodWithNull() { // preparation var config = new Mock <IConfiguration>(); var tekExportRepo = new Mock <ITemporaryExposureKeyExportRepository>(); var resultModels = new List <TemporaryExposureKeyExportModel>(); tekExportRepo.Setup(_ => _.GetKeysAsync(It.IsAny <ulong>())).ReturnsAsync(resultModels.ToArray()); var logger = new Mock.LoggerMock <TemporaryExposureKeysApi>(); var temporaryExposureKeysApi = new TemporaryExposureKeysApi(config.Object, tekExportRepo.Object, logger); var context = new Mock.HttpContextMock(); context._Request.Query = null; // action await temporaryExposureKeysApi.RunAsync(context.Request); // assert }