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();
        }
Ejemplo n.º 2
0
        public void FindWildcard()
        {
            var newEd = new MockEditor("This is some sample text\non 3 different lines\nwith more samples");
            var vm2   = new FindReplaceDialogViewModel(mockEventAggregator)
            {
                Editor        = newEd,
                UseWildcards  = true,
                UseRegex      = false,
                CaseSensitive = false,
                TextToFind    = "sam* "
            };

            vm2.FindText();

            Assert.AreEqual(13, newEd.SelectionStart, "Selection Start");
            Assert.AreEqual(7, newEd.SelectionLength, "Selection Length");
        }
Ejemplo n.º 3
0
        public void ReplaceAllTest()
        {
            var localEditor = new MockEditor("This is some sample text\non 3 different lines\nwith more samples");
            var vm          = new FindReplaceDialogViewModel(mockEventAggregator)
            {
                // need to ceatea a new editor for replaces tests as they change the text
                Editor        = localEditor,
                UseRegex      = true,
                UseWildcards  = false,
                CaseSensitive = false,
                TextToFind    = "sam[^\\s]*",
                TextToReplace = "hello"
            };

            //vm.Find();
            vm.ReplaceAllText();

            Assert.AreEqual("This is some hello text\non 3 different lines\nwith more hello",
                            localEditor.Text,
                            "Replacement Text");
        }
Ejemplo n.º 4
0
 public void Init()
 {
     ed = new MockEditor("This is some sample text\non 3 different lines\nwith more samples");
     mockEventAggregator = new MockEventAggregator();
 }