Exemple #1
0
        public void DoubleBindingNotEffectedByGlobal()
        {
            Text text = null;
            var  view = new StatePage();

            view.text.Value = "Hello";
            int buildCount     = 0;
            int textBuildCount = 0;

            view.Body = () => {
                buildCount++;
                text = new Text(() => {
                    textBuildCount++;
                    return($"{view.text.Value} - {view.clickCount.Value}");
                });
                return(text);
            };

            var viewHandler = new GenericViewHandler();

            view.ViewHandler = viewHandler;


            var textHandler = new GenericViewHandler();

            text.ViewHandler = textHandler;


            Assert.Equal(1, buildCount);
            Assert.Equal(1, textBuildCount);

            view.clickCount.Value++;


            Assert.Equal(1, buildCount);
            Assert.Equal(2, textBuildCount);

            view.text.Value = "Good bye";


            Assert.Equal(1, buildCount);
            Assert.Equal(3, textBuildCount);
        }
Exemple #2
0
        public void RebuildingViewsReuseNativeView()
        {
            Text text        = null;
            Text currentText = null;
            var  view        = new StatePage();

            view.text.Value = "Hello";
            int buildCount = 0;

            view.Body = () => {
                buildCount++;
                currentText = new Text($"{view.text.Value} - {view.clickCount.Value}");
                return(currentText);
            };

            var viewHandler = new GenericViewHandler();

            view.ViewHandler = viewHandler;


            text = currentText;
            var textHandler = new GenericViewHandler();

            text.ViewHandler = textHandler;


            Assert.Equal(1, buildCount);

            view.clickCount.Value++;


            Assert.Equal(2, buildCount);


            //Check to make sure that the view was rebuilt
            Assert.NotEqual(text, currentText);
            //Make sure the old one is unasociated
            Assert.Null(text?.ViewHandler);
            //Make sure the new view has the old handler
            Assert.Equal(currentText?.ViewHandler, textHandler);
        }
Exemple #3
0
        public void FormatingStringInTextCausesGlobal()
        {
            Text text = null;
            var  view = new StatePage();

            view.text.Value = "Hello";
            int buildCount = 0;

            view.Body = () => {
                buildCount++;
                text = new Text($"{view.text.Value} - {view.clickCount.Value}");
                return(text);
            };

            var viewHandler = new GenericViewHandler();

            view.ViewHandler = viewHandler;


            var textHandler = new GenericViewHandler();

            text.ViewHandler = textHandler;


            Assert.Equal(1, buildCount);

            view.clickCount.Value++;


            Assert.Equal(2, buildCount);

            view.text.Value = "Good bye";


            Assert.Equal(3, buildCount);
        }