diff --git a/Selenium.Axe/Selenium.Axe.Test/AxeResultTargetConverterTest.cs b/Selenium.Axe/Selenium.Axe.Test/AxeResultTargetConverterTest.cs index 98744971..d311e73a 100644 --- a/Selenium.Axe/Selenium.Axe.Test/AxeResultTargetConverterTest.cs +++ b/Selenium.Axe/Selenium.Axe.Test/AxeResultTargetConverterTest.cs @@ -1,8 +1,29 @@ -using System; -using System.IO; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Newtonsoft.Json; + +/* Unmerged change from project 'Selenium.Axe.Test (netcoreapp3.1)' +Before: using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; using Newtonsoft.Json; +After: +using System; +using Microsoft.IO; +using System.Linq; +*/ + +/* Unmerged change from project 'Selenium.Axe.Test (net45)' +Before: +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Newtonsoft.Json; +After: +using System; +using Microsoft.IO; +using System.Linq; +*/ +using System.IO; +using System.Linq; namespace Selenium.Axe.Test { @@ -15,8 +36,30 @@ public void CanConvertPassedAxeResultTarget() var instance = new AxeResultTargetConverter(); var result = instance.CanConvert(typeof(AxeResultTarget)); Assert.IsTrue(result); + + /* Unmerged change from project 'Selenium.Axe.Test (netcoreapp3.1)' + Before: + } + + [TestMethod] + After: + } + + [TestMethod] + */ + + /* Unmerged change from project 'Selenium.Axe.Test (net45)' + Before: + } + + [TestMethod] + After: + } + + [TestMethod] + */ } - + [TestMethod] public void ShouldReadSingleSelector() { @@ -26,22 +69,56 @@ public void ShouldReadSingleSelector() }; var json = $@"{{""target"":[""{testObject.Selector}""]}}"; + + /* Unmerged change from project 'Selenium.Axe.Test (netcoreapp3.1)' + Before: + var axeResultTarget = DeserializeJsonAndReturnFirstTarget(json); + + Assert.AreEqual(axeResultTarget?.Selector, testObject.Selector); + } + + [TestMethod] + After: + var axeResultTarget = DeserializeJsonAndReturnFirstTarget(json); + + Assert.AreEqual(axeResultTarget?.Selector, testObject.Selector); + } + + [TestMethod] + */ + + /* Unmerged change from project 'Selenium.Axe.Test (net45)' + Before: + var axeResultTarget = DeserializeJsonAndReturnFirstTarget(json); + + Assert.AreEqual(axeResultTarget?.Selector, testObject.Selector); + } + + [TestMethod] + After: + var axeResultTarget = DeserializeJsonAndReturnFirstTarget(json); + + Assert.AreEqual(axeResultTarget?.Selector, testObject.Selector); + } + + [TestMethod] + */ var axeResultTarget = DeserializeJsonAndReturnFirstTarget(json); - + Assert.AreEqual(axeResultTarget?.Selector, testObject.Selector); } - + [TestMethod] public void ShouldReadArrayOfSelectors() { var testObject = new AxeResultTarget { - Selectors = { "a", "b"} + Selectors = { "a", "b" } }; var json = $@"{{""target"":[[""{testObject.Selectors.First()}"", ""{testObject.Selectors.Last()}""]]}}"; var axeResultTarget = DeserializeJsonAndReturnFirstTarget(json); - + Assert.AreEqual(axeResultTarget?.Selectors.First(), testObject.Selectors.First()); Assert.AreEqual(axeResultTarget?.Selectors.Last(), testObject.Selectors.Last()); } @@ -58,11 +135,11 @@ public void Write() { var jsonWriter = new JsonTextWriter(writer); var instance = new AxeResultTargetConverter(); - - instance.WriteJson(jsonWriter, value, new JsonSerializer{ Converters = { instance }}); + + instance.WriteJson(jsonWriter, value, new JsonSerializer { Converters = { instance } }); var result = writer.ToString(); - + Assert.IsTrue(expectedResult.Equals(result)); } } diff --git a/Selenium.Axe/Selenium.Axe.Test/AxeRunContextTest.cs b/Selenium.Axe/Selenium.Axe.Test/AxeRunContextTest.cs index e47ccf5b..6fe71ba3 100644 --- a/Selenium.Axe/Selenium.Axe.Test/AxeRunContextTest.cs +++ b/Selenium.Axe/Selenium.Axe.Test/AxeRunContextTest.cs @@ -1,7 +1,7 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Collections.Generic; -using FluentAssertions; +using FluentAssertions; +using Microsoft.VisualStudio.TestTools.UnitTesting; using Newtonsoft.Json; +using System.Collections.Generic; namespace Selenium.Axe.Test { diff --git a/Selenium.Axe/Selenium.Axe.Test/AxeRunOptionsTest.cs b/Selenium.Axe/Selenium.Axe.Test/AxeRunOptionsTest.cs index 7af2e0be..3489c26d 100644 --- a/Selenium.Axe/Selenium.Axe.Test/AxeRunOptionsTest.cs +++ b/Selenium.Axe/Selenium.Axe.Test/AxeRunOptionsTest.cs @@ -1,7 +1,7 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; +using FluentAssertions; +using Microsoft.VisualStudio.TestTools.UnitTesting; using Newtonsoft.Json; using System.Collections.Generic; -using FluentAssertions; namespace Selenium.Axe.Test { diff --git a/Selenium.Axe/Selenium.Axe.Test/IntegrationTests.cs b/Selenium.Axe/Selenium.Axe.Test/IntegrationTests.cs index dfadb0d9..462d5a32 100644 --- a/Selenium.Axe/Selenium.Axe.Test/IntegrationTests.cs +++ b/Selenium.Axe/Selenium.Axe.Test/IntegrationTests.cs @@ -64,7 +64,7 @@ public WebDriverWait Wait [TestCleanup] public virtual void TearDown() - { + { WebDriver?.Quit(); WebDriver?.Dispose(); } @@ -261,7 +261,7 @@ public void ReportRespectsIframeTrue(string browser) { string path = CreateReportPath(); string filename = new Uri(Path.GetFullPath(IntegrationTestTargetComplexTargetsFile)).AbsoluteUri; - + InitDriver(browser); WebDriver.Navigate().GoToUrl(filename); Wait.Until(drv => drv.FindElement(By.CssSelector(mainElementSelector))); @@ -333,7 +333,7 @@ private string CreateReportPath() string path = Uri.UnescapeDataString(uri.Path); return Path.Combine(Path.GetDirectoryName(path), Guid.NewGuid() + ".html"); } - + private void ValidateReport(string path, int violationCount, int passCount, int incompleteCount = 0, int inapplicableCount = 0) { string text = File.ReadAllText(path); @@ -394,7 +394,7 @@ private void ValidateResultCount(string text, int count, ResultType resultType) private void ValidateResultNotWritten(string path, ReportTypes ReportType) { string text = File.ReadAllText(path); - + foreach (string resultType in ReportType.ToString().Split(',')) { Assert.IsFalse(text.Contains($"{resultType}: "), $"Expected to not find '{resultType}: '"); diff --git a/Selenium.Axe/Selenium.Axe.Test/Selenium.Axe.Test.csproj b/Selenium.Axe/Selenium.Axe.Test/Selenium.Axe.Test.csproj index d3a6ea48..629327da 100644 --- a/Selenium.Axe/Selenium.Axe.Test/Selenium.Axe.Test.csproj +++ b/Selenium.Axe/Selenium.Axe.Test/Selenium.Axe.Test.csproj @@ -32,17 +32,13 @@ - + - - - - diff --git a/Selenium.Axe/Selenium.Axe/AxeBuilder.cs b/Selenium.Axe/Selenium.Axe/AxeBuilder.cs index 174591b4..78146340 100644 --- a/Selenium.Axe/Selenium.Axe/AxeBuilder.cs +++ b/Selenium.Axe/Selenium.Axe/AxeBuilder.cs @@ -20,7 +20,7 @@ public class AxeBuilder private readonly AxeRunContext runContext = new AxeRunContext(); private AxeRunOptions runOptions = new AxeRunOptions(); private string outputFilePath = null; - + private static readonly JsonSerializerSettings JsonSerializerSettings = new JsonSerializerSettings { Formatting = Formatting.None, @@ -217,9 +217,9 @@ private AxeResult AnalyzeRawContext(object rawContextArg) { _webDriver.Inject(_AxeBuilderOptions.ScriptProvider, runOptions); - #pragma warning disable CS0618 // Intentionally falling back to publicly deprecated property for backcompat +#pragma warning disable CS0618 // Intentionally falling back to publicly deprecated property for backcompat string rawOptionsArg = Options == "{}" ? JsonConvert.SerializeObject(runOptions, JsonSerializerSettings) : Options; - #pragma warning restore CS0618 +#pragma warning restore CS0618 string scanJsContent = EmbeddedResourceProvider.ReadEmbeddedFile("scan.js"); object[] rawArgs = new[] { rawContextArg, rawOptionsArg }; @@ -227,9 +227,11 @@ private AxeResult AnalyzeRawContext(object rawContextArg) JObject jObject = JObject.FromObject(result); - if (outputFilePath != null && jObject.Type == JTokenType.Object) { + if (outputFilePath != null && jObject.Type == JTokenType.Object) + { Encoding utf8NoBOM = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false); - using (var outputFileWriter = new StreamWriter(outputFilePath, append: false, encoding: utf8NoBOM)) { + using (var outputFileWriter = new StreamWriter(outputFilePath, append: false, encoding: utf8NoBOM)) + { jObject.WriteTo(new JsonTextWriter(outputFileWriter)); } } @@ -257,9 +259,9 @@ private static void ValidateNotNullParameter(T parameterValue, string paramet private void ThrowIfDeprecatedOptionsSet() { - #pragma warning disable CS0618 // Intentionally checking publicly deprecated property for backcompat +#pragma warning disable CS0618 // Intentionally checking publicly deprecated property for backcompat if (Options != "{}") - #pragma warning restore CS0618 +#pragma warning restore CS0618 { throw new InvalidOperationException("Deprecated Options api shouldn't be used with the new apis - WithOptions/WithRules/WithTags or DisableRules"); } diff --git a/Selenium.Axe/Selenium.Axe/AxeResultNode.cs b/Selenium.Axe/Selenium.Axe/AxeResultNode.cs index e10e8864..4fff1063 100644 --- a/Selenium.Axe/Selenium.Axe/AxeResultNode.cs +++ b/Selenium.Axe/Selenium.Axe/AxeResultNode.cs @@ -1,5 +1,5 @@ -using System.Collections.Generic; -using Newtonsoft.Json; +using Newtonsoft.Json; +using System.Collections.Generic; namespace Selenium.Axe { diff --git a/Selenium.Axe/Selenium.Axe/AxeResultRelatedNode.cs b/Selenium.Axe/Selenium.Axe/AxeResultRelatedNode.cs index 74ee2550..1ff30a51 100644 --- a/Selenium.Axe/Selenium.Axe/AxeResultRelatedNode.cs +++ b/Selenium.Axe/Selenium.Axe/AxeResultRelatedNode.cs @@ -1,12 +1,12 @@ -using System.Collections.Generic; -using Newtonsoft.Json; +using Newtonsoft.Json; +using System.Collections.Generic; namespace Selenium.Axe { public class AxeResultRelatedNode { public string Html { get; set; } - + [JsonProperty("target", ItemConverterType = typeof(AxeResultTargetConverter), NullValueHandling = NullValueHandling.Ignore)] public List Target { get; set; } } diff --git a/Selenium.Axe/Selenium.Axe/AxeResultTargetConverter.cs b/Selenium.Axe/Selenium.Axe/AxeResultTargetConverter.cs index ea6ec527..0f028d33 100644 --- a/Selenium.Axe/Selenium.Axe/AxeResultTargetConverter.cs +++ b/Selenium.Axe/Selenium.Axe/AxeResultTargetConverter.cs @@ -1,6 +1,6 @@ +using Newtonsoft.Json; using System; using System.Collections.Generic; -using Newtonsoft.Json; namespace Selenium.Axe { @@ -23,10 +23,10 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist Selectors = serializer.Deserialize>(reader) }; } - + throw new ArgumentException("Cannot unmarshal type Target"); } - + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { var val = (AxeResultTarget)value; @@ -41,7 +41,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s serializer.Serialize(writer, val.Selectors); return; } - + throw new ArgumentException("Cannot marshal type Target"); } } diff --git a/Selenium.Axe/Selenium.Axe/AxeTestEnvironment.cs b/Selenium.Axe/Selenium.Axe/AxeTestEnvironment.cs index 9378f17e..77aade52 100644 --- a/Selenium.Axe/Selenium.Axe/AxeTestEnvironment.cs +++ b/Selenium.Axe/Selenium.Axe/AxeTestEnvironment.cs @@ -3,7 +3,7 @@ public class AxeTestEnvironment { public string UserAgent { get; set; } - public int WindowWidth { get; set; } + public int WindowWidth { get; set; } public int WindowHeight { get; set; } public string OrientationType { get; set; } } diff --git a/Selenium.Axe/Selenium.Axe/EmbeddedResourceProvider.cs b/Selenium.Axe/Selenium.Axe/EmbeddedResourceProvider.cs index f5596a8b..5a37cd7b 100644 --- a/Selenium.Axe/Selenium.Axe/EmbeddedResourceProvider.cs +++ b/Selenium.Axe/Selenium.Axe/EmbeddedResourceProvider.cs @@ -5,10 +5,12 @@ namespace Selenium.Axe { internal static class EmbeddedResourceProvider { - public static string ReadEmbeddedFile(string fileName) { + public static string ReadEmbeddedFile(string fileName) + { var assembly = typeof(EmbeddedResourceProvider).Assembly; var resourceStream = assembly.GetManifestResourceStream($"Selenium.Axe.Resources.{fileName}"); - using (var reader = new StreamReader(resourceStream, Encoding.UTF8)) { + using (var reader = new StreamReader(resourceStream, Encoding.UTF8)) + { return reader.ReadToEnd(); } } diff --git a/Selenium.Axe/Selenium.Axe/HtmlReport.cs b/Selenium.Axe/Selenium.Axe/HtmlReport.cs index 56bc2968..0d2f42c8 100644 --- a/Selenium.Axe/Selenium.Axe/HtmlReport.cs +++ b/Selenium.Axe/Selenium.Axe/HtmlReport.cs @@ -1,8 +1,6 @@ using HtmlAgilityPack; using OpenQA.Selenium; -using OpenQA.Selenium.Internal; using System; -using System.IO; using System.Text; using System.Web; @@ -174,7 +172,7 @@ public static void CreateAxeHtmlReport(this ISearchContext context, AxeResult re modalImage.SetAttributeValue("id", "modalimage"); modal.AppendChild(modalImage); - + doc.DocumentNode.SelectSingleNode("//script").InnerHtml = EmbeddedResourceProvider.ReadEmbeddedFile("htmlReporterElements.js"); doc.Save(destination, Encoding.UTF8); diff --git a/Selenium.Axe/Selenium.Axe/Selenium.Axe.csproj b/Selenium.Axe/Selenium.Axe/Selenium.Axe.csproj index 98587941..27f2286f 100644 --- a/Selenium.Axe/Selenium.Axe/Selenium.Axe.csproj +++ b/Selenium.Axe/Selenium.Axe/Selenium.Axe.csproj @@ -26,7 +26,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - +