Пример #1
0
        public async Task ResourceExplorer_ReadTokenRangeAdvance_AssignId()
        {
            var          path            = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, PathUtils.NormalizePath(@"..\..\..")));
            var          sourceContext   = new ResourceSourceContext();
            const string resourcesFolder = "resources";
            const string resourceId      = "test.dialog";

            using (var explorer = new ResourceExplorer())
            {
                explorer.AddResourceProvider(new FolderResourceProvider(explorer, path));

                // Load file using resource explorer
                var resource = explorer.GetResource(resourceId);

                // Read token range using resource explorer
                var(jToken, range) = await explorer.ReadTokenRangeAsync(resource, sourceContext, true).ConfigureAwait(false);

                // Verify correct range
                var expectedRange = new SourceRange
                {
                    StartPoint = new SourcePoint(1, 1),
                    EndPoint   = new SourcePoint(14, 1),
                    Path       = Path.Join(Path.Join(path, resourcesFolder), resourceId)
                };

                Assert.Equal(expectedRange, range);

                // Verify ID was added
                Assert.Equal(resourceId, sourceContext.DefaultIdMap[jToken]);
            }
        }