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";
            var          profile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));

            AzureSMCmdlet.CurrentProfile = profile;
            ProfileClient client = new ProfileClient(profile);

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

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

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

            client = new ProfileClient(new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
            Assert.False(client.Profile.Environments.ContainsKey(name));
        }
        public void ThrowsForUnknownEnvironment()
        {
            Mock<ICommandRuntime> commandRuntimeMock = new Mock<ICommandRuntime>();
            RemoveAzureEnvironmentCommand cmdlet = new RemoveAzureEnvironmentCommand()
            {
                CommandRuntime = commandRuntimeMock.Object,
                Name = "test2"
            };

            Testing.AssertThrows<KeyNotFoundException>(
                () => cmdlet.ExecuteCmdlet(),
                string.Format(Resources.EnvironmentNotFound, "test2"));
        }
        public void ThrowsForUnknownEnvironment()
        {
            Mock <ICommandRuntime>        commandRuntimeMock = new Mock <ICommandRuntime>();
            RemoveAzureEnvironmentCommand cmdlet             = new RemoveAzureEnvironmentCommand()
            {
                CommandRuntime = commandRuntimeMock.Object,
                Name           = "test2"
            };

            Testing.AssertThrows <KeyNotFoundException>(
                () => cmdlet.ExecuteCmdlet(),
                string.Format(Resources.EnvironmentNotFound, "test2"));
        }
        public void ThrowsForUnknownEnvironment()
        {
            Mock <ICommandRuntime> commandRuntimeMock = new Mock <ICommandRuntime>();

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

            RemoveAzureEnvironmentCommand cmdlet = new RemoveAzureEnvironmentCommand()
            {
                CommandRuntime = commandRuntimeMock.Object,
                Name           = "test2",
                Force          = true
            };

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

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

                Testing.AssertThrows <InvalidOperationException>(
                    () => cmdlet.ExecuteCmdlet(),
                    string.Format(Resources.ChangePublicEnvironmentMessage, name));
            }
        }
Beispiel #6
0
        public void RemovesAzureEnvironment()
        {
            Mock <ICommandRuntime> commandRuntimeMock = new Mock <ICommandRuntime>();
            string name = "test";

            GlobalSettingsManager.Instance.AddEnvironment(name, "test url");
            RemoveAzureEnvironmentCommand cmdlet = new RemoveAzureEnvironmentCommand()
            {
                CommandRuntime = commandRuntimeMock.Object,
                Name           = name
            };

            cmdlet.ExecuteCmdlet();

            Testing.AssertThrows <KeyNotFoundException>(
                () => GlobalSettingsManager.Instance.GetEnvironment(name),
                string.Format(Resources.EnvironmentNotFound, name));
        }
        public void RemovesAzureEnvironment()
        {
            var commandRuntimeMock = new Mock<ICommandRuntime>();
            const string name = "test";
            testProfile.AddEnvironment(new WindowsAzureEnvironment
            {
                Name = name,
                PublishSettingsFileUrl = "test url"
            });

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

            cmdlet.ExecuteCmdlet();
            Assert.IsFalse(WindowsAzureProfile.Instance.Environments.ContainsKey(name));
        }
        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)
            {
                RemoveAzureEnvironmentCommand cmdlet = new RemoveAzureEnvironmentCommand()
                {
                    CommandRuntime = commandRuntimeMock.Object,
                    Force          = true,
                    Name           = name
                };

                cmdlet.InvokeBeginProcessing();
                Assert.Throws <ArgumentException>(() => cmdlet.ExecuteCmdlet());
            }
        }
        public void RemovesAzureEnvironment()
        {
            var          commandRuntimeMock = new Mock <ICommandRuntime>();
            const string name = "test";

            testProfile.AddEnvironment(new WindowsAzureEnvironment
            {
                Name = name,
                PublishSettingsFileUrl = "test url"
            });

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

            cmdlet.ExecuteCmdlet();
            Assert.IsFalse(WindowsAzureProfile.Instance.Environments.ContainsKey(name));
        }
        public void ThrowsForPublicEnvironment()
        {
            Mock<ICommandRuntime> commandRuntimeMock = new Mock<ICommandRuntime>();

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

                Testing.AssertThrows<InvalidOperationException>(
                    () => cmdlet.ExecuteCmdlet(),
                    string.Format(Resources.ChangePublicEnvironmentMessage, name));
            }
        }