/// <summary>
        /// Given a mock object, this function will add to it a callback function to handle
        /// IConnectionPointContainer.FindConnectionPoint for all the event interfaces contained
        /// in the array passed as parameter.
        /// </summary>
        public static void AddConnectionPointsToContainer(BaseMock mockContainer, Type[] eventInterfaces)
        {
            // Check that the mock object implements IConnectionPointContainer.
            if (null == (mockContainer as IConnectionPointContainer))
            {
                throw new InvalidCastException("Parameter mockContainer does not implement IConnectionPointContainer.");
            }
            // Check if there is any interface in the array.
            if ((null == eventInterfaces) || (eventInterfaces.Length == 0))
            {
                throw new ArgumentNullException("eventIterfaces");
            }
            // Create the Dictionary that will store the connection points.
            Dictionary<Guid, IConnectionPoint> connectionPoints = new Dictionary<Guid, IConnectionPoint>();

            // Get the factory for the connection points.
            if (null == connectionPointFactory)
            {
                connectionPointFactory = new GenericMockFactory("MockLibraryConnectionPoint", new Type[] { typeof(IConnectionPoint) });
            }

            // Create a connection point for every type in the array.
            foreach (Type eventInterface in eventInterfaces)
            {
                BaseMock connectionMock = connectionPointFactory.GetInstance();
                // Set a return value for the Advise method so that the cookie will be not zero.
                connectionMock.AddMethodReturnValues(
                    string.Format(CultureInfo.InvariantCulture, "{0}.{1}", typeof(IConnectionPoint).FullName, "Advise"),
                    new object[] { null, (uint)1 });
                // Add this connection point to the dictionary.
                connectionPoints.Add(eventInterface.GUID, connectionMock as IConnectionPoint);
            }

            // Set the dictionary as member data for the container mock.
            mockContainer[connectionPointsCollection] = connectionPoints;

            // Set the callback for the FindConnectionPoint method.
            mockContainer.AddMethodCallback(
                string.Format(CultureInfo.InvariantCulture, "{0}.{1}", typeof(IConnectionPointContainer).FullName, "FindConnectionPoint"),
                new EventHandler<CallbackArgs>(FindConnectionPointCallback));
        }