Inheritance: global::System.Configuration.ApplicationSettingsBase
コード例 #1
0
		public void TestStartupModeConnect()
		{
			var mocks = new MockRepository();

			var form = new Form(); // Visual Studio main window.
			var toolWindowControl = new ToolWindowControl {Dock = DockStyle.Fill}; // To Do tool window control.
			form.Controls.Add(toolWindowControl);
			DTE2 application;
			AddIn addin;

			using (mocks.Record())
			{
				MockDte(mocks, form, toolWindowControl, out application, out addin);
			}

			var settings = new Settings
			               	{
			               		Uri = new Uri("http://localhost/tp2"),
			               		Login = "******",
			               		DecryptedPassword = "******",
			               		AutoLogin = true,
			               		AutoRefresh = false,
			               	};
			settings.Save();

			using (mocks.Playback())
			{
				Array array = null;

				// Create addin instance.
				var connect = new Connect();

				Console.WriteLine("Test started");

				// Display Visual Studio main window.
				form.Show();

				// Connect addin instance to Visual Studio.
				connect.OnConnection(application, ext_ConnectMode.ext_cm_Startup, addin, ref array);
				connect.OnStartupComplete(ref array);

				// Check command statuses.
				vsCommandStatus status = vsCommandStatus.vsCommandStatusUnsupported;
				object tmp = null;

				connect.QueryStatus(addin.ProgID + "." + Connect.CmdLogin, vsCommandStatusTextWanted.vsCommandStatusTextWantedNone,
				                    ref status, ref tmp);
				Assert.AreEqual(vsCommandStatus.vsCommandStatusSupported, status);

				connect.QueryStatus(addin.ProgID + "." + Connect.CmdLogout, vsCommandStatusTextWanted.vsCommandStatusTextWantedNone,
				                    ref status, ref tmp);
				Assert.AreEqual(vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled, status);

				connect.QueryStatus(addin.ProgID + "." + Connect.CmdToDoList,
				                    vsCommandStatusTextWanted.vsCommandStatusTextWantedNone, ref status, ref tmp);
				Assert.AreEqual(vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled, status);

				connect.QueryStatus(addin.ProgID + "." + Connect.CmdOptions, vsCommandStatusTextWanted.vsCommandStatusTextWantedNone,
				                    ref status, ref tmp);
				Assert.AreEqual(vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled, status);

				// Execute some commands.
				bool handled = false;
				connect.Exec(addin.ProgID + "." + Connect.CmdToDoList, vsCommandExecOption.vsCommandExecOptionDoDefault, ref tmp,
				             ref tmp, ref handled);
				Assert.IsTrue(handled);

				form.Closed += (sender, e) =>
				               	{
				               		// Disconnect addin instance from Visual Studio.
				               		connect.OnDisconnection(ext_DisconnectMode.ext_dm_HostShutdown, ref array);
				               		Console.WriteLine("Test ended");
				               	};
				Application.Run(form);
			}
		}
コード例 #2
0
		/// <summary>
		/// Implements the OnStartupComplete method of the IDTExtensibility2 interface. Receives notification that the host application has completed loading.
		/// </summary>
		/// <param name='custom'>
		/// Array of parameters that are host application specific.
		/// </param>
		/// <seealso class='IDTExtensibility2' />
		public void OnStartupComplete(ref Array custom)
		{
			try
			{
				var settings = new Settings();
				if (settings.AutoLogin)
				{
					_toolWindow.Visible = true;
					_controller.Connect(false);
				}
			}
			catch (Exception ex)
			{
				_listener.WriteLine(ex);
			}
		}