コード例 #1
0
        public void ShouldReadSingleSelector()
        {
            var testObject = new AxeResultTarget
            {
                Selector = "test"
            };
            var json = $@"{{""target"":[""{testObject.Selector}""]}}";

            var axeResultTarget = DeserializeJsonAndReturnFirstTarget(json);

            Assert.AreEqual(axeResultTarget?.Selector, testObject.Selector);
        }
コード例 #2
0
        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());
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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));
            }
        }