public void LoginUsingSkipValidation() { var cmdlt = new AddAzureRMAccountCommand(); // Setup cmdlt.CommandRuntime = commandRuntimeMock; cmdlt.AccessToken = "test"; cmdlt.AccessToken = "*****@*****.**"; cmdlt.SkipValidation = true; cmdlt.TenantId = Guid.NewGuid().ToString(); cmdlt.Subscription = Guid.NewGuid().ToString(); cmdlt.SetBoundParameters(new Dictionary <string, object>() { { "Subscription", cmdlt.Subscription } }); cmdlt.SetParameterSet("AccessTokenWithSubscriptionId"); cmdlt.InvokeBeginProcessing(); cmdlt.ExecuteCmdlet(); cmdlt.InvokeEndProcessing(); Assert.NotNull(AzureRmProfileProvider.Instance.Profile.DefaultContext); Assert.Equal(AzureRmProfileProvider.Instance.Profile.DefaultContext.Subscription.Id, cmdlt.Subscription); Assert.Equal(AzureRmProfileProvider.Instance.Profile.DefaultContext.Tenant.Id, cmdlt.TenantId); }
public void ThrowOnUnknownEnvironment() { var cmdlt = new AddAzureRMAccountCommand(); // Setup cmdlt.CommandRuntime = commandRuntimeMock; cmdlt.Environment = "unknown"; var testPassed = false; cmdlt.SetBoundParameters(new Dictionary <string, object>() { { "Environment", "unknown" } }); cmdlt.SetParameterSet("UserWithSubscriptionId"); // Act try { cmdlt.InvokeBeginProcessing(); } catch (TargetInvocationException ex) { Assert.NotNull(ex); Assert.NotNull(ex.InnerException); Assert.Equal("Unable to find environment with name 'unknown'", ex.InnerException.Message); testPassed = true; } Assert.True(testPassed); }