コード例 #1
0
        public void ResolveResourceType_JObjectWithExpectedResourcesArray_ReturnsResourcesOfCorrectType(string template, string resourceType, int[] matchingResourceIndexes)
        {
            var jToken   = JObject.Parse(template);
            var resolver = new JsonPathResolver(jToken, jToken.Path);

            // Do twice to verify internal cache correctness
            for (int i = 0; i < 2; i++)
            {
                var resources = resolver.ResolveResourceType(resourceType).ToList();
                Assert.AreEqual(matchingResourceIndexes.Length, resources.Count);

                // Verify resources of correct type were returned
                for (int j = 0; j < matchingResourceIndexes.Length; j++)
                {
                    var resource      = resources[j];
                    int resourceIndex = matchingResourceIndexes[j];
                    var expectedPath  = $"resources[{resourceIndex}]";
                    Assert.AreEqual(expectedPath, resource.JToken.Path);
                }
            }
        }