コード例 #1
0
        public ContentResult Get()
        {
            // simple test
            var svc = new FormatterService();

            return(Content(svc.FormatTSql("Select * From em"), System.Net.Mime.MediaTypeNames.Text.Html));
        }
コード例 #2
0
 public async Task FormatDocumentShouldReturnSingleEdit()
 {
     // Given a document that we want to format
     SetupScriptFile(defaultSqlContents);
     // When format document is called
     await TestUtils.RunAndVerify <TextEdit[]>(
         test : (requestContext) => FormatterService.HandleDocFormatRequest(docFormatParams, requestContext),
         verify : (edits =>
     {
         // Then expect a single edit to be returned and for it to match the standard formatting
         Assert.Equal(1, edits.Length);
         AssertFormattingEqual(formattedSqlContents, edits[0].NewText);
     }));
 }
コード例 #3
0
 public async Task FormatDocumentTelemetryShouldIncludeFormatTypeProperty()
 {
     await RunAndVerifyTelemetryTest(
         // Given a document that we want to format
         preRunSetup : () => SetupScriptFile(defaultSqlContents),
         // When format document is called
         test : (requestContext) => FormatterService.HandleDocFormatRequest(docFormatParams, requestContext),
         verify : (result, actualParams) =>
     {
         // Then expect a telemetry event to have been sent with the right format definition
         Assert.NotNull(actualParams);
         Assert.Equal(TelemetryEventNames.FormatCode, actualParams.Params.EventName);
         Assert.Equal(TelemetryPropertyNames.DocumentFormatType, actualParams.Params.Properties[TelemetryPropertyNames.FormatType]);
     });
 }
コード例 #4
0
 public async Task FormatDocumentShouldSkipNonMssqlFile()
 {
     // Given a non-MSSQL document
     SetupLanguageService(skipFile: true);
     SetupScriptFile(defaultSqlContents);
     // When format document is called
     await TestUtils.RunAndVerify <TextEdit[]>(
         test : (requestContext) => FormatterService.HandleDocFormatRequest(docFormatParams, requestContext),
         verify : (edits =>
     {
         // Then expect a single edit to be returned and for it to match the standard formatting
         Assert.Equal(0, edits.Length);
         LanguageServiceMock.Verify(x => x.ShouldSkipNonMssqlFile(docFormatParams.TextDocument.Uri), Times.Once);
     }));
 }
コード例 #5
0
        public async Task FormatRangeTelemetryShouldIncludeFormatTypeProperty()
        {
            await RunAndVerifyTelemetryTest(
                // Given a document that we want to format
                preRunSetup : () => SetupLanguageService(),
                // When format range is called
                test : (requestContext) => FormatterService.HandleDocRangeFormatRequest(rangeFormatParams, requestContext),
                verify : (result, actualParams) =>
            {
                // Then expect a telemetry event to have been sent with the right format definition
                Assert.NotNull(actualParams);
                Assert.Equal(TelemetryEventNames.FormatCode, actualParams.Params.EventName);
                Assert.Equal(TelemetryPropertyNames.RangeFormatType, actualParams.Params.Properties[TelemetryPropertyNames.FormatType]);

                // And expect range to have been correctly formatted
                Assert.Equal(1, result.Length);
                AssertFormattingEqual(formattedSqlContents, result[0].NewText);
            });
        }
コード例 #6
0
 public TestFormatterService()
 {
     _target = new FormatterService();
 }
コード例 #7
0
 public Form1()
 {
     InitializeComponent();
     _formatter = new FormatterService();
 }
コード例 #8
0
        public ContentResult Post([FromForm] FormatterService.Options options)
        {
            var svc = new FormatterService();

            return(Content(svc.FormatTSqlWithOptions(options), System.Net.Mime.MediaTypeNames.Text.Html));
        }