forked from EgorBo/Xamaridea
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMenuItemTest.cs
66 lines (58 loc) · 2.24 KB
/
MenuItemTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System;
using System.Globalization;
using System.ComponentModel.Design;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.OLE.Interop;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Shell;
using Microsoft.VsSDK.IntegrationTestLibrary;
using Microsoft.VSSDK.Tools.VsIdeTesting;
namespace Xamaridea.VisualStudioPlugin_IntegrationTests
{
[TestClass()]
public class MenuItemTest
{
private delegate void ThreadInvoker();
private TestContext testContextInstance;
/// <summary>
///Gets or sets the test context which provides
///information about and functionality for the current test run.
///</summary>
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
/// <summary>
///A test for lauching the command and closing the associated dialogbox
///</summary>
[TestMethod()]
[HostType("VS IDE")]
public void LaunchCommand()
{
UIThreadInvoker.Invoke((ThreadInvoker)delegate()
{
CommandID menuItemCmd = new CommandID(EgorBo.Xamaridea_VisualStudioPlugin.GuidList.guidXamaridea_VisualStudioPluginCmdSet, (int)EgorBo.Xamaridea_VisualStudioPlugin.PkgCmdIDList.cmdidOpenInIdeaCommand);
// Create the DialogBoxListener Thread.
string expectedDialogBoxText = string.Format(CultureInfo.CurrentCulture, "{0}\n\nInside {1}.MenuItemCallback()", "Xamaridea.VisualStudioPlugin", "EgorBo.Xamaridea_VisualStudioPlugin.Xamaridea_VisualStudioPluginPackage");
DialogBoxPurger purger = new DialogBoxPurger(NativeMethods.IDOK, expectedDialogBoxText);
try
{
purger.Start();
TestUtils testUtils = new TestUtils();
testUtils.ExecuteCommand(menuItemCmd);
}
finally
{
Assert.IsTrue(purger.WaitForDialogThreadToTerminate(), "The dialog box has not shown");
}
});
}
}
}