public void CommandOperator_DefaultValues_SetsNothing()
        {
            var expected = new StartAzureStorageBlobCopyCommand();

            Command actual = expected;

            Assert.That(actual.Parameters, Is.Empty);
        }
        public void CommandOperator_DestContainerIsEmpty_SetsNothing()
        {
            var expected = new StartAzureStorageBlobCopyCommand
            {
                DestContainer = String.Empty
            };

            Command command = expected;
            var actual = command.Parameters.FirstOrDefault(x => x.Name == StartAzureStorageBlobCopyCommand.DestContainerParameter);

            Assert.That(actual, Is.Null);
        }
        public void CommandOperator_DestContainerIsSomething_SetsDestContainer()
        {
            var expected = new StartAzureStorageBlobCopyCommand
            {
                DestContainer = "SomeContainer"
            };

            Command command = expected;
            var actual = command.Parameters.FirstOrDefault(x => x.Name == StartAzureStorageBlobCopyCommand.DestContainerParameter);

            Assert.That(actual, Is.Not.Null);
            Assert.That(actual.Value, Is.EqualTo(expected.DestContainer));
        }
예제 #4
0
        private static void CopyVirtualHardDrive(IPowershellExecutor executor, string sourceVhdName, string vhdContainerName, string dataDiskName)
        {
            var azureStorageBlobCopyCommand = new StartAzureStorageBlobCopyCommand
            {
                SrcBlob = sourceVhdName,
                SrcContainer = vhdContainerName,
                DestContainer = vhdContainerName,
                DestBlob = String.Format("{0}.vhd", dataDiskName),
                Force = true
            };

            var results = executor.Execute(azureStorageBlobCopyCommand);

            if (results.Any())
            {
                var copyPending = false;

                var getAzureStorageBlobCopyStateCommand = new GetAzureStorageBlobCopyStateCommand();

                do
                {
                    var copyResult = executor.Execute(results, getAzureStorageBlobCopyStateCommand)
                        .OfType<PSObject>()
                        .Select(x => x.BaseObject)
                        .FirstOrDefault();

                    if (copyResult != null)
                    {
                        var type = copyResult.GetType();

                        var property = type.GetProperty("Status", BindingFlags.Instance | BindingFlags.Public);

                        var value = String.Format("{0}", property.GetValue(copyResult));

                        copyPending = (value == "Pending");
                    }

                    if (copyPending)
                    {
                        Thread.Sleep(10);
                    }
                } while (copyPending);
            }
        }
        public void CommandOperator_ForceIsTrue_SetsForce()
        {
            var expected = new StartAzureStorageBlobCopyCommand
            {
                Force = true
            };

            Command command = expected;
            var actual = command.Parameters.FirstOrDefault(x => x.Name == StartAzureStorageBlobCopyCommand.ForceParameter);

            Assert.That(actual, Is.Not.Null);
        }
        public void CommandOperator_SrcBlobIsSomething_SetsSrcBlob()
        {
            var expected = new StartAzureStorageBlobCopyCommand
            {
                SrcBlob = "SomeBlob"
            };

            Command command = expected;
            var actual = command.Parameters.FirstOrDefault(x => x.Name == StartAzureStorageBlobCopyCommand.SrcBlobParameter);

            Assert.That(actual, Is.Not.Null);
            Assert.That(actual.Value, Is.EqualTo(expected.SrcBlob));
        }