ExecuteCmdlet() private method

private ExecuteCmdlet ( ) : void
return void
        public void ImportPublishSettingsFileOverwritesEnvironment()
        {
            ImportAzurePublishSettingsCommand cmdlt = new ImportAzurePublishSettingsCommand();

            // Setup
            ProfileClient.DataStore.WriteFile("ImportPublishSettingsFileSelectsCorrectEnvironment.publishsettings",
                Properties.Resources.ValidProfileChina);
            ProfileClient client = new ProfileClient();
            var oldDataStore = FileUtilities.DataStore;
            FileUtilities.DataStore = ProfileClient.DataStore;
            var expectedEnv = "AzureCloud";
            var expected = client.ImportPublishSettings("ImportPublishSettingsFileSelectsCorrectEnvironment.publishsettings", expectedEnv);

            cmdlt.CommandRuntime = commandRuntimeMock.Object;
            cmdlt.ProfileClient = new ProfileClient();
            cmdlt.PublishSettingsFile = "ImportPublishSettingsFileSelectsCorrectEnvironment.publishsettings";
            cmdlt.Environment = expectedEnv;

            try
            {
                // Act
                cmdlt.InvokeBeginProcessing();
                cmdlt.ExecuteCmdlet();
                cmdlt.InvokeEndProcessing();

                // Verify
                foreach (var subscription in expected)
                {
                    Assert.Equal(cmdlt.ProfileClient.GetSubscription(subscription.Id).Environment, expectedEnv);
                }
                commandRuntimeMock.Verify(f => f.WriteObject(expected), Times.Once());
            }
            finally
            {
                // Cleanup
                FileUtilities.DataStore = oldDataStore;
            }
        }
        public void ImportPublishSettingsWorksForCustomProfile()
        {
            ImportAzurePublishSettingsCommand cmdlt = new ImportAzurePublishSettingsCommand();
            var oldAzureDataStore = AzureSession.DataStore;
            AzureSession.DataStore = new MemoryDataStore();
            // Setup
            AzureSession.DataStore.WriteFile("ImportPublishSettingsFileSelectsCorrectEnvironment.publishsettings",
                Commands.Common.Test.Properties.Resources.ValidProfileChina);
            var oldProfile = new AzureProfile();
            AzurePSCmdlet.CurrentProfile = oldProfile;
            var profile = new AzureProfile();
            ProfileClient client = new ProfileClient(profile);
            var oldDataStore = FileUtilities.DataStore;
            FileUtilities.DataStore = AzureSession.DataStore;
            var expectedEnv = "AzureCloud";
            var expected = client.ImportPublishSettings("ImportPublishSettingsFileSelectsCorrectEnvironment.publishsettings", expectedEnv);
            AzurePSCmdlet.CurrentProfile = new AzureProfile();
            cmdlt.Profile = profile;
            cmdlt.CommandRuntime = commandRuntimeMock;
            cmdlt.ProfileClient = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
            cmdlt.PublishSettingsFile = "ImportPublishSettingsFileSelectsCorrectEnvironment.publishsettings";
            cmdlt.Environment = expectedEnv;

            try
            {
                // Act
                cmdlt.InvokeBeginProcessing();
                cmdlt.ExecuteCmdlet();
                cmdlt.InvokeEndProcessing();

                // Verify
                foreach (var subscription in expected)
                {
                    Assert.Equal(client.GetSubscription(subscription.Id).Environment, expectedEnv);
                }
                Assert.Equal(1, commandRuntimeMock.OutputPipeline.Count);
                Assert.Equal(oldProfile.Subscriptions.Count, 0);
                Assert.Equal(oldProfile.Accounts.Count, 0);
            }
            finally
            {
                // Cleanup
                FileUtilities.DataStore = oldDataStore;
                AzureSession.DataStore = oldAzureDataStore;
            }
        }