public PublishedProvidersController(IProviderFundingPublishingService providerFundingPublishingService,
                                            IPublishedProviderStatusService publishedProviderStatusService,
                                            IPublishedProviderVersionService publishedProviderVersionService,
                                            IPublishedProviderFundingService publishedProviderFundingService,
                                            IPublishedProviderFundingStructureService publishedProviderFundingStructureService,
                                            IDeletePublishedProvidersService deletePublishedProvidersService,
                                            IPublishedProviderUpdateDateService publishedProviderUpdateDateService,
                                            IFeatureToggle featureToggle)
        {
            Guard.ArgumentNotNull(providerFundingPublishingService, nameof(providerFundingPublishingService));
            Guard.ArgumentNotNull(publishedProviderStatusService, nameof(publishedProviderStatusService));
            Guard.ArgumentNotNull(publishedProviderVersionService, nameof(publishedProviderVersionService));
            Guard.ArgumentNotNull(publishedProviderFundingService, nameof(publishedProviderFundingService));
            Guard.ArgumentNotNull(publishedProviderFundingStructureService, nameof(publishedProviderFundingStructureService));
            Guard.ArgumentNotNull(deletePublishedProvidersService, nameof(deletePublishedProvidersService));
            Guard.ArgumentNotNull(publishedProviderUpdateDateService, nameof(publishedProviderUpdateDateService));
            Guard.ArgumentNotNull(featureToggle, nameof(featureToggle));

            _providerFundingPublishingService         = providerFundingPublishingService;
            _publishedProviderStatusService           = publishedProviderStatusService;
            _publishedProviderVersionService          = publishedProviderVersionService;
            _publishedProviderFundingService          = publishedProviderFundingService;
            _publishedProviderFundingStructureService = publishedProviderFundingStructureService;
            _deletePublishedProvidersService          = deletePublishedProvidersService;
            _publishedProviderUpdateDateService       = publishedProviderUpdateDateService;
            _featureToggle = featureToggle;
        }
Пример #2
0
        public void SetUp()
        {
            _providerFundingPublishingService         = Substitute.For <IProviderFundingPublishingService>();
            _publishedProviderStatusService           = Substitute.For <IPublishedProviderStatusService>();
            _publishedProviderVersionService          = Substitute.For <IPublishedProviderVersionService>();
            _publishedProviderFundingService          = Substitute.For <IPublishedProviderFundingService>();
            _publishedProviderFundingStructureService = Substitute.For <IPublishedProviderFundingStructureService>();
            _deletePublishedProvidersService          = Substitute.For <IDeletePublishedProvidersService>();

            _featureToggle = Substitute.For <IFeatureToggle>();

            _controller = new PublishedProvidersController(
                _providerFundingPublishingService,
                _publishedProviderStatusService,
                _publishedProviderVersionService,
                _publishedProviderFundingService,
                _publishedProviderFundingStructureService,
                _deletePublishedProvidersService,
                new Mock <IPublishedProviderUpdateDateService>().Object,
                _featureToggle
                );


            _fundingStreamId = NewRandomString();
            _fundPeriodId    = NewRandomString();
            _correlationId   = NewRandomString();
            _userId          = NewRandomString();
            _userName        = NewRandomString();

            HttpContext     context         = Substitute.For <HttpContext>();
            HttpRequest     request         = Substitute.For <HttpRequest>();
            ClaimsPrincipal claimsPrincipal = new ClaimsPrincipal(new ClaimsIdentity(new[]
            {
                new Claim(ClaimTypes.Sid, _userId),
                new Claim(ClaimTypes.Name, _userName)
            }));

            context.Request.Returns(request);
            request.HttpContext.Returns(context);
            context.User.Returns(claimsPrincipal);

            _controller.ControllerContext = new ControllerContext
            {
                HttpContext = context
            };

            request.Headers.Returns(new HeaderDictionary(new Dictionary <string, StringValues>
            {
                { "sfa-correlationId", new StringValues(_correlationId) }
            }));
        }