示例#1
0
        /// -------------------------------------------------------------------
        /// <summary>
        /// Tests and displays the correct error/comment
        /// </summary>
        /// -------------------------------------------------------------------
        void TestIfEventShouldFire(EventFired shouldFire, EventFired actualFired, object eventId, CheckType checkType)
        {
            if (!shouldFire.Equals(EventFired.Undetermined))
            {
                string eventName;
                if (eventId == null)
                {
                    eventName = "Focus";
                }
                else
                {
                    // Property change event
                    eventName = ((AutomationIdentifier)(eventId)).ProgrammaticName;
                }

                if (!actualFired.Equals(shouldFire))
                {
                    if (actualFired.Equals(EventFired.False))
                    {
                        ThrowMe(checkType, eventName + " event was not fired and was expected to be fired");
                    }
                    else
                    {
                        // Was fired and should not have been
                        ThrowMe(checkType, eventName + " event did get fired and was not expected to be fired");
                    }
                }
                else
                {
                    if (actualFired.Equals(EventFired.False))
                    {
                        Comment(eventName + " event was not fired and was not expected to be fired");
                    }
                    else
                    {
                        Comment(eventName + " change event did get fired and was expected to be fired");
                    }
                }
            }
            else
            {
                if (actualFired.Equals(EventFired.False))
                    Comment("The test spec'd firing of " + eventId + " event is Undetermined. The event was not fired");
                else
                    Comment("The test spec'd firing of " + eventId + " event is Undetermined. The event was fired");
            }
        }