public void CloudAnalyticsClientListLogsStartEndDate()
        {
            CloudBlobClient      blobClient      = CloudAnalyticsClientTests.GenerateCloudBlobClient();
            CloudTableClient     tableClient     = CloudAnalyticsClientTests.GenerateCloudTableClient();
            CloudAnalyticsClient analyticsClient = new CloudAnalyticsClient(blobClient.StorageUri, tableClient.StorageUri, blobClient.Credentials);

            analyticsClient.LogContainer = CloudAnalyticsClientTests.GetRandomContainerName();
            CloudBlobContainer container = blobClient.GetContainerReference(analyticsClient.LogContainer);

            try
            {
                DateTime time = DateTime.UtcNow;
                container.CreateIfNotExists();
                List <string> logBlobNames             = CreateLogs(container, StorageService.Blob, 72, time.AddDays(-3), "hour"); // 3 days of logs, one per hour
                string        expectedTwoDaysAgoPrefix = string.Concat("blob/", time.AddDays(-2).ToString("yyyy/MM/dd/HH", CultureInfo.InvariantCulture));
                string        expectedYesterdayPrefix  = string.Concat("blob/", time.AddDays(-1).ToString("yyyy/MM/dd/HH", CultureInfo.InvariantCulture));

                IEnumerable <ICloudBlob> results = analyticsClient.ListLogs(StorageService.Blob, time.AddDays(-2), time.AddDays(-1)); // only want the middle day's logs
                foreach (ICloudBlob result in results)
                {
                    Assert.IsTrue(string.Compare(result.Parent.Prefix, expectedTwoDaysAgoPrefix) >= 0);
                    Assert.IsTrue(string.Compare(result.Parent.Prefix, expectedYesterdayPrefix) <= 0);
                    Assert.IsTrue(logBlobNames.Remove(result.Name));
                    result.Delete();
                }

                Assert.AreEqual(48, logBlobNames.Count); // should have two thirds of the logs remaining.
                Assert.AreEqual(0, analyticsClient.ListLogs(StorageService.Blob, time.AddDays(-2), time.AddDays(-1)).Count());
            }
            finally
            {
                container.DeleteIfExists();
            }
        }
        public void CloudAnalyticsClientListAllLogs()
        {
            CloudBlobClient      blobClient      = CloudAnalyticsClientTests.GenerateCloudBlobClient();
            CloudTableClient     tableClient     = CloudAnalyticsClientTests.GenerateCloudTableClient();
            CloudAnalyticsClient analyticsClient = new CloudAnalyticsClient(blobClient.StorageUri, tableClient.StorageUri, blobClient.Credentials);

            analyticsClient.LogContainer = CloudAnalyticsClientTests.GetRandomContainerName();
            CloudBlobContainer container = blobClient.GetContainerReference(analyticsClient.LogContainer);

            try
            {
                container.CreateIfNotExists();
                List <string> logBlobNames = CreateLogs(container, StorageService.Blob, 13, DateTime.UtcNow.AddMonths(-13), "month"); // 13 months of logs, one per month

                IEnumerable <ICloudBlob> results = analyticsClient.ListLogs(StorageService.Blob);
                foreach (ICloudBlob result in results)
                {
                    result.Delete();
                    logBlobNames.Remove(result.Name);
                }

                Assert.AreEqual(0, logBlobNames.Count);
                Assert.AreEqual(0, analyticsClient.ListLogs(StorageService.Blob).Count());
            }
            finally
            {
                container.DeleteIfExists();
            }
        }
        public void CloudAnalyticsClientListLogsStartEndDate()
        {
            CloudBlobClient blobClient = CloudAnalyticsClientTests.GenerateCloudBlobClient();
            CloudTableClient tableClient = CloudAnalyticsClientTests.GenerateCloudTableClient();
            CloudAnalyticsClient analyticsClient = new CloudAnalyticsClient(blobClient.StorageUri, tableClient.StorageUri, blobClient.Credentials);
            analyticsClient.LogContainer = CloudAnalyticsClientTests.GetRandomContainerName();
            CloudBlobContainer container = blobClient.GetContainerReference(analyticsClient.LogContainer);

            try
            {
                DateTime time = DateTime.UtcNow;
                container.CreateIfNotExists();
                List<string> logBlobNames = CreateLogs(container, StorageService.Blob, 72, time.AddDays(-3), "hour"); // 3 days of logs, one per hour
                string expectedTwoDaysAgoPrefix = string.Concat("blob/", time.AddDays(-2).ToString("yyyy/MM/dd/HH", CultureInfo.InvariantCulture));
                string expectedYesterdayPrefix = string.Concat("blob/", time.AddDays(-1).ToString("yyyy/MM/dd/HH", CultureInfo.InvariantCulture));

                IEnumerable<ICloudBlob> results = analyticsClient.ListLogs(StorageService.Blob, time.AddDays(-2), time.AddDays(-1)); // only want the middle day's logs
                foreach (ICloudBlob result in results)
                {
                    Assert.IsTrue(string.Compare(result.Parent.Prefix, expectedTwoDaysAgoPrefix) >= 0);
                    Assert.IsTrue(string.Compare(result.Parent.Prefix, expectedYesterdayPrefix) <= 0);
                    Assert.IsTrue(logBlobNames.Remove(result.Name));
                    result.Delete();
                }

                Assert.AreEqual(48, logBlobNames.Count); // should have two thirds of the logs remaining. 
                Assert.AreEqual(0, analyticsClient.ListLogs(StorageService.Blob, time.AddDays(-2), time.AddDays(-1)).Count());
            }
            finally
            {
                container.DeleteIfExists();
            }
        }
        public void CloudAnalyticsClientListAllLogs()
        {
            CloudBlobClient blobClient = CloudAnalyticsClientTests.GenerateCloudBlobClient();
            CloudTableClient tableClient = CloudAnalyticsClientTests.GenerateCloudTableClient();
            CloudAnalyticsClient analyticsClient = new CloudAnalyticsClient(blobClient.StorageUri, tableClient.StorageUri, blobClient.Credentials);
            analyticsClient.LogContainer = CloudAnalyticsClientTests.GetRandomContainerName();
            CloudBlobContainer container = blobClient.GetContainerReference(analyticsClient.LogContainer);

            try
            {
                container.CreateIfNotExists();
                List<string> logBlobNames = CreateLogs(container, StorageService.Blob, 13, DateTime.UtcNow.AddMonths(-13), "month"); // 13 months of logs, one per month

                IEnumerable<ICloudBlob> results = analyticsClient.ListLogs(StorageService.Blob);
                foreach (ICloudBlob result in results)
                {
                    result.Delete();
                    logBlobNames.Remove(result.Name);
                }

                Assert.AreEqual(0, logBlobNames.Count);
                Assert.AreEqual(0, analyticsClient.ListLogs(StorageService.Blob).Count());
            }
            finally
            {
                container.DeleteIfExists();
            }
        }