public void Init()
        {
            FacebookLogger.Instance = new FacebookTestLogger();
            Type type            = this.GetType();
            var  callbackManager = new CallbackManager();

            if (Attribute.GetCustomAttribute(type, typeof(AndroidTestAttribute)) != null)
            {
                var mockWrapper = new MockAndroid();
                Constants.CurrentPlatform = FacebookUnityPlatform.Android;
                var facebook = new AndroidFacebook(mockWrapper, callbackManager);
                this.Mock          = mockWrapper;
                this.Mock.Facebook = facebook;
                FB.FacebookImpl    = facebook;
            }
            else if (Attribute.GetCustomAttribute(type, typeof(IOSTestAttribute)) != null)
            {
                var mockWrapper = new MockIOS();
                Constants.CurrentPlatform = FacebookUnityPlatform.IOS;
                var facebook = new IOSFacebook(mockWrapper, callbackManager);
                this.Mock          = mockWrapper;
                this.Mock.Facebook = facebook;
                FB.FacebookImpl    = facebook;
            }
            else if (Attribute.GetCustomAttribute(type, typeof(GameroomTestAttribute)) != null)
            {
                var mockWrapper = new MockGameroom();
                Constants.CurrentPlatform = FacebookUnityPlatform.Gameroom;
                var facebook = new GameroomFacebook(mockWrapper, callbackManager);
                this.Mock          = mockWrapper;
                this.Mock.Facebook = facebook;
                FB.FacebookImpl    = facebook;
            }
            else if (Attribute.GetCustomAttribute(type, typeof(CanvasTestAttribute)) != null)
            {
                var mockWrapper = new MockCanvas();
                Constants.CurrentPlatform = FacebookUnityPlatform.WebGL;
                var facebook = new CanvasFacebook(mockWrapper, callbackManager);
                this.Mock          = mockWrapper;
                this.Mock.Facebook = facebook;
                FB.FacebookImpl    = facebook;
            }
            else if (Attribute.GetCustomAttribute(type, typeof(EditorTestAttribute)) != null)
            {
                var mockWrapper = new MockEditor();

                // The editor works for all platforms but claim to be android for testing.
                Constants.CurrentPlatform = FacebookUnityPlatform.Android;
                var facebook = new EditorFacebook(mockWrapper, callbackManager);
                this.Mock          = mockWrapper;
                this.Mock.Facebook = facebook;
                FB.FacebookImpl    = facebook;
            }
            else
            {
                throw new Exception("Failed to specify platform specified on test class");
            }

            this.OnInit();
        }
        public void Init()
        {
            FacebookLogger.Instance = new FacebookTestLogger();
            Type type = this.GetType();
            var callbackManager = new CallbackManager();
            if (Attribute.GetCustomAttribute(type, typeof(AndroidTestAttribute)) != null)
            {
                var mockWrapper = new MockAndroid();
                Constants.CurrentPlatform = FacebookUnityPlatform.Android;
                var facebook = new AndroidFacebook(mockWrapper, callbackManager);
                this.Mock = mockWrapper;
                this.Mock.Facebook = facebook;
                FB.FacebookImpl = facebook;
            }
            else if (Attribute.GetCustomAttribute(type, typeof(IOSTestAttribute)) != null)
            {
                var mockWrapper = new MockIOS();
                Constants.CurrentPlatform = FacebookUnityPlatform.IOS;
                var facebook = new IOSFacebook(mockWrapper, callbackManager);
                this.Mock = mockWrapper;
                this.Mock.Facebook = facebook;
                FB.FacebookImpl = facebook;
            }
            else if (Attribute.GetCustomAttribute(type, typeof(CanvasTestAttribute)) != null)
            {
                var mockWrapper = new MockCanvas();
                Constants.CurrentPlatform = FacebookUnityPlatform.WebGL;
                var facebook = new CanvasFacebook(mockWrapper, callbackManager);
                this.Mock = mockWrapper;
                this.Mock.Facebook = facebook;
                FB.FacebookImpl = facebook;
            }
            else if (Attribute.GetCustomAttribute(type, typeof(EditorTestAttribute)) != null)
            {
                var mockWrapper = new MockEditor();

                // The editor works for all platforms but claim to be android for testing.
                Constants.CurrentPlatform = FacebookUnityPlatform.Android;
                var facebook = new EditorFacebook(mockWrapper, callbackManager);
                this.Mock = mockWrapper;
                this.Mock.Facebook = facebook;
                FB.FacebookImpl = facebook;
            }
            else
            {
                throw new Exception("Failed to specify platform specified on test class");
            }

            this.OnInit();
        }
示例#3
0
        public void Init()
        {
            FacebookLogger.Instance = new FacebookTestLogger();
            Type type = this.GetType();

            if (Attribute.GetCustomAttribute(type, typeof(AndroidTestAttribute)) != null)
            {
                var callbackManager = new CallbackManager();
                var mockWrapper     = new MockAndroid();
                Constants.CurrentPlatform = FacebookUnityPlatform.Android;
                var facebook = new AndroidFacebook(mockWrapper, callbackManager);
                this.Mock          = mockWrapper;
                this.Mock.Facebook = facebook;
                FB.FacebookImpl    = facebook;
            }
            else if (Attribute.GetCustomAttribute(type, typeof(IOSTestAttribute)) != null)
            {
                var callbackManager = new CallbackManager();
                var mockWrapper     = new MockIOS();
                Constants.CurrentPlatform = FacebookUnityPlatform.IOS;
                var facebook = new IOSFacebook(mockWrapper, callbackManager);
                this.Mock          = mockWrapper;
                this.Mock.Facebook = facebook;
                FB.FacebookImpl    = facebook;
            }
            else if (Attribute.GetCustomAttribute(type, typeof(CanvasTestAttribute)) != null)
            {
                var callbackManager = new CallbackManager();
                var mockWrapper     = new MockCanvas();
                Constants.CurrentPlatform = FacebookUnityPlatform.WebGL;
                var facebook = new CanvasFacebook(mockWrapper, callbackManager);
                this.Mock          = mockWrapper;
                this.Mock.Facebook = facebook;
                FB.FacebookImpl    = facebook;
            }
            else
            {
                throw new Exception("No platform specified on test class");
            }

            this.OnInit();
        }