public static async Task Test2Async()
        {
            Func<HttpMessageHandler> handlerFunc = () =>
            {
                return new VerboseHandler();
            };

            DistinctPackageIdCollector collector = new DistinctPackageIdCollector(new Uri("https://az320820.vo.msecnd.net/catalog-0/index.json"), handlerFunc);
            await collector.Run(CancellationToken.None);

            foreach (string s in collector.Result)
            {
                Console.WriteLine(s);
            }

            Console.WriteLine();
            Console.WriteLine("count = {0}", collector.Result.Count);
            Console.WriteLine("http requests: {0}", collector.RequestCount);
        }
        public static void Test0()
        {
            Console.WriteLine("MakeTestCatalog.Test0");

            //Storage storage = new FileStorage("http://localhost:8000/test", @"c:\data\site\test");

            StorageCredentials credentials = new StorageCredentials("", "");
            CloudStorageAccount account = new CloudStorageAccount(credentials, true);
            Storage storage = new AzureStorage(account, "ver36", "catalog");

            var ids = GetInitialIdList(250);

            //var ids = new string[] { "dotnetrdf" };

            string path = @"c:\data\nuget\nuspecs";

            BuildCatalogAsync(path, storage, ids).Wait();
            AddDependenciesAsync(path, storage).Wait();

            DistinctPackageIdCollector distinctPackageIdCollector = new DistinctPackageIdCollector(storage.ResolveUri("index.json"));
            distinctPackageIdCollector.Run(CancellationToken.None).Wait();

            Console.WriteLine(distinctPackageIdCollector.Result.Count);
        }
        public static void Test1()
        {
            Console.WriteLine("IntegrityTests.Test1");

            string catalog = "https://api.nuget.org/v3/catalog0/index.json";

            Func<HttpMessageHandler> handlerFunc = () =>
            {
                return new VerboseHandler();
            };

            DistinctPackageIdCollector collector = new DistinctPackageIdCollector(new Uri(catalog), handlerFunc, 20);

            collector.Run(CancellationToken.None).Wait();

            HashSet<string> packagesFromCatalog = collector.Result;

            Console.WriteLine(packagesFromCatalog.Count);
        }
        public static async Task AddDependenciesAsync(string path, Storage storage)
        {
            Uri root = storage.ResolveUri("index.json");

            Console.WriteLine(root);

            DistinctPackageIdCollector distinctPackageIdCollector = new DistinctPackageIdCollector(root);
            await distinctPackageIdCollector.Run(CancellationToken.None);

            DistinctDependencyPackageIdCollector distinctDependencyPackageIdCollector = new DistinctDependencyPackageIdCollector(root);
            await distinctDependencyPackageIdCollector.Run(CancellationToken.None);

            HashSet<string> missing = new HashSet<string>();

            foreach (string id in distinctDependencyPackageIdCollector.Result)
            {
                if (!distinctPackageIdCollector.Result.Contains(id))
                {
                    if (!id.StartsWith("../"))
                    {
                        missing.Add(id);
                    }
                }
            }

            if (missing.Count > 0)
            {
                Console.WriteLine("missing: {0}", missing.Count);

                foreach (string name in missing)
                {
                    Console.WriteLine("\t{0}", name);
                }

                BuildCatalogAsync(path, storage, missing).Wait();
                AddDependenciesAsync(path, storage).Wait();
            }
        }