public void TestUninstallAzureRmUnauthorized()
        {
            var dataStore = new MockDataStore();

            AzureSession.Instance.DataStore = dataStore;
            dataStore.CreateDirectory("testmodulepath");
            dataStore.CreateDirectory(Path.Combine("testmodulepath", "AzureRM.ApiManagement"));
            dataStore.WriteFile(Path.Combine("testmodulepath", Path.Combine("AzureRM.ApiManagement", "file1")), new byte[2]);
            dataStore.LockAccessToFile(Path.Combine("testmodulepath", "AzureRM.ApiManagement"));
            // Ensure read does not throw
            Assert.True(dataStore.DirectoryExists(Path.Combine("testmodulepath", "AzureRM.ApiManagement")));

            var cmdlet = new UninstallAzureRmCommand();

            Environment.SetEnvironmentVariable("PSModulePath", "testmodulepath");
            try
            {
                cmdlet.ExecuteCmdlet();
                // Throw incorrect exception if cmdlet does not throw
                Assert.True(false);
            }
            catch (UnauthorizedAccessException e)
            {
                Assert.Equal("Module deletion failed. Please close all PowerShell sessions to ensure no AzureRM modules are currently loaded, and rerun this cmdlet in Administrator mode.", e.Message);
            }
        }
        public void TestUninstallAzureRm()
        {
            var dataStore = new MockDataStore();

            AzureSession.Instance.DataStore = dataStore;
            dataStore.CreateDirectory("testmodulepath");
            dataStore.CreateDirectory(Path.Combine("testmodulepath", "AzureRM.ApiManagement"));
            dataStore.WriteFile(Path.Combine("testmodulepath", Path.Combine("AzureRM.ApiManagement", "file1")), new byte[2]);
            // Ensure read does not throw
            Assert.True(dataStore.DirectoryExists(Path.Combine("testmodulepath", "AzureRM.ApiManagement")));

            var cmdlet = new UninstallAzureRmCommand();

            Environment.SetEnvironmentVariable("PSModulePath", "testmodulepath");
            cmdlet.ExecuteCmdlet();
            Assert.False(dataStore.DirectoryExists(Path.Combine("testmodulepath", "AzureRM.ApiManagement")));
        }