예제 #1
0
        public LabelPrintModule(
            ILabelPrintService labelPrintService,
            IFacadeWithSearchReturnTen <Address, int, AddressResource, AddressResource> addressService,
            IFacadeWithSearchReturnTen <Supplier, int, SupplierResource, SupplierResource> supplierService)
        {
            this.labelPrintService = labelPrintService;
            this.addressService    = addressService;
            this.supplierService   = supplierService;

            this.Get("production/maintenance/labels/print", _ => this.GetApp());
            this.Get("production/maintenance/labels/suppliers", _ => this.SearchSuppliers());
            this.Get("production/maintenance/labels/addresses", _ => this.SearchAddresses());
            this.Get("production/maintenance/labels/address/{id*}", parameters => this.GetAddress(parameters.id));
            this.Post("production/maintenance/labels/print", _ => this.Print());
            this.Get("production/maintenance/labels/printers", _ => this.GetPrinters());
            this.Get("production/maintenance/labels/label-types", _ => this.GetLabelsTypes());
        }
예제 #2
0
        public void EstablishContext()
        {
            this.LabelPrintService = Substitute.For <ILabelPrintService>();
            this.AddressService    = Substitute.For <IFacadeWithSearchReturnTen <Address, int, AddressResource, AddressResource> >();
            this.SupplierService   =
                Substitute.For <IFacadeWithSearchReturnTen <Supplier, int, SupplierResource, SupplierResource> >();
            var bootstrapper = new ConfigurableBootstrapper(
                with =>
            {
                with.Dependency(this.LabelPrintService);
                with.Dependency(this.AddressService);
                with.Dependency(this.SupplierService);
                with.Dependency <IResourceBuilder <LabelPrint> >(new LabelPrintResourceBuilder());
                with.Module <LabelPrintModule>();
                with.Dependency <IResourceBuilder <IdAndName> >(new IdAndNameResourceBuilder());
                with.Dependency <IResourceBuilder <IEnumerable <IdAndName> > >(new IdAndNameListResourceBuilder());
                with.Dependency <IResourceBuilder <Address> >(new AddressResourceBuilder());
                with.Dependency <IResourceBuilder <Supplier> >(new SupplierResourceBuilder());
                with.Dependency <IResourceBuilder <IEnumerable <Address> > >(new AddressesResourceBuilder());
                with.Dependency <IResourceBuilder <IEnumerable <Supplier> > >(new SuppliersResourceBuilder());
                with.ResponseProcessor <LabelPrintResponseProcessor>();
                with.ResponseProcessor <IdAndNameResponseProcessor>();
                with.ResponseProcessor <IdAndNameListResponseProcessor>();
                with.ResponseProcessor <AddressResponseProcessor>();
                with.ResponseProcessor <SupplierResponseProcessor>();
                with.ResponseProcessor <AddressesResponseProcessor>();
                with.ResponseProcessor <SuppliersResponseProcessor>();
                with.RequestStartup(
                    (container, pipelines, context) =>
                {
                    var claims = new List <Claim>
                    {
                        new Claim(ClaimTypes.Role, "employee"),
                        new Claim(ClaimTypes.NameIdentifier, "test-user")
                    };
                    var user = new ClaimsIdentity(claims, "jwt");

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

            this.Browser = new Browser(bootstrapper);
        }