public async Task Passes_through_to_specific_service_with_delegate()
        {
            RequestDelegate _next = (ctx) => Task.Run(() => { throw new NotImplementedException(); });

            var host       = TestHelpers.CreatePluginHost(new[] { typeof(EndpointMiddlewareFacts).GetTypeInfo().Assembly, typeof(EndpointDescriptor).GetTypeInfo().Assembly });
            var middleware = new EndpointMiddleware(_next, host, new LoggerFactory());

            var context = new DefaultHttpContext();

            context.Request.Path = PathString.FromUriComponent("/findsymbols");

            var memoryStream = new MemoryStream();

            context.Request.Body = new MemoryStream(
                Encoding.UTF8.GetBytes(
                    JsonConvert.SerializeObject(new FindSymbolsRequest
            {
                Language = LanguageNames.CSharp
            })
                    )
                );

            await middleware.Invoke(context);

            Assert.True(true);
        }
        public async Task Passes_through_to_services()
        {
            RequestDelegate _next = (ctx) => Task.Run(() => { throw new NotImplementedException(); });

            var host       = TestHelpers.CreatePluginHost(new[] { typeof(EndpointMiddlewareFacts).GetTypeInfo().Assembly, typeof(EndpointDescriptor).GetTypeInfo().Assembly });
            var middleware = new EndpointMiddleware(_next, host, new LoggerFactory());

            var context = new DefaultHttpContext();

            context.Request.Path = PathString.FromUriComponent("/gotodefinition");

            var memoryStream = new MemoryStream();

            context.Request.Body = new MemoryStream(
                Encoding.UTF8.GetBytes(
                    JsonConvert.SerializeObject(new GotoDefinitionRequest
            {
                FileName = "bar.cs",
                Line     = 2,
                Column   = 14,
                Timeout  = 60000
            })
                    )
                );

            await middleware.Invoke(context);

            Assert.True(true);
        }
示例#3
0
        private async Task <RunCodeActionResponse> RunRefactoringsAsync(string source, string identifier, bool wantsChanges = false)
        {
            var request = CreateRunCodeActionRequest(source, identifier, wantsChanges);

            _host      = _host ?? TestHelpers.CreatePluginHost(new[] { typeof(RoslynCodeActionProvider).GetTypeInfo().Assembly, typeof(NRefactoryCodeActionProvider).GetTypeInfo().Assembly, typeof(GetCodeActionsService).GetTypeInfo().Assembly });
            _workspace = _workspace ?? await TestHelpers.CreateSimpleWorkspace(_host, request.Buffer, bufferPath);

            var controller = new RunCodeActionService(_workspace, new ICodeActionProvider[] { new RoslynCodeActionProvider(), new NRefactoryCodeActionProvider() }, new FakeLoggerFactory());
            var response   = await controller.Handle(request);

            return(response);
        }
示例#4
0
        private async Task <IEnumerable <OmniSharpCodeAction> > FindRefactoringsAsync(string source)
        {
            var request = CreateGetCodeActionsRequest(source);

            _host      = _host ?? TestHelpers.CreatePluginHost(new[] { typeof(RoslynCodeActionProvider).GetTypeInfo().Assembly, typeof(NRefactoryCodeActionProvider).GetTypeInfo().Assembly, typeof(GetCodeActionsService).GetTypeInfo().Assembly });
            _workspace = _workspace ?? await TestHelpers.CreateSimpleWorkspace(_host, request.Buffer, bufferPath);

            var controller = new GetCodeActionsService(_workspace, new ICodeActionProvider[] { new RoslynCodeActionProvider(), new NRefactoryCodeActionProvider() }, new FakeLoggerFactory());
            var response   = await controller.Handle(request);

            return(response.CodeActions);
        }
        public async Task Passes_through_for_invalid_path()
        {
            RequestDelegate _next = (ctx) => Task.Run(() => { throw new NotImplementedException(); });

            var host       = TestHelpers.CreatePluginHost(new[] { typeof(EndpointMiddlewareFacts).GetTypeInfo().Assembly });
            var middleware = new EndpointMiddleware(_next, host, new LoggerFactory());

            var context = new DefaultHttpContext();

            context.Request.Path = PathString.FromUriComponent("/notvalid");

            await Assert.ThrowsAsync <NotImplementedException>(() => middleware.Invoke(context));
        }
        public async Task Should_throw_if_type_is_not_mergeable()
        {
            RequestDelegate _next = async(ctx) => await Task.Run(() => { throw new NotImplementedException(); });

            var host       = TestHelpers.CreatePluginHost(new[] { typeof(EndpointMiddlewareFacts).GetTypeInfo().Assembly });
            var middleware = new EndpointMiddleware(_next, host, new LoggerFactory());

            var context = new DefaultHttpContext();

            context.Request.Path = PathString.FromUriComponent("/throw");

            var memoryStream = new MemoryStream();

            context.Request.Body = new MemoryStream(
                Encoding.UTF8.GetBytes(
                    JsonConvert.SerializeObject(new ThrowRequest())
                    )
                );

            await Assert.ThrowsAsync <NotSupportedException>(async() => await middleware.Invoke(context));
        }