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()); } }
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.Profile); client.AddOrSetEnvironment(new AzureEnvironment { Name = name }); var cmdlet = new RemoveAzureRMEnvironmentCommand() { CommandRuntime = commandRuntimeMock.Object, Force = true, Name = name }; cmdlet.InvokeBeginProcessing(); cmdlet.ExecuteCmdlet(); cmdlet.InvokeEndProcessing(); Assert.False(AzureRmProfileProvider.Instance.Profile.Environments.ContainsKey(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", Force = true }; 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()); } }