Ejemplo n.º 1
0
            public async void InvokesContainer()
            {
                var container        = Substitute.For <IContainerClient>();
                var containerManager = Substitute.For <IContainerManager>();

                containerManager.GetContainer(null).ReturnsForAnyArgs(container);

                var handler = new LimitMemoryRequestHandler(containerManager, request);

                await handler.HandleAsync();

                container.Received(1, x => x.LimitMemoryAsync(GB));
            }
Ejemplo n.º 2
0
            public async void ReturnsValidResponse()
            {
                var container        = Substitute.For <IContainerClient>();
                var containerManager = Substitute.For <IContainerManager>();

                containerManager.GetContainer(null).ReturnsForAnyArgs(container);

                var handler = new LimitMemoryRequestHandler(containerManager, request);

                var response = await handler.HandleAsync();

                Assert.NotNull(response);
                var limitMemoryResponse = Assert.IsType <LimitMemoryResponse>(response);

                Assert.Equal(GB, limitMemoryResponse.LimitInBytes);
            }
Ejemplo n.º 3
0
        public RequestHandler GetHandler()
        {
            RequestHandler handler = null;

            switch (requestType)
            {
            case Message.Type.CopyIn:
                handler = new CopyInRequestHandler(containerManager, request);
                break;

            case Message.Type.CopyOut:
                handler = new CopyOutRequestHandler(containerManager, request);
                break;

            case Message.Type.Create:
                handler = new CreateRequestHandler(containerManager, request);
                break;

            case Message.Type.Destroy:
                handler = new DestroyRequestHandler(containerManager, request);
                break;

            case Message.Type.Echo:
                handler = new EchoRequestHandler(request);
                break;

            case Message.Type.Info:
                handler = new InfoRequestHandler(containerManager, request);
                break;

            case Message.Type.LimitBandwidth:
                handler = new LimitBandwidthRequestHandler(request);
                break;

            case Message.Type.LimitDisk:
                handler = new LimitDiskRequestHandler(request);
                break;

            case Message.Type.LimitMemory:
                handler = new LimitMemoryRequestHandler(request);
                break;

            case Message.Type.Link:
                handler = new LinkRequestHandler(containerManager, jobManager, request);
                break;

            case Message.Type.List:
                handler = new ListRequestHandler(containerManager, request);
                break;

            case Message.Type.NetIn:
                handler = new NetInRequestHandler(containerManager, request);
                break;

            case Message.Type.NetOut:
                handler = new NetOutRequestHandler(request);
                break;

            case Message.Type.Ping:
                handler = new PingRequestHandler(request);
                break;

            case Message.Type.Run:
                handler = new RunRequestHandler(containerManager, request);
                break;

            case Message.Type.Spawn:
                handler = new SpawnRequestHandler(containerManager, jobManager, request);
                break;

            case Message.Type.Stop:
                handler = new StopRequestHandler(containerManager, request);
                break;

            case Message.Type.Stream:
                handler = new StreamRequestHandler(containerManager, jobManager, request);
                break;

            default:
                throw new WardenException("Unknown request type '{0}' passed to handler factory.", requestType);
            }

            return(handler);
        }
        public RequestHandler GetHandler()
        {
            RequestHandler handler = null;

            switch (requestType)
            {
                case Message.Type.CopyIn:
                    handler = new CopyInRequestHandler(containerManager, request);
                    break;
                case Message.Type.CopyOut:
                    handler = new CopyOutRequestHandler(containerManager, request);
                    break;
                case Message.Type.Create:
                    handler = new CreateRequestHandler(containerManager, request);
                    break;
                case Message.Type.Destroy:
                    handler = new DestroyRequestHandler(containerManager, request);
                    break;
                case Message.Type.Echo:
                    handler = new EchoRequestHandler(request);
                    break;
                case Message.Type.Info:
                    handler = new InfoRequestHandler(containerManager, request);
                    break;
                case Message.Type.LimitBandwidth:
                    handler = new LimitBandwidthRequestHandler(request);
                    break;
                case Message.Type.LimitDisk:
                    handler = new LimitDiskRequestHandler(request);
                    break;
                case Message.Type.LimitMemory:
                    handler = new LimitMemoryRequestHandler(request);
                    break;
                case Message.Type.Link:
                    handler = new LinkRequestHandler(containerManager, jobManager, request);
                    break;
                case Message.Type.List:
                    handler = new ListRequestHandler(containerManager, request);
                    break;
                case Message.Type.NetIn:
                    handler = new NetInRequestHandler(containerManager, request);
                    break;
                case Message.Type.NetOut:
                    handler = new NetOutRequestHandler(request);
                    break;
                case Message.Type.Ping:
                    handler = new PingRequestHandler(request);
                    break;
                case Message.Type.Run:
                    handler = new RunRequestHandler(containerManager, request);
                    break;
                case Message.Type.Spawn:
                    handler = new SpawnRequestHandler(containerManager, jobManager, request);
                    break;
                case Message.Type.Stop:
                    handler = new StopRequestHandler(containerManager, request);
                    break;
                case Message.Type.Stream:
                    handler = new StreamRequestHandler(containerManager, jobManager, request);
                    break;
                default:
                    throw new WardenException("Unknown request type '{0}' passed to handler factory.", requestType);
            }

            return handler;
        }