public override void Given()
        {
            BulkResultResponse = new BulkResultResponse
            {
                IsSuccess           = false,
                BlobUniqueReference = BlobUniqueReference,
                ErrorFileSize       = 1.5
            };

            UploadResultsRequestViewModel = new UploadResultsRequestViewModel {
                AoUkprn = Ukprn, File = FormFile
            };

            UploadResultsResponseViewModel = new UploadResultsResponseViewModel
            {
                IsSuccess           = false,
                BlobUniqueReference = BlobUniqueReference,
                ErrorFileSize       = 1.5
            };

            Mapper.Map <BulkProcessRequest>(UploadResultsRequestViewModel).Returns(BulkResultRequest);
            Mapper.Map <UploadResultsResponseViewModel>(BulkResultResponse).Returns(UploadResultsResponseViewModel);
            InternalApiClient.ProcessBulkResultsAsync(BulkResultRequest).Returns(BulkResultResponse);
            Loader = new ResultLoader(Mapper, Logger, InternalApiClient, BlobStorageService);
        }
        public override void Setup()
        {
            HttpContextAccessor = Substitute.For <IHttpContextAccessor>();
            ResultLoader        = Substitute.For <IResultLoader>();
            CacheService        = Substitute.For <ICacheService>();
            Logger     = Substitute.For <ILogger <ResultController> >();
            Controller = new ResultController(ResultLoader, CacheService, Logger);

            AoUkprn = 1234567890;

            ViewModel = new ManageCoreResultViewModel
            {
                ProfileId         = 1,
                ResultId          = 11,
                SelectedGradeCode = "PCG1"
            };

            var httpContext = new ClaimsIdentityBuilder <ResultController>(Controller)
                              .Add(CustomClaimTypes.Ukprn, AoUkprn.ToString())
                              .Add(CustomClaimTypes.UserId, Guid.NewGuid().ToString())
                              .Build()
                              .HttpContext;

            HttpContextAccessor.HttpContext.Returns(httpContext);
            CacheKey   = CacheKeyHelper.GetCacheKey(httpContext.User.GetUserId(), CacheConstants.ResultCacheKey);
            MockResult = new ChangeResultResponse();
        }
        public override void Setup()
        {
            ResultLoader = Substitute.For <IResultLoader>();
            CacheService = Substitute.For <ICacheService>();
            Logger       = Substitute.For <ILogger <ResultController> >();

            Controller = new ResultController(ResultLoader, CacheService, Logger);
        }
Beispiel #4
0
        public override void Setup()
        {
            HttpContextAccessor = Substitute.For <IHttpContextAccessor>();
            ResultLoader        = Substitute.For <IResultLoader>();
            CacheService        = Substitute.For <ICacheService>();
            Logger     = Substitute.For <ILogger <ResultController> >();
            Controller = new ResultController(ResultLoader, CacheService, Logger);

            Ukprn = 1234567890;
            var httpContext = new ClaimsIdentityBuilder <ResultController>(Controller)
                              .Add(CustomClaimTypes.Ukprn, Ukprn.ToString())
                              .Add(CustomClaimTypes.UserId, Guid.NewGuid().ToString())
                              .Build()
                              .HttpContext;

            HttpContextAccessor.HttpContext.Returns(httpContext);
        }
        public override void Setup()
        {
            Ukprn = 12345;
            HttpContextAccessor = Substitute.For <IHttpContextAccessor>();
            CacheService        = Substitute.For <ICacheService>();
            Logger       = Substitute.For <ILogger <ResultController> >();
            ResultLoader = Substitute.For <IResultLoader>();
            Controller   = new ResultController(ResultLoader, CacheService, Logger);

            var httpContext = new ClaimsIdentityBuilder <ResultController>(Controller)
                              .Add(CustomClaimTypes.Ukprn, Ukprn.ToString())
                              .Build()
                              .HttpContext;

            HttpContextAccessor.HttpContext.Returns(httpContext);
            TempData            = new TempDataDictionary(HttpContextAccessor.HttpContext, Substitute.For <ITempDataProvider>());
            Controller.TempData = TempData;
        }
        public override void Setup()
        {
            Ukprn = 12345;
            HttpContextAccessor = Substitute.For <IHttpContextAccessor>();
            Logger       = Substitute.For <ILogger <ResultController> >();
            ResultLoader = Substitute.For <IResultLoader>();
            CacheService = Substitute.For <ICacheService>();
            Controller   = new ResultController(ResultLoader, CacheService, Logger);

            var httpContext = new ClaimsIdentityBuilder <ResultController>(Controller)
                              .Add(CustomClaimTypes.Ukprn, Ukprn.ToString())
                              .Add(CustomClaimTypes.UserId, Guid.NewGuid().ToString())
                              .Build()
                              .HttpContext;

            HttpContextAccessor.HttpContext.Returns(httpContext);
            CacheKey = string.Concat(CacheKeyHelper.GetCacheKey(httpContext.User.GetUserId(), CacheConstants.ResultCacheKey), Common.Helpers.Constants.ResultsUploadSuccessfulViewModel);
        }
Beispiel #7
0
        public override void Setup()
        {
            Ukprn = 12345;
            HttpContextAccessor = Substitute.For <IHttpContextAccessor>();
            ResultLoader        = Substitute.For <IResultLoader>();
            CacheService        = Substitute.For <ICacheService>();
            Logger = Substitute.For <ILogger <ResultController> >();

            Controller = new ResultController(ResultLoader, CacheService, Logger);
            ViewModel  = new UploadResultsRequestViewModel();

            var httpContext = new ClaimsIdentityBuilder <ResultController>(Controller)
                              .Add(CustomClaimTypes.Ukprn, Ukprn.ToString())
                              .Build()
                              .HttpContext;

            HttpContextAccessor.HttpContext.Returns(httpContext);
        }
Beispiel #8
0
        public override void Setup()
        {
            Ukprn = 123456789;
            HttpContextAccessor = Substitute.For <IHttpContextAccessor>();
            Logger       = Substitute.For <ILogger <ResultController> >();
            ResultLoader = Substitute.For <IResultLoader>();
            CacheService = Substitute.For <ICacheService>();

            Controller = new ResultController(ResultLoader, CacheService, Logger);

            var httpContext = new ClaimsIdentityBuilder <ResultController>(Controller)
                              .Add(CustomClaimTypes.Ukprn, Ukprn.ToString())
                              .Build()
                              .HttpContext;

            HttpContextAccessor.HttpContext.Returns(httpContext);
            ResultLoader.GetResultValidationErrorsFileAsync(Ukprn, BlobUniqueReference).Returns(new MemoryStream(Encoding.ASCII.GetBytes("Test File for validation errors")));
        }
Beispiel #9
0
        public override void Given()
        {
            BlobUniqueReference = Guid.NewGuid();
            ApiResponse         = new DocumentUploadHistoryDetails
            {
                AoUkprn             = Ukprn,
                BlobFileName        = BlobFileName,
                BlobUniqueReference = BlobUniqueReference,
                DocumentType        = (int)DocumentType.Results,
                FileType            = (int)FileType.Csv,
                Status    = (int)DocumentUploadStatus.Failed,
                CreatedBy = $"{Givenname} {Surname}"
            };

            InternalApiClient.GetDocumentUploadHistoryDetailsAsync(Ukprn, BlobUniqueReference).Returns(ApiResponse);
            BlobStorageService.DownloadFileAsync(Arg.Any <BlobStorageData>()).Returns(new MemoryStream(Encoding.ASCII.GetBytes("Test File")));
            Loader = new ResultLoader(Mapper, Logger, InternalApiClient, BlobStorageService);
        }
        public override void Setup()
        {
            HttpContextAccessor = Substitute.For <IHttpContextAccessor>();
            ResultLoader        = Substitute.For <IResultLoader>();
            CacheService        = Substitute.For <ICacheService>();
            Logger     = Substitute.For <ILogger <ResultController> >();
            Controller = new ResultController(ResultLoader, CacheService, Logger);

            ProfileId    = 1;
            AssessmentId = 11;
            AoUkprn      = 1234567890;
            var httpContext = new ClaimsIdentityBuilder <ResultController>(Controller)
                              .Add(CustomClaimTypes.Ukprn, AoUkprn.ToString())
                              .Add(CustomClaimTypes.UserId, Guid.NewGuid().ToString())
                              .Build()
                              .HttpContext;

            HttpContextAccessor.HttpContext.Returns(httpContext);
            CacheKey = CacheKeyHelper.GetCacheKey(httpContext.User.GetUserId(), CacheConstants.ResultCacheKey);
        }
 public ResultController(IResultLoader resultLoader, ICacheService cacheService, ILogger <ResultController> logger)
 {
     _resultLoader = resultLoader;
     _cacheService = cacheService;
     _logger       = logger;
 }
Beispiel #12
0
 public override void Setup()
 {
     ResultLoader = Substitute.For <IResultLoader>();
     Controller   = new ResultController(ResultLoader, CacheService, Logger);
     ViewModel    = new UploadResultsRequestViewModel();
 }