public void SaveAzureProfileInMemory() { var profile = new AzureRMProfile(); profile.Environments.Add("foo", AzureEnvironment.PublicEnvironments.Values.FirstOrDefault()); #pragma warning disable CS0618 // Suppress obsolescence warning: cmdlet name is changing SaveAzureRMContextCommand cmdlt = new SaveAzureRMContextCommand(); #pragma warning restore CS0618 // Suppress obsolescence warning: cmdlet name is changing // Setup cmdlt.Profile = profile; cmdlt.Path = "X:\\foo.json"; cmdlt.CommandRuntime = commandRuntimeMock; // Act cmdlt.InvokeBeginProcessing(); cmdlt.ExecuteCmdlet(); cmdlt.InvokeEndProcessing(); // Verify Assert.True(AzureSession.DataStore.FileExists("X:\\foo.json")); var profile2 = new AzureRMProfile("X:\\foo.json"); Assert.True(profile2.Environments.ContainsKey("foo")); }
public void SaveAzureProfileFromDefault() { var profile = new AzureRmProfile(); profile.EnvironmentTable.Add("foo", new AzureEnvironment(AzureEnvironment.PublicEnvironments.Values.FirstOrDefault())); profile.DefaultContext = new AzureContext(new AzureSubscription(), new AzureAccount(), profile.EnvironmentTable["foo"]); AzureRmProfileProvider.Instance.Profile = profile; SaveAzureRMContextCommand cmdlt = new SaveAzureRMContextCommand(); // Setup cmdlt.Path = "X:\\foo.json"; cmdlt.CommandRuntime = commandRuntimeMock; // Act cmdlt.InvokeBeginProcessing(); cmdlt.ExecuteCmdlet(); cmdlt.InvokeEndProcessing(); // Verify Assert.True(AzureSession.Instance.DataStore.FileExists("X:\\foo.json")); var profile2 = new AzureRmProfile("X:\\foo.json"); Assert.True(profile2.EnvironmentTable.ContainsKey("foo")); }
public void SaveAzureProfileInMemory() { var profile = new AzureRmProfile(); profile.EnvironmentTable.Add("foo", new AzureEnvironment(AzureEnvironment.PublicEnvironments.Values.FirstOrDefault())); profile.EnvironmentTable["foo"].Name = "foo"; SaveAzureRMContextCommand cmdlt = new SaveAzureRMContextCommand(); // Setup cmdlt.Profile = profile; cmdlt.Path = "X:\\foo.json"; cmdlt.CommandRuntime = commandRuntimeMock; // Act cmdlt.InvokeBeginProcessing(); cmdlt.ExecuteCmdlet(); cmdlt.InvokeEndProcessing(); // Verify Assert.True(AzureSession.Instance.DataStore.FileExists("X:\\foo.json")); var profile2 = new AzureRmProfile("X:\\foo.json"); Assert.Contains(profile2.Environments, (e) => string.Equals(e.Name, "foo")); }