private void GetSelectedMembers(GUITestDataCollector guiTDC, int guiSeq, ref TypeVerification typeVerify)
        {
            int    itemCounter = 0;
            string typeMember  = "";

            string[] expectedItems = GetExpectedOutcome(guiTDC.txtExpectedResult);

            for (int i = 0; i < guiTDC.chckLstMembersToVerify.Items.Count; i++)
            {
                if (guiTDC.chckLstMembersToVerify.GetItemChecked(i))
                {
                    typeMember = guiTDC.chckLstMembersToVerify.GetItemText(guiTDC.chckLstMembersToVerify.Items[i]);
                    if (!typeMember.StartsWith("\t"))
                    {
                        typeVerify.TypeName = typeMember;
                        typeVerify.GUIEvent = GUIEvent;
                    }
                    else
                    {
                        TestExpectation individualTest = new TestExpectation();
                        individualTest.EventMember       = GUIEvent;
                        individualTest.VerifyingMember   = typeMember.Trim();
                        individualTest.ExpectingResult   = expectedItems[itemCounter];
                        individualTest.GUIActionSequence = guiSeq;
                        itemCounter++;

                        typeVerify.MemberList.Add(individualTest);
                    }
                }
            }
        }
        //chapter 8
        private void AddTestVerification()
        {
            if (AUT == null)
            {
                return;
            }

            string VerifyDataStore = guiTestDataStore.Replace(".xml", "_verify.xml");

            TypeVerificationSerializable verifyTypes = new TypeVerificationSerializable();
            object obj = (object)verifyTypes;

            GUITestUtility.DeSerializeInfo(VerifyDataStore, ref obj);
            verifyTypes = (TypeVerificationSerializable)obj;

            TypeVerification oneType  = (TypeVerification)verifyTypes.TypeList[clickNum - 1];
            object           resulted = null;

            foreach (TestExpectation fieldName in oneType.MemberList)
            {
                TestExpectation tested = fieldName;
                try
                {
                    resulted       = GUITestUtility.VerifyField(AUT, tested.VerifyingMember);
                    tested.isField = true;
                }
                catch (Exception ex4)
                {
                    resulted          = GUITestUtility.VerifyProperty(AUT, tested.VerifyingMember);
                    tested.isProperty = true;
                }
                VerifyAlphanumericResult(ref tested, resulted);
                VerifyClipboard(ref tested, resulted);
            }
        }
 private void VerifyCheckedValue(ref TestExpectation fieldName, CheckBox resulted)
 {
     try
     {
         fieldName.ActualCheckVal = resulted.Checked;
         fieldName.AssertRadioButtonCheckBox(true, null);
     }
     catch (Exception ex)
     {
         fieldName.RadioBtnErrMsg = ex.Message;
     }
 }
 private void VerifyGroupBox(ref TestExpectation fieldName, object resulted)
 {
     try
     {
         GroupBox grp = (GroupBox)resulted;
         VerifyCosmeticGUIs(ref fieldName, grp);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
 private void VerifyLabel(ref TestExpectation fieldName, object resulted)
 {
     try
     {
         Label lbl = (Label)resulted;
         VerifyCosmeticGUIs(ref fieldName, lbl);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
 private void VerifyCheckedValue(ref TestExpectation fieldName, RadioButton resulted)
 {
     try
     {
         fieldName.ActualCheckVal = resulted.Checked;
         string errMsg       = "";
         bool   oneIsChecked = GetCheckedButtonInGroup(resulted, ref errMsg);
         fieldName.AssertRadioButtonCheckBox(oneIsChecked, errMsg);
     }
     catch (Exception ex)
     {
         fieldName.RadioBtnErrMsg = ex.Message;
     }
 }
 private void VerifyClipboard(ref TestExpectation fieldName, object resulted)
 {
     fieldName.ActualClpbrdObj = Clipboard.GetDataObject().GetData(DataFormats.Text);
     try
     {
         Control cntl = (Control)resulted;
         fieldName.ExpectedClpbrdObj = cntl.Text;
         fieldName.AssertClipboardTest(fieldName.ExpectClipBrdEqual);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
        //Chapter 9

        private void VerifyCosmeticGUIs(ref TestExpectation fieldName, object resulted)
        {
            try
            {
                Control cntl = (Control)resulted;
                fieldName.ActualCosmeticStr = "Caption: " + cntl.Text + "\n Size: " + cntl.Size +
                                              "\n Child GUIs: " + cntl.Controls.Count + "\n Font: " + cntl.Font +
                                              "\n Location: " + cntl.Location + "\n Back Color: " + cntl.BackColor +
                                              "\n Fore Color: " + cntl.ForeColor + "\n Enabled: " + cntl.Enabled +
                                              "\n Visible: " + cntl.Visible + "\n hasChildren: " + cntl.HasChildren;

                fieldName.AssertCosmeticGUITest();
            }
            catch (Exception ex)
            {
                fieldName.ActualCosmeticStr = ex.Message;
            }
        }
 //chapter 11
 private void VerifyRadioButtonCheckBox(ref TestExpectation fieldName, object resulted)
 {
     try
     {
         try
         {
             RadioButton rdBtn = (RadioButton)resulted;
             fieldName.ExpectedCheckVal = true;
             VerifyCheckedValue(ref fieldName, rdBtn);
         }
         catch
         {
             CheckBox chckBx = (CheckBox)resulted;
             fieldName.ExpectedCheckVal = preChecked ? false : true;
             VerifyCheckedValue(ref fieldName, chckBx);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
        private void VerifyAlphanumericResult(ref TestExpectation fieldName, object resulted)
        {
            try
            {
                Control cntl = (Control)resulted;
                fieldName.isGUI        = true;
                fieldName.ActualResult = cntl.Text;
                StringBuilder sb = new StringBuilder(MaxLen);
                GUITestActions.GetWindowText((int)cntl.Handle, sb, MaxLen);
                fieldName.ScreenSnapshot = sb.ToString();
            }
            catch (InvalidCastException ex1)
            {
                fieldName.ActualResult = resulted.ToString() + "\n" + ex1.Message;
            }
            catch (Exception ex2)
            {
                fieldName.ActualResult = fieldName.VerifyingMember + " is not found as a member.\n" + ex2.Message;
            }

            fieldName.AssertAlphanumericTest(fieldName.ExpectAlphaNumericEqual);
            testResult.MemberList.Add(fieldName);
        }