public void ShouldReadSingleSelector() { var testObject = new AxeResultTarget { Selector = "test" }; var json = $@"{{""target"":[""{testObject.Selector}""]}}"; var axeResultTarget = DeserializeJsonAndReturnFirstTarget(json); Assert.AreEqual(axeResultTarget?.Selector, testObject.Selector); }
public void ShouldReadArrayOfSelectors() { var testObject = new AxeResultTarget { 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()); }
public void ShouldReadSingleSelector() { var testObject = new AxeResultTarget { Selector = "test" }; 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); }
public void Write() { var expectedResult = "\"test\""; var value = new AxeResultTarget { Selector = "test" }; using (var writer = new StringWriter()) { var jsonWriter = new JsonTextWriter(writer); var instance = new AxeResultTargetConverter(); instance.WriteJson(jsonWriter, value, new JsonSerializer { Converters = { instance } }); var result = writer.ToString(); Assert.IsTrue(expectedResult.Equals(result)); } }