/// Substitute a class that extends from Monobehaviour and add it to the GameObject passed in.
    /// Remember, all non-virtual members will actually be executed. Only virtual/abstract members
    /// can be recorded or have return values specified.
    /// Additionally, call OnEnable and Awake on the component after it is added to the GameObject.
    public static T ForInvokeLifecycle <T>(GameObject gameObject)
        where T : MonoBehaviour
    {
        T result = SubstituteComponent.For <T>(gameObject);

        if (result == null)
        {
            return(null);
        }

        ComponentHelpers.CallOnEnable(gameObject);
        ComponentHelpers.CallAwake(gameObject);

        return(result);
    }
        public void Setup()
        {
            SubstituteComponent.BeginComponentContext();

            // Create input module implementation.
            module = new GvrPointerInputModuleImpl();

            // Create Event System.
            GameObject eventSystemObj = new GameObject("EventSystem");

            eventSytem = eventSystemObj.AddComponent <EventSystem>();

            // Create mock pointer.
            pointer = SubstituteComponent.For <GvrBasePointer>(eventSystemObj);
            pointer.PointerTransform.Returns(eventSytem.transform);
            pointer.IsAvailable.Returns(true);
            module.Pointer = pointer;

            // Create mock scroll input.
            scrollInput        = new GvrPointerScrollInput();
            module.ScrollInput = scrollInput;

            // Create mock module controller.
            moduleController = Substitute.For <IGvrInputModuleController>();
            moduleController.eventSystem.Returns(eventSytem);
            resultCache = new List <RaycastResult>();
            moduleController.RaycastResultCache.Returns(resultCache);
            module.ModuleController = moduleController;

            // Create mock event executor.
            eventExecutor        = Substitute.For <IGvrEventExecutor>();
            module.EventExecutor = eventExecutor;

            // Create dummy objects to use for hit detection.
            raycastResult = new RaycastResult();
            hitObject     = new GameObject("HitObject");
            hitPos        = new Vector3(1.0f, 2.0f, 3.0f);

            dummyRaycastResult = new RaycastResult();
        }