示例#1
0
        public void EstablishContext()
        {
            this.ProductionTriggerLevelService = Substitute.For <IProductionTriggerLevelsService>();
            this.PtlSettingsFacadeService      = Substitute.For <ISingleRecordFacadeService <PtlSettings, PtlSettingsResource> >();
            this.AuthorisationService          = Substitute.For <IAuthorisationService>();
            this.TriggerRunDispatcher          = Substitute.For <ITriggerRunDispatcher>();

            var bootstrapper = new ConfigurableBootstrapper(
                with =>
            {
                with.Dependency(this.ProductionTriggerLevelService);
                with.Dependency(this.PtlSettingsFacadeService);
                with.Dependency(this.AuthorisationService);
                with.Dependency(this.TriggerRunDispatcher);
                with.Dependency <IResourceBuilder <Error> >(new ErrorResourceBuilder());
                with.Dependency <IResourceBuilder <ResponseModel <PtlSettings> > >(new PtlSettingsResourceBuilder(this.AuthorisationService));
                with.Dependency <IResourceBuilder <ResponseModel <IEnumerable <ProductionTriggerLevel> > > >(
                    new ProductionTriggerLevelsResourceBuilder(this.AuthorisationService));
                with.Module <ProductionTriggerLevelsModule>();
                with.Dependency <IResourceBuilder <ResponseModel <ProductionTriggerLevel> > >(new ProductionTriggerLevelResourceBuilder(this.AuthorisationService));

                with.ResponseProcessor <ProductionTriggerLevelResponseProcessor>();
                with.ResponseProcessor <ProductionTriggerLevelsResponseProcessor>();
                with.ResponseProcessor <ErrorResponseProcessor>();
                with.ResponseProcessor <PtlSettingsResponseProcessor>();
                with.RequestStartup(
                    (container, pipelines, context) =>
                {
                    var claims = new List <Claim>
                    {
                        new Claim(ClaimTypes.Role, "employee"),
                        new Claim(ClaimTypes.NameIdentifier, "test-user"),
                        new Claim("employee", "/e/111")
                    };

                    var user = new ClaimsIdentity(claims, "jwt");

                    context.CurrentUser = new ClaimsPrincipal(user);
                });
            });

            this.Browser = new Browser(bootstrapper);
        }
示例#2
0
        public ProductionTriggerLevelsModule(
            IProductionTriggerLevelsService productionTriggerLevelsService,
            ISingleRecordFacadeService <PtlSettings, PtlSettingsResource> ptlSettingsFacadeService,
            IAuthorisationService authorisationService,
            ITriggerRunDispatcher triggerRunDispatcher)
        {
            this.productionTriggerLevelsService = productionTriggerLevelsService;
            this.ptlSettingsFacadeService       = ptlSettingsFacadeService;
            this.authorisationService           = authorisationService;
            this.triggerRunDispatcher           = triggerRunDispatcher;

            this.Get("production/maintenance/production-trigger-levels/create", _ => this.GetApp());
            this.Get("production/maintenance/production-trigger-levels/application-state", _ => this.GetApp());
            this.Get("production/maintenance/production-trigger-levels/{partNumber*}", parameters => this.GetProductionTriggerLevel(parameters.partNumber));
            this.Get("production/maintenance/production-trigger-levels", _ => this.GetProductionTriggerLevels());
            this.Put("production/maintenance/production-trigger-levels/{partNumber*}", parameters => this.UpdateTriggerLevel(parameters.partNumber));
            this.Post("production/maintenance/production-trigger-levels", _ => this.AddTriggerLevel());
            this.Get("production/maintenance/production-trigger-levels-settings", _ => this.GetProductionTriggerLevelsSettings());
            this.Put("production/maintenance/production-trigger-levels-settings", _ => this.UpdateProductionTriggerLevelsSettings());
            this.Post("production/maintenance/production-trigger-levels-settings/start-trigger-run", _ => this.StartTriggerRun());
        }