Ejemplo n.º 1
0
        public void SaveAzureProfileNull()
        {
            SaveAzureRMProfileCommand cmdlt = new SaveAzureRMProfileCommand();

            // Setup
            AzureRmProfileProvider.Instance.Profile = null;
            cmdlt.Path           = "X:\\foo.json";
            cmdlt.CommandRuntime = commandRuntimeMock;

            // Act
            Assert.Throws <ArgumentException>(() => cmdlt.ExecuteCmdlet());
        }
Ejemplo n.º 2
0
        public void SaveAzureProfileInMemory()
        {
            var profile = new AzureRMProfile();

            profile.Environments.Add("foo", AzureEnvironment.PublicEnvironments.Values.FirstOrDefault());
            SaveAzureRMProfileCommand cmdlt = new SaveAzureRMProfileCommand();

            // 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"));
        }
Ejemplo n.º 3
0
        public void SaveAzureProfileFromDefault()
        {
            var profile = new AzureRMProfile();

            profile.Environments.Add("foo", AzureEnvironment.PublicEnvironments.Values.FirstOrDefault());
            profile.Context = new AzureContext(new AzureSubscription(), new AzureAccount(), profile.Environments["foo"]);
            AzureRmProfileProvider.Instance.Profile = profile;
            SaveAzureRMProfileCommand cmdlt = new SaveAzureRMProfileCommand();

            // Setup
            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"));
        }