mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-04 20:21:18 +08:00
StyleCop rules enforced (#5339)
Co-authored-by: Clint Rutkas <crutkas@microsoft.com>
This commit is contained in:
parent
c48bd9b840
commit
cfc768caa9
@ -1,4 +1,7 @@
|
||||
using System;
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Markdig;
|
||||
using MarkdownPreviewHandler;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
@ -18,29 +21,28 @@ namespace PreviewPaneUnitTests
|
||||
[TestMethod]
|
||||
public void Extension_UpdatesTablesClass_WhenUsed()
|
||||
{
|
||||
// Arrange
|
||||
String mdString = "| A | B |\n| -- | -- | ";
|
||||
// Arrange
|
||||
string mdString = "| A | B |\n| -- | -- | ";
|
||||
HTMLParsingExtension htmlParsingExtension = new HTMLParsingExtension(() => { });
|
||||
MarkdownPipeline markdownPipeline = BuidPipeline(htmlParsingExtension);
|
||||
|
||||
// Act
|
||||
String html = Markdown.ToHtml(mdString, markdownPipeline);
|
||||
string html = Markdown.ToHtml(mdString, markdownPipeline);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(html, "<table class=\"table table-striped table-bordered\">\n<thead>\n<tr>\n<th>A</th>\n<th>B</th>\n</tr>\n</thead>\n</table>\n");
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public void Extension_UpdatesBlockQuotesClass_WhenUsed()
|
||||
{
|
||||
// Arrange
|
||||
String mdString = "> Blockquotes.";
|
||||
// Arrange
|
||||
string mdString = "> Blockquotes.";
|
||||
HTMLParsingExtension htmlParsingExtension = new HTMLParsingExtension(() => { });
|
||||
MarkdownPipeline markdownPipeline = BuidPipeline(htmlParsingExtension);
|
||||
|
||||
// Act
|
||||
String html = Markdown.ToHtml(mdString, markdownPipeline);
|
||||
string html = Markdown.ToHtml(mdString, markdownPipeline);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(html, "<blockquote class=\"blockquote\">\n<p>Blockquotes.</p>\n</blockquote>\n");
|
||||
@ -49,13 +51,13 @@ namespace PreviewPaneUnitTests
|
||||
[TestMethod]
|
||||
public void Extension_UpdatesFigureClassAndBlocksRelativeUrl_WhenUsed()
|
||||
{
|
||||
// arrange
|
||||
String mdString = "![text](a.jpg \"Figure\")";
|
||||
// arrange
|
||||
string mdString = "![text](a.jpg \"Figure\")";
|
||||
HTMLParsingExtension htmlParsingExtension = new HTMLParsingExtension(() => { }, "C:\\Users\\");
|
||||
MarkdownPipeline markdownPipeline = BuidPipeline(htmlParsingExtension);
|
||||
|
||||
// Act
|
||||
String html = Markdown.ToHtml(mdString, markdownPipeline);
|
||||
string html = Markdown.ToHtml(mdString, markdownPipeline);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(html, "<p><img src=\"#\" class=\"img-fluid\" alt=\"text\" title=\"Figure\" /></p>\n");
|
||||
@ -64,13 +66,13 @@ namespace PreviewPaneUnitTests
|
||||
[TestMethod]
|
||||
public void Extension_AddsClassToFigureCaption_WhenUsed()
|
||||
{
|
||||
// arrange
|
||||
String mdString = "^^^ This is a caption";
|
||||
// arrange
|
||||
string mdString = "^^^ This is a caption";
|
||||
HTMLParsingExtension htmlParsingExtension = new HTMLParsingExtension(() => { }, "C:/Users/");
|
||||
MarkdownPipeline markdownPipeline = BuidPipeline(htmlParsingExtension);
|
||||
|
||||
// Act
|
||||
String html = Markdown.ToHtml(mdString, markdownPipeline);
|
||||
string html = Markdown.ToHtml(mdString, markdownPipeline);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(html, "<figure class=\"figure\">\n<figcaption class=\"figure-caption\">This is a caption</figcaption>\n</figure>\n");
|
||||
@ -81,18 +83,16 @@ namespace PreviewPaneUnitTests
|
||||
{
|
||||
// arrange
|
||||
int count = 0;
|
||||
String mdString = "![text](http://dev.nodeca.com \"Figure\")";
|
||||
string mdString = "![text](http://dev.nodeca.com \"Figure\")";
|
||||
HTMLParsingExtension htmlParsingExtension = new HTMLParsingExtension(() => { count++; });
|
||||
MarkdownPipeline markdownPipeline = BuidPipeline(htmlParsingExtension);
|
||||
|
||||
// Act
|
||||
String html = Markdown.ToHtml(mdString, markdownPipeline);
|
||||
string html = Markdown.ToHtml(mdString, markdownPipeline);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(count, 1);
|
||||
Assert.AreEqual(html, "<p><img src=\"#\" class=\"img-fluid\" alt=\"text\" title=\"Figure\" /></p>\n");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,9 @@
|
||||
using System;
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml.Linq;
|
||||
using Markdig;
|
||||
using MarkdownPreviewHandler;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using PreviewHandlerCommon;
|
||||
@ -17,7 +16,7 @@ namespace PreviewPaneUnitTests
|
||||
[TestMethod]
|
||||
public void MarkdownPreviewHandlerControl__AddsBrowserToForm_WhenDoPreviewIsCalled()
|
||||
{
|
||||
// Arrange
|
||||
// Arrange
|
||||
using (var markdownPreviewHandlerControl = new MarkdownPreviewHandlerControl())
|
||||
{
|
||||
// Act
|
||||
@ -32,7 +31,7 @@ namespace PreviewPaneUnitTests
|
||||
[TestMethod]
|
||||
public void MarkdownPreviewHandlerControl__AddsInfoBarToFormIfExternalImageLinkPresent_WhenDoPreviewIsCalled()
|
||||
{
|
||||
// Arrange
|
||||
// Arrange
|
||||
using (var markdownPreviewHandlerControl = new MarkdownPreviewHandlerControl())
|
||||
{
|
||||
// Act
|
||||
@ -47,7 +46,7 @@ namespace PreviewPaneUnitTests
|
||||
[TestMethod]
|
||||
public void MarkdownPreviewHandlerControl__AddsInfoBarToFormIfHTMLImageTagIsPresent_WhenDoPreviewIsCalled()
|
||||
{
|
||||
// Arrange
|
||||
// Arrange
|
||||
using (var markdownPreviewHandlerControl = new MarkdownPreviewHandlerControl())
|
||||
{
|
||||
// Act
|
||||
@ -62,7 +61,7 @@ namespace PreviewPaneUnitTests
|
||||
[TestMethod]
|
||||
public void MarkdownPreviewHandlerControl__DoesNotAddInfoBarToFormIfExternalImageLinkNotPresent_WhenDoPreviewIsCalled()
|
||||
{
|
||||
// Arrange
|
||||
// Arrange
|
||||
using (var markdownPreviewHandlerControl = new MarkdownPreviewHandlerControl())
|
||||
{
|
||||
// Act
|
||||
@ -77,7 +76,7 @@ namespace PreviewPaneUnitTests
|
||||
[TestMethod]
|
||||
public void MarkdownPreviewHandlerControl__UpdatesWebBrowserSettings_WhenDoPreviewIsCalled()
|
||||
{
|
||||
// Arrange
|
||||
// Arrange
|
||||
using (var markdownPreviewHandlerControl = new MarkdownPreviewHandlerControl())
|
||||
{
|
||||
// Act
|
||||
@ -97,7 +96,7 @@ namespace PreviewPaneUnitTests
|
||||
[TestMethod]
|
||||
public void MarkdownPreviewHandlerControl__UpdateInfobarSettings_WhenDoPreviewIsCalled()
|
||||
{
|
||||
// Arrange
|
||||
// Arrange
|
||||
using (var markdownPreviewHandlerControl = new MarkdownPreviewHandlerControl())
|
||||
{
|
||||
// Act
|
||||
@ -113,4 +112,4 @@ namespace PreviewPaneUnitTests
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -125,6 +125,21 @@
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\..\codeAnalysis\GlobalSuppressions.cs">
|
||||
<Link>GlobalSuppressions.cs</Link>
|
||||
</Compile>
|
||||
<AdditionalFiles Include="..\..\..\codeAnalysis\StyleCop.json">
|
||||
<Link>StyleCop.json</Link>
|
||||
</AdditionalFiles>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="StyleCop.Analyzers">
|
||||
<Version>1.1.118</Version>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user