private QCController CreateRequest(HttpMethod Method) { QCController repositoryTypesController; using (ShimsContext.Create()) { ShimIdentityHelper.GetCurrentUserIUserServiceClaimsPrincipal = (us, cp) => new User(); repositoryTypesController = new QCController(qcService, null, null); } repositoryTypesController.Request = new HttpRequestMessage(Method, string.Empty); repositoryTypesController.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = new HttpConfiguration(); return repositoryTypesController; }
public async Task GetQualityCheckRulesAndFileSheets_ShouldReturnHttpStatusCodeOK_WhenFileServiceReturnsAXlsxFile() { IFileService fileService = new StubIFileService() { GetFileByFileIdInt32 = (fileId) => new File() { Name = "abc.xlsx" }, GetDocumentSheetDetailsFile = (file) => Task.FromResult<IEnumerable<FileSheet>>(null) }; IFileServiceFactory fileServiceFactory = new StubIFileServiceFactory() { GetFileServiceString = instanceName => fileService }; IQCService qcService = new StubIQCService(); using (ShimsContext.Create()) { ShimIdentityHelper.GetCurrentUserIUserServiceClaimsPrincipal = (service, principle) => new User(); QCController fileController = new QCController(qcService, fileServiceFactory, null); fileController.Request = new HttpRequestMessage(HttpMethod.Get, string.Empty); fileController.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = new HttpConfiguration(); HttpResponseMessage httpResponseMessage = await fileController.GetQualityCheckRulesAndFileSheets(0); Assert.AreEqual(HttpStatusCode.OK, httpResponseMessage.StatusCode); } }
public async Task GetQualityCheckIssues_ShouldReturnHttpStatusCodeOK() { IQCService qcService = new StubIQCService() { GetQualityCheckIssuesInt32Int32String = (fileId, qualityCheckId, sheetIds) => Task.FromResult(Enumerable.Empty<QualityCheckResult>()) }; using (ShimsContext.Create()) { ShimIdentityHelper.GetCurrentUserIUserServiceClaimsPrincipal = (service, principle) => new User(); QCController fileController = new QCController(qcService, null, null); fileController.Request = new HttpRequestMessage(HttpMethod.Get, string.Empty); fileController.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = new HttpConfiguration(); HttpResponseMessage httpResponseMessage = await fileController.GetQualityCheckIssues(0, 0, string.Empty); Assert.AreEqual(HttpStatusCode.OK, httpResponseMessage.StatusCode); } }
public async Task GetQualityCheckRulesAndFileSheets_ShouldReturnHttpStatusCodeNotImplemented_WhenFileServiceReturnsAFileOtherThanXlsxAndCsv() { IFileService fileService = new StubIFileService() { GetFileByFileIdInt32 = (fileId) => new File() { Name = "abc.xyz" } }; IFileServiceFactory fileServiceFactory = new StubIFileServiceFactory() { GetFileServiceString = instanceName => fileService }; using (ShimsContext.Create()) { ShimIdentityHelper.GetCurrentUserIUserServiceClaimsPrincipal = (service, principle) => new User(); QCController fileController = new QCController(null, fileServiceFactory, null); fileController.Request = new HttpRequestMessage(HttpMethod.Get, string.Empty); fileController.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = new HttpConfiguration(); HttpResponseMessage httpResponseMessage = await fileController.GetQualityCheckRulesAndFileSheets(0); Assert.AreEqual(HttpStatusCode.NotImplemented, httpResponseMessage.StatusCode); } }