public void FetchLocalRepositoryDoesNotExist()
        {
            string targetDtmi = "dtmi:com:example:thermostat;1";

            Uri invalidFileUri             = new Uri("file://totally/fake/path/please");
            LocalModelFetcher localFetcher = new LocalModelFetcher(_logger.Object, new ResolverClientOptions());

            Assert.ThrowsAsync <DirectoryNotFoundException>(async() => await localFetcher.FetchAsync(targetDtmi, invalidFileUri));

            _logger.ValidateLog(StandardStrings.ErrorAccessLocalRepository(invalidFileUri.AbsolutePath), LogLevel.Error, Times.Once());
        }
        public FetchResult Fetch(string dtmi, Uri repositoryUri, CancellationToken cancellationToken = default)
        {
            string registryPath = repositoryUri.AbsolutePath;

            if (!Directory.Exists(registryPath))
            {
                string dnfError = StandardStrings.ErrorAccessLocalRepository(registryPath);
                _logger.LogError(dnfError);
                throw new DirectoryNotFoundException(dnfError);
            }

            Queue <string> work = new Queue <string>();

            if (_tryExpanded)
            {
                work.Enqueue(GetPath(dtmi, repositoryUri, true));
            }

            work.Enqueue(GetPath(dtmi, repositoryUri, false));

            string fnfError = string.Empty;

            while (work.Count != 0 && !cancellationToken.IsCancellationRequested)
            {
                string tryContentPath = work.Dequeue();
                _logger.LogTrace(StandardStrings.FetchingContent(tryContentPath));

                if (EvaluatePath(tryContentPath))
                {
                    return(new FetchResult()
                    {
                        Definition = File.ReadAllText(tryContentPath, Encoding.UTF8),
                        Path = tryContentPath
                    });
                }

                fnfError = StandardStrings.ErrorAccessLocalRepositoryModel(tryContentPath);
                _logger.LogWarning(fnfError);
            }

            throw new FileNotFoundException(fnfError);
        }