public void TestShowSnapshot()
        {
            IBlockStorageProvider  provider  = new CloudBlockStorageProvider(Bootstrapper.Settings.TestIdentity);
            IEnumerable <Snapshot> snapshots = provider.ListSnapshots();

            Assert.IsNotNull(snapshots);
            if (!snapshots.Any())
            {
                Assert.Inconclusive("The test could not proceed because the specified account and/or region does not appear to contain any snapshots.");
            }

            Console.WriteLine("Snapshots");
            foreach (Snapshot snapshot in snapshots)
            {
                Assert.IsNotNull(snapshot);
                Assert.IsFalse(string.IsNullOrEmpty(snapshot.Id));
                Snapshot showSnapshot = provider.ShowSnapshot(snapshot.Id);
                Assert.IsNotNull(showSnapshot);
                Assert.AreEqual(snapshot.CreatedAt, showSnapshot.CreatedAt);
                Assert.AreEqual(snapshot.DisplayDescription, showSnapshot.DisplayDescription);
                Assert.AreEqual(snapshot.DisplayName, showSnapshot.DisplayName);
                Assert.AreEqual(snapshot.Id, showSnapshot.Id);
                Assert.AreEqual(snapshot.Size, showSnapshot.Size);
                //Assert.AreEqual(snapshot.Status, showSnapshot.Status);
                Assert.AreEqual(snapshot.VolumeId, showSnapshot.VolumeId);
            }
        }
        public void Should_Delete_Test_Snapshot()
        {
            var provider             = new CloudBlockStorageProvider();
            var snapshotListResponse = provider.ListSnapshots(identity: _testIdentity);

            if (snapshotListResponse != null && snapshotListResponse.Any())
            {
                var testSnapshot = snapshotListResponse.FirstOrDefault(x => x.DisplayName == snapshotDisplayName);
                if (testSnapshot == null)
                {
                    Assert.Fail("Could not find test snapshot to delete.");
                }
                var deleteSnapshotResult = provider.DeleteSnapshot(testSnapshot.Id, identity: _testIdentity);

                if (deleteSnapshotResult)
                {
                    var snapshotDeleteDetails = provider.WaitForSnapshotDeleted(testSnapshot.Id, identity: _testIdentity);
                    Assert.IsTrue(snapshotDeleteDetails);
                }
                else
                {
                    Assert.Fail("Test snapshot was not deleted.");
                }
            }
            else
            {
                Assert.Fail("No snapshots present to test delete.");
            }
        }
        public void Should_Return_Snapshot_List()
        {
            var provider             = new CloudBlockStorageProvider();
            var snapshotListResponse = provider.ListSnapshots(identity: _testIdentity);

            Assert.IsNotNull(snapshotListResponse);
            Assert.IsTrue(snapshotListResponse.Any());
        }
        public void Should_Cleanup_CloudBlockStorage_Environment()
        {
            var provider           = new CloudBlockStorageProvider();
            var volumeListResponse = provider.ListVolumes(identity: _testIdentity);

            if (volumeListResponse == null || !volumeListResponse.Any())
            {
                return;
            }

            var testVolumeList = volumeListResponse.Where(x => x.DisplayName == volumeDisplayName);

            if (!testVolumeList.Any())
            {
                return;
            }

            var snapshotList = provider.ListSnapshots(identity: _testIdentity);

            if (snapshotList != null && snapshotList.Any())
            {
                foreach (var testVolume in testVolumeList)
                {
                    var testVolumeSnapshots = snapshotList.Where(x => x.VolumeId == testVolume.Id);

                    if (testVolumeSnapshots.Any())
                    {
                        foreach (var testSnapshot in testVolumeSnapshots)
                        {
                            var deleteSnapshotResult = provider.DeleteSnapshot(testSnapshot.Id,
                                                                               identity: _testIdentity);

                            if (deleteSnapshotResult)
                            {
                                var snapshotDeleteDetails = provider.WaitForSnapshotDeleted(testSnapshot.Id,
                                                                                            identity: _testIdentity);
                                Assert.IsTrue(snapshotDeleteDetails);
                            }
                            else
                            {
                                Assert.Fail(string.Format("Snapshot (Volume ID: {0} -- Snapshot ID:{1}) could not be deleted.", testVolume.Id, testSnapshot.Id));
                            }
                        }
                    }
                }
            }

            foreach (var testVolume in testVolumeList)
            {
                var deleteVolumeResults = provider.DeleteVolume(testVolume.Id, identity: _testIdentity);
                Assert.IsTrue(deleteVolumeResults);
                var volumeWaitForDeletedResult = provider.WaitForVolumeDeleted(testVolume.Id, identity: _testIdentity);
                Assert.IsTrue(volumeWaitForDeletedResult);
            }
        }
        public void TestListSnapshots()
        {
            IBlockStorageProvider  provider  = new CloudBlockStorageProvider(Bootstrapper.Settings.TestIdentity);
            IEnumerable <Snapshot> snapshots = provider.ListSnapshots();

            Assert.IsNotNull(snapshots);
            if (!snapshots.Any())
            {
                Assert.Inconclusive("The test could not proceed because the specified account and/or region does not appear to contain any snapshots.");
            }

            Console.WriteLine("Snapshots");
            foreach (Snapshot snapshot in snapshots)
            {
                Assert.IsNotNull(snapshot);
                Assert.IsFalse(string.IsNullOrEmpty(snapshot.Id));
                Console.WriteLine(JsonConvert.SerializeObject(snapshot, Formatting.Indented));
            }
        }
        public void CleanupTestSnapshots()
        {
            IBlockStorageProvider  provider  = new CloudBlockStorageProvider(Bootstrapper.Settings.TestIdentity);
            IEnumerable <Snapshot> snapshots = provider.ListSnapshots();

            foreach (Snapshot snapshot in snapshots)
            {
                if (string.IsNullOrEmpty(snapshot.DisplayName))
                {
                    continue;
                }

                if (!snapshot.DisplayName.StartsWith(UnitTestSnapshotPrefix))
                {
                    continue;
                }

                Console.WriteLine("Deleting unit test snapshot... {0} ({1})", snapshot.DisplayName, snapshot.Id);
                provider.DeleteSnapshot(snapshot.Id);
            }
        }
        public void Should_Return_Test_Snapshot()
        {
            var provider = new CloudBlockStorageProvider();

            var snapshotListResponse = provider.ListSnapshots(identity: _testIdentity);

            if (snapshotListResponse != null && snapshotListResponse.Any())
            {
                var testSnapshot = snapshotListResponse.FirstOrDefault(x => x.DisplayName == snapshotDisplayName);
                if (testSnapshot == null)
                {
                    Assert.Fail("Could not retrieve test snapshot");
                }
                var singleSnapshotResponse = provider.ShowSnapshot(testSnapshot.Id, identity: _testIdentity);
                Assert.IsNotNull(singleSnapshotResponse);
                Assert.IsTrue(singleSnapshotResponse.Id == testSnapshot.Id);
            }
            else
            {
                Assert.Fail("No snapshots present to query.");
            }
        }
        public void Should_Wait_Until_Test_Snapshot_Becomes_Available_Or_Exceeds_Timeout_For_Becoming_Available()
        {
            var provider = new CloudBlockStorageProvider();

            var snapshotListResponse = provider.ListSnapshots(identity: _testIdentity);

            if (snapshotListResponse != null && snapshotListResponse.Any())
            {
                var testSnapshot = snapshotListResponse.FirstOrDefault(x => x.DisplayName == snapshotDisplayName);
                if (testSnapshot == null)
                {
                    Assert.Fail("Could not find test snapshot to query for Available status.");
                }

                var snapshotDetails = provider.WaitForSnapshotAvailable(testSnapshot.Id, identity: _testIdentity);
                Assert.IsNotNull(snapshotDetails);
                Assert.AreEqual(SnapshotState.Available, snapshotDetails.Status);
            }
            else
            {
                Assert.Fail("No snapshots present to obtain Available status.");
            }
        }
        public void Should_Cleanup_CloudBlockStorage_Environment()
        {
            var provider = new CloudBlockStorageProvider();
            var volumeListResponse = provider.ListVolumes(identity: _testIdentity);

            if (volumeListResponse == null || !volumeListResponse.Any()) return;

            var testVolumeList = volumeListResponse.Where(x => x.DisplayName == volumeDisplayName);
            if (!testVolumeList.Any()) return;

            var snapshotList = provider.ListSnapshots(identity: _testIdentity);
            if (snapshotList != null && snapshotList.Any())
            {
                foreach (var testVolume in testVolumeList)
                {
                    var testVolumeSnapshots = snapshotList.Where(x => x.VolumeId == testVolume.Id);

                    if (testVolumeSnapshots.Any())
                    {
                        foreach (var testSnapshot in testVolumeSnapshots)
                        {
                            var deleteSnapshotResult = provider.DeleteSnapshot(testSnapshot.Id,
                                                                               identity: _testIdentity);

                            if (deleteSnapshotResult)
                            {
                                var snapshotDeleteDetails = provider.WaitForSnapshotDeleted(testSnapshot.Id,
                                                                                            identity: _testIdentity);
                                Assert.IsTrue(snapshotDeleteDetails);
                            }
                            else
                            {
                                Assert.Fail(string.Format("Snapshot (Volume ID: {0} -- Snapshot ID:{1}) could not be deleted.", testVolume.Id, testSnapshot.Id));
                            }

                        }
                    }
                }
            }

            foreach (var testVolume in testVolumeList)
            {
                var deleteVolumeResults = provider.DeleteVolume(testVolume.Id, identity: _testIdentity);
                Assert.IsTrue(deleteVolumeResults);
                var volumeWaitForDeletedResult = provider.WaitForVolumeDeleted(testVolume.Id, identity: _testIdentity);
                Assert.IsTrue(volumeWaitForDeletedResult);
            }
        }
        public void Should_Delete_Test_Snapshot()
        {
            var provider = new CloudBlockStorageProvider();
            var snapshotListResponse = provider.ListSnapshots(identity: _testIdentity);
            if (snapshotListResponse != null && snapshotListResponse.Any())
            {
                var testSnapshot = snapshotListResponse.FirstOrDefault(x => x.DisplayName == snapshotDisplayName);
                if (testSnapshot == null)
                {
                    Assert.Fail("Could not find test snapshot to delete.");
                }
                var deleteSnapshotResult = provider.DeleteSnapshot(testSnapshot.Id, identity: _testIdentity);

                if (deleteSnapshotResult)
                {
                    var snapshotDeleteDetails = provider.WaitForSnapshotDeleted(testSnapshot.Id, identity: _testIdentity);
                    Assert.IsTrue(snapshotDeleteDetails);
                }
                else
                {
                    Assert.Fail("Test snapshot was not deleted.");
                }
            }
            else
            {
                Assert.Fail("No snapshots present to test delete.");
            }
        }
        public void Should_Return_Test_Snapshot()
        {
            var provider = new CloudBlockStorageProvider();

            var snapshotListResponse = provider.ListSnapshots(identity: _testIdentity);
            if (snapshotListResponse != null && snapshotListResponse.Any())
            {
                var testSnapshot = snapshotListResponse.FirstOrDefault(x => x.DisplayName == snapshotDisplayName);
                if (testSnapshot == null)
                {
                    Assert.Fail("Could not retrieve test snapshot");
                }
                var singleSnapshotResponse = provider.ShowSnapshot(testSnapshot.Id, identity: _testIdentity);
                Assert.IsNotNull(singleSnapshotResponse);
                Assert.IsTrue(singleSnapshotResponse.Id == testSnapshot.Id);
            }
            else
            {
                Assert.Fail("No snapshots present to query.");
            }
        }
 public void Should_Return_Snapshot_List()
 {
     var provider = new CloudBlockStorageProvider();
     var snapshotListResponse = provider.ListSnapshots(identity: _testIdentity);
     Assert.IsNotNull(snapshotListResponse);
     Assert.IsTrue(snapshotListResponse.Any());
 }
        public void Should_Wait_Until_Test_Snapshot_Becomes_Available_Or_Exceeds_Timeout_For_Becoming_Available()
        {
            var provider = new CloudBlockStorageProvider();

            var snapshotListResponse = provider.ListSnapshots(identity: _testIdentity);
            if (snapshotListResponse != null && snapshotListResponse.Any())
            {
                var testSnapshot = snapshotListResponse.FirstOrDefault(x => x.DisplayName == snapshotDisplayName);
                if (testSnapshot == null)
                {
                    Assert.Fail("Could not find test snapshot to query for Available status.");
                }

                var snapshotDetails = provider.WaitForSnapshotAvailable(testSnapshot.Id, identity: _testIdentity);
                Assert.IsNotNull(snapshotDetails);
                Assert.AreEqual(SnapshotState.Available, snapshotDetails.Status);

            }
            else
            {
                Assert.Fail("No snapshots present to obtain Available status.");
            }
        }
        public void TestShowSnapshot()
        {
            IBlockStorageProvider provider = new CloudBlockStorageProvider(Bootstrapper.Settings.TestIdentity);
            IEnumerable<Snapshot> snapshots = provider.ListSnapshots();
            Assert.IsNotNull(snapshots);
            if (!snapshots.Any())
                Assert.Inconclusive("The test could not proceed because the specified account and/or region does not appear to contain any snapshots.");

            Console.WriteLine("Snapshots");
            foreach (Snapshot snapshot in snapshots)
            {
                Assert.IsNotNull(snapshot);
                Assert.IsFalse(string.IsNullOrEmpty(snapshot.Id));
                Snapshot showSnapshot = provider.ShowSnapshot(snapshot.Id);
                Assert.IsNotNull(showSnapshot);
                Assert.AreEqual(snapshot.CreatedAt, showSnapshot.CreatedAt);
                Assert.AreEqual(snapshot.DisplayDescription, showSnapshot.DisplayDescription);
                Assert.AreEqual(snapshot.DisplayName, showSnapshot.DisplayName);
                Assert.AreEqual(snapshot.Id, showSnapshot.Id);
                Assert.AreEqual(snapshot.Size, showSnapshot.Size);
                //Assert.AreEqual(snapshot.Status, showSnapshot.Status);
                Assert.AreEqual(snapshot.VolumeId, showSnapshot.VolumeId);
            }
        }
        public void TestListSnapshots()
        {
            IBlockStorageProvider provider = new CloudBlockStorageProvider(Bootstrapper.Settings.TestIdentity);
            IEnumerable<Snapshot> snapshots = provider.ListSnapshots();
            Assert.IsNotNull(snapshots);
            if (!snapshots.Any())
                Assert.Inconclusive("The test could not proceed because the specified account and/or region does not appear to contain any snapshots.");

            Console.WriteLine("Snapshots");
            foreach (Snapshot snapshot in snapshots)
            {
                Assert.IsNotNull(snapshot);
                Assert.IsFalse(string.IsNullOrEmpty(snapshot.Id));
                Console.WriteLine(JsonConvert.SerializeObject(snapshot, Formatting.Indented));
            }
        }
        public void CleanupTestSnapshots()
        {
            IBlockStorageProvider provider = new CloudBlockStorageProvider(Bootstrapper.Settings.TestIdentity);
            IEnumerable<Snapshot> snapshots = provider.ListSnapshots();
            foreach (Snapshot snapshot in snapshots)
            {
                if (string.IsNullOrEmpty(snapshot.DisplayName))
                    continue;

                if (!snapshot.DisplayName.StartsWith(UnitTestSnapshotPrefix))
                    continue;

                Console.WriteLine("Deleting unit test snapshot... {0} ({1})", snapshot.DisplayName, snapshot.Id);
                provider.DeleteSnapshot(snapshot.Id);
            }
        }