public ContentResult Get() { // simple test var svc = new FormatterService(); return(Content(svc.FormatTSql("Select * From em"), System.Net.Mime.MediaTypeNames.Text.Html)); }
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); })); }
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]); }); }
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); })); }
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); }); }
public TestFormatterService() { _target = new FormatterService(); }
public Form1() { InitializeComponent(); _formatter = new FormatterService(); }
public ContentResult Post([FromForm] FormatterService.Options options) { var svc = new FormatterService(); return(Content(svc.FormatTSqlWithOptions(options), System.Net.Mime.MediaTypeNames.Text.Html)); }