public void RemovesAzureEnvironment()
        {
            var commandRuntimeMock = new Mock <ICommandRuntime>();

            commandRuntimeMock.Setup(f => f.ShouldProcess(It.IsAny <string>(), It.IsAny <string>())).Returns(true);

            const string    name   = "test";
            RMProfileClient client = new RMProfileClient(AzureRmProfileProvider.Instance.GetProfile <AzureRmProfile>());

            client.AddOrSetEnvironment(new AzureEnvironment
            {
                Name = name
            });

            var cmdlet = new RemoveAzureRMEnvironmentCommand()
            {
                CommandRuntime = commandRuntimeMock.Object,
                Name           = name
            };

            cmdlet.InvokeBeginProcessing();
            cmdlet.ExecuteCmdlet();
            cmdlet.InvokeEndProcessing();

            Assert.False(AzureRmProfileProvider.Instance.Profile.HasEnvironment(name));
        }
        public void ThrowsForUnknownEnvironment()
        {
            Mock <ICommandRuntime> commandRuntimeMock = new Mock <ICommandRuntime>();

            commandRuntimeMock.Setup(f => f.ShouldProcess(It.IsAny <string>(), It.IsAny <string>())).Returns(true);

            var cmdlet = new RemoveAzureRMEnvironmentCommand()
            {
                CommandRuntime = commandRuntimeMock.Object,
                Name           = "test2",
            };

            cmdlet.InvokeBeginProcessing();
            Assert.Throws <ArgumentException>(() => cmdlet.ExecuteCmdlet());
        }
        public void ThrowsForPublicEnvironment()
        {
            Mock <ICommandRuntime> commandRuntimeMock = new Mock <ICommandRuntime>();

            SetupConfirmation(commandRuntimeMock);

            foreach (string name in AzureEnvironment.PublicEnvironments.Keys)
            {
                var cmdlet = new RemoveAzureRMEnvironmentCommand()
                {
                    CommandRuntime = commandRuntimeMock.Object,
                    Name           = name
                };

                cmdlet.InvokeBeginProcessing();
                Assert.Throws <ArgumentException>(() => cmdlet.ExecuteCmdlet());
            }
        }
Ejemplo n.º 4
0
        public void ThrowsForPublicEnvironment()
        {
            Mock <ICommandRuntime> commandRuntimeMock = new Mock <ICommandRuntime>();

            commandRuntimeMock.Setup(f => f.ShouldProcess(It.IsAny <string>(), It.IsAny <string>())).Returns(true);

            foreach (string name in AzureEnvironment.PublicEnvironments.Keys)
            {
                var cmdlet = new RemoveAzureRMEnvironmentCommand()
                {
                    CommandRuntime = commandRuntimeMock.Object,
                    Force          = true,
                    Name           = name
                };

                cmdlet.InvokeBeginProcessing();
                Assert.Throws <ArgumentException>(() => cmdlet.ExecuteCmdlet());
            }
        }