public static async Task Test0Async()
        {
            //Storage storage = new FileStorage
            //{
            //    Path = @"c:\data\site\test",
            //    Container = "test",
            //    BaseAddress = "http://localhost:8000/"
            //};

            Storage storage = new AzureStorage(
                CloudStorageAccount.Parse("AccountName=nuget3;AccountKey=;DefaultEndpointsProtocol=https"), "test");

            CatalogContext context = new CatalogContext();

            CatalogWriter writer = new CatalogWriter(storage, context, 4, false);

            string[] first = { "john", "paul", "ringo", "george" };
            foreach (string item in first)
            {
                writer.Add(new TestCatalogItem(item));
            }
            await writer.Commit(new DateTime(2010, 12, 25, 12, 0, 0));

            string[] second = { "jimmy", "robert" };
            foreach (string item in second)
            {
                writer.Add(new TestCatalogItem(item));
            }
            await writer.Commit(new DateTime(2011, 12, 25, 12, 0, 0));

            string[] third = { "john-paul", "john" };
            foreach (string item in third)
            {
                writer.Add(new TestCatalogItem(item));
            }
            await writer.Commit(new DateTime(2012, 12, 25, 12, 0, 0));

            //  collection...

            Uri index = storage.ResolveUri("index.json");

            TestItemCollector collector = new TestItemCollector();

            Console.WriteLine("----------------");

            await collector.Run(index, new DateTime(2012, 10, 31, 12, 0, 0));

            Console.WriteLine("----------------");

            await collector.Run(index, new DateTime(2011, 10, 31, 12, 0, 0));

            Console.WriteLine("----------------");

            CollectorCursor cursor = await collector.Run(index, new CollectorCursor(DateTime.MinValue));
        }
        static Storage CreateStorage(string connectionString, string container, string catalogBaseAddress)
        {
            CloudStorageAccount account = CloudStorageAccount.Parse(connectionString);

            Storage storage;
            if (catalogBaseAddress == null)
            {
                storage = new AzureStorage(account, container);
            }
            else
            {
                string baseAddress = catalogBaseAddress.TrimEnd('/') + "/" + container;

                storage = new AzureStorage(account, container, string.Empty, new Uri(baseAddress));
            }

            return storage;
        }
        public static async Task Test4Async()
        {
            //Storage storage = new AzureStorage
            //{
            //    AccountName = "nuget3",
            //    AccountKey = "",
            //    Container = "feed",
            //    BaseAddress = "http://nuget3.blob.core.windows.net"
            //};

            // Storage storage = new FileStorage("http://*****:*****@"c:\data\site\test");
            Storage storage = new AzureStorage(
                CloudStorageAccount.Parse("AccountName=nugetdev0;AccountKey=;DefaultEndpointsProtocol=https"),
                "cdn-public",
                "v3/resolver",
                new Uri("http://preview-api.dev.nugettest.org/v3/resolver/"));

            ResolverCollector collector = new ResolverCollector(storage, 200);

            await collector.Run(new Uri("http://localhost:8000/test/catalog/index.json"), DateTime.MinValue);
            Console.WriteLine("http requests: {0} batch count: {1}", collector.RequestCount, collector.BatchCount);
        }
        public static async Task Test0Async()
        {
            //Storage storage = new FileStorage
            //{
            //    Path = @"c:\data\site\test",
            //    Container = "test",
            //    BaseAddress = "http://localhost:8000/"
            //};

            Storage storage = new AzureStorage
            {
                AccountName = "",
                AccountKey = "",
                Container = "test",
                BaseAddress = "http://nuget3.blob.core.windows.net"
            };

            CatalogContext context = new CatalogContext();

            CatalogWriter writer = new CatalogWriter(storage, context, 4, false);

            string[] first = { "john", "paul", "ringo", "george" };
            foreach (string item in first)
            {
                writer.Add(new TestCatalogItem(item));
            }
            await writer.Commit(new DateTime(2010, 12, 25, 12, 0, 0));

            string[] second = { "jimmy", "robert" };
            foreach (string item in second)
            {
                writer.Add(new TestCatalogItem(item));
            }
            await writer.Commit(new DateTime(2011, 12, 25, 12, 0, 0));

            string[] third = { "john-paul", "john" };
            foreach (string item in third)
            {
                writer.Add(new TestCatalogItem(item));
            }
            await writer.Commit(new DateTime(2012, 12, 25, 12, 0, 0));

            //  collection...

            string baseAddress = storage.BaseAddress + storage.Container + "/";

            Uri index = new Uri(baseAddress + "catalog/index.json");

            TestItemCollector collector = new TestItemCollector();

            Console.WriteLine("----------------");

            await collector.Run(index, new DateTime(2012, 10, 31, 12, 0, 0));

            Console.WriteLine("----------------");

            await collector.Run(index, new DateTime(2011, 10, 31, 12, 0, 0));

            Console.WriteLine("----------------");

            await collector.Run(index, DateTime.MinValue);
        }
        static async Task<Uri> AddToCatalog(Stream nupkgStream, CancellationToken cancellationToken)
        {
            string storagePrimary = _configurationService.Get("Storage.Primary");
            CloudStorageAccount account = CloudStorageAccount.Parse(storagePrimary);

            Storage storage = new AzureStorage(account, "catalog");

            AppendOnlyCatalogWriter writer = new AppendOnlyCatalogWriter(storage);
            writer.Add(Utils.CreateCatalogItem(nupkgStream, null, null, ""));
            await writer.Commit(null, cancellationToken);

            return writer.RootUri;
        }
        public static void Test0()
        {
            Console.WriteLine("MakeTestCatalog.Test0");

            //Storage storage = new FileStorage("http://*****:*****@"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);
        }