SIL.FieldWorks.FwCoreDlgs.DummyWritingSystemPropertiesDialog.VerifyAddWsContextMenuItems C# (CSharp) Method

VerifyAddWsContextMenuItems() private method

private VerifyAddWsContextMenuItems ( string expectedItems ) : void
expectedItems string
return void
		internal void VerifyAddWsContextMenuItems(string[] expectedItems)
		{
			using (ContextMenuStrip cms = PopulateAddWsContextMenu())
			{
				if (expectedItems != null)
				{
					Assert.AreEqual(expectedItems.Length, cms.Items.Count);
					List<string> actualItems = (from ToolStripItem item in cms.Items select item.ToString()).ToList();
					foreach (string item in expectedItems)
						Assert.Contains(item, actualItems);
				}
				else
				{
					// don't expect a context menu
					Assert.AreEqual(0, cms.Items.Count);
				}
			}
		}

Usage Example

Ejemplo n.º 1
0
 public void General_AddNewWs_OK()
 {
     m_dlg.ShowDialog(m_wsKalaba);
     // Verify Remove doesn't (yet) do anything for Wss already in the Database.
     m_dlg.VerifyListBox(new[] { "Kalaba", "Kalaba (International Phonetic Alphabet)" });
     m_dlg.PressDeleteButton();
     m_dlg.VerifyListBox(new[] { "Kalaba", "Kalaba (International Phonetic Alphabet)" });
     // Switch tabs, so we can test that Add New Ws will switch to General Tab.
     m_dlg.SwitchTab(FwWritingSystemSetupDlg.kWsFonts);
     m_dlg.VerifyTab(FwWritingSystemSetupDlg.kWsFonts);
     m_dlg.VerifyAddWsContextMenuItems(new[] { "&Writing System for Kalaba..." });
     // Click on Add Button...selecting "Add New..." option.
     m_dlg.PressBtnAdd("&Writing System for Kalaba...");
     // Verify WsList has new item and it is selected
     m_dlg.VerifyListBox(new[] { "Kalaba", "Kalaba", "Kalaba (International Phonetic Alphabet)" });
     m_dlg.VerifyLoadedForListBoxSelection("Kalaba");
     // verify we automatically switched back to General Tab.
     m_dlg.VerifyTab(FwWritingSystemSetupDlg.kWsGeneral);
     // Verify Switching context is not OK (force user to make unique Ws)
     m_dlg.SwitchTab(FwWritingSystemSetupDlg.kWsFonts,
                     DummyWritingSystemPropertiesDialog.ShowMsgBoxStatus.CheckCantCreateDuplicateWs,
                     DialogResult.OK);
     m_dlg.VerifyTab(FwWritingSystemSetupDlg.kWsGeneral);
     // make sure we can't select a different ethnologue code.
     m_dlg.SelectEthnologueCodeDlg("", "", "", DialogResult.OK,
                                   new[] { DummyWritingSystemPropertiesDialog.ShowMsgBoxStatus.CheckCantCreateDuplicateWs },
                                   null,
                                   new[] { DialogResult.OK });
     // Change Region or Variant info.
     m_dlg.SetVariantName("Phonetic");
     m_dlg.VerifyListBox(new[] { "Kalaba", "Kalaba (International Phonetic Alphabet)", "Kalaba (Phonetic)" });
     // Now update the Ethnologue code, and cancel msg box to check we restored the expected newly added language defns.
     m_dlg.SelectEthnologueCodeDlg("WSDialog", "qaa-x-wsd", "", DialogResult.OK,
                                   new[] { DummyWritingSystemPropertiesDialog.ShowMsgBoxStatus.CheckCantCreateDuplicateWs },
                                   new[] { "qaa-x-kal" },
                                   new[] { DialogResult.OK });
     // Verify dialog indicates a list to add to current (vernacular) ws list
     VerifyNewlyAddedWritingSystems(new[] { "qaa-fonipa-x-kal-etic" });
     // Now update the Ethnologue code, check we still have expected newly added language defns.
     m_dlg.SelectEthnologueCodeDlg("Kala", "qaa-x-kal", "", DialogResult.OK,
                                   new DummyWritingSystemPropertiesDialog.ShowMsgBoxStatus[] { }, new string[] { }, new DialogResult[] { });
     // Verify dialog indicates a list to add to current (vernacular) ws list
     VerifyNewlyAddedWritingSystems(new[] { "qaa-fonipa-x-kal-etic" });
     // Now try adding a second/duplicate ws.
     m_dlg.PressBtnAdd("&Writing System for Kala...");
     m_dlg.VerifyListBox(new[] { "Kala", "Kala", "Kala (International Phonetic Alphabet)", "Kala (Phonetic)" });
     m_dlg.VerifyLoadedForListBoxSelection("Kala");
     m_dlg.SetVariantName("Phonetic");
     m_dlg.VerifyListBox(new[] { "Kala", "Kala (International Phonetic Alphabet)", "Kala (Phonetic)", "Kala (Phonetic)" });
     m_dlg.SwitchTab(FwWritingSystemSetupDlg.kWsFonts,
                     DummyWritingSystemPropertiesDialog.ShowMsgBoxStatus.CheckCantCreateDuplicateWs,
                     DialogResult.OK);
     m_dlg.PressDeleteButton();
     m_dlg.VerifyListBox(new[] { "Kala", "Kala (International Phonetic Alphabet)", "Kala (Phonetic)" });
     m_dlg.VerifyLoadedForListBoxSelection("Kala (Phonetic)");
     // Do OK
     m_dlg.PressOk();
     // Verify dialog indicates a list to add to current (vernacular) ws list
     VerifyNewlyAddedWritingSystems(new[] { "qaa-fonipa-x-kal-etic" });
     // Verify we've actually created the new ws.
     VerifyWsNames(
         new[] { "Kala", "Kala (International Phonetic Alphabet)", "Kala (Phonetic)" },
         new[] { "qaa-x-kal", "qaa-fonipa-x-kal", "qaa-fonipa-x-kal-etic" });
 }