示例#1
0
        public void ObjectIsFullyUnwoundAlongDefinedPath(string path, int expectedObjects)
        {
            var testObjectJson = JsonConvert.SerializeObject(ValidatorTestObjectGenerator.GenerateTestObject());
            var testJObject    = JObject.Parse(testObjectJson);

            var actual = JsonUnwinder.Unwind(testJObject, path).ToList();

            Assert.That(actual.Count, Is.EqualTo(expectedObjects));
        }
示例#2
0
        public void PerformanceTest(string filePath, string propertyPath)
        {
            var bestResult = 36934;
            var json       = File.ReadAllText(filePath);
            var jObject    = JObject.Parse(json);
            var stopwatch  = Stopwatch.StartNew();
            var actual     = JsonUnwinder.Unwind(jObject, propertyPath).ToList();

            stopwatch.Stop();
            Console.WriteLine($"Elapsed: {stopwatch.ElapsedMilliseconds} ms");
            Assert.That(stopwatch.ElapsedMilliseconds, Is.LessThanOrEqualTo(bestResult));
        }