Esempio n. 1
0
        public override async Task Start(TestContext ctx, CancellationToken cancellationToken)
        {
            var backend = new ProxyBackend(ctx, this);

            if (Interlocked.CompareExchange(ref currentBackend, backend, null) != null)
            {
                throw new InternalErrorException();
            }

            if (AuthenticationType != AuthenticationType.None)
            {
                AuthenticationManager = new AuthenticationManager(AuthenticationType, true);
            }

            await Target.Start(ctx, cancellationToken).ConfigureAwait(false);

            var listener = new Listener(ctx, this, ListenerType.Proxy, backend);

            listener.Start();
            currentListener = listener;
        }
Esempio n. 2
0
        public override async Task Stop(TestContext ctx, CancellationToken cancellationToken)
        {
            var listener = Interlocked.Exchange(ref currentListener, null);

            if (listener == null || listener.TestContext != ctx)
            {
                throw new InternalErrorException();
            }
            try {
                listener.Dispose();
                await Target.Stop(ctx, cancellationToken);
            } catch {
                if ((Flags & HttpServerFlags.ExpectException) == 0)
                {
                    throw;
                }
            } finally {
                currentBackend        = null;
                AuthenticationManager = null;
            }
        }