public void TestPublishFilesImpersonateCancelCredentials() { var project = DebugProject.OpenProject(@"Python.VS.TestData\HelloWorld.sln"); try { string subDir = Guid.NewGuid().ToString(); project.Properties.Item("PublishUrl").Value = Path.Combine(TestSharePrivate, subDir); string dir = Path.Combine(TestSharePrivate, subDir); var app = new VisualStudioApp(VsIdeTestHostContext.Dte); app.OpenSolutionExplorer(); var window = app.SolutionExplorerTreeView; // find Program.py, send copy & paste, verify copy of file is there var programPy = window.FindItem("Solution 'HelloWorld' (1 project)", "HelloWorld"); programPy.SetFocus(); ThreadPool.QueueUserWorkItem(x => VsIdeTestHostContext.Dte.ExecuteCommand("Build.PublishSelection")); var creds = new CredentialsDialog(app.WaitForDialog()); creds.UserName = PrivateShareUser; creds.Password = PrivateSharePasswordIncorrect; creds.Cancel(); System.Threading.Thread.Sleep(2000); var statusBar = (IVsStatusbar)VsIdeTestHostContext.ServiceProvider.GetService(typeof(SVsStatusbar)); string text; ErrorHandler.ThrowOnFailure(statusBar.GetText(out text)); const string expected = "Publish failed: Access to the path '"; Assert.IsTrue(text.StartsWith(expected), "Expected '{0}', got '{1}'", expected, text); } finally { project.Properties.Item("PublishUrl").Value = ""; } }