public IEnumerator Hooks_UseState_WrongValues()
    {
        var wordState = new UseState <string>("Hola a todos !!");

        // A Component
        REcanvas MainReactorComponent()
        {
            return(new REcanvas
            {
                childs = () => new REbase[] {
                    new REtext {
                        propsId = () => new REtext.IdSetter {
                            id = "ProveText"
                        },
                        propsText = () => new REtext.TextSetter {
                            text = wordState.value,
                        },
                        useState = new IuseState[] {
                            wordState,
                        },
                    },
                },
            });
        }

        var routerProve = MainReactorComponent();

        yield return(new WaitForSecondsRealtime(1));

        routerProve.Draw();
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "Hola a todos !!");

        yield return(new WaitForSecondsRealtime(1));

        wordState.SetState("NewWord");
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "NewWord");
        wordState.SetState("OtherWord");
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "OtherWord");
        wordState.PrevState(0);
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "OtherWord");
        wordState.SetState("OtherWord");
        wordState.SetState("Word");
        wordState.SetState("LastWord");
        wordState.SetState("FinalWord");
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "FinalWord");
        wordState.PrevState(-1);
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "FinalWord");
        wordState.PrevState(-2);
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "FinalWord");
        wordState.PrevState(-10);
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "FinalWord");
        wordState.PrevState(-2);
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "FinalWord");

        yield return(new WaitForSecondsRealtime(2));

        routerProve.Erase();
    }
Example #2
0
    public IEnumerator Hooks_UseEffect_60ThrowErrorInDeltaFunction()
    {
        // A Component
        REcanvas MainReactorComponent()
        {
            var count = 0;

            return(new REcanvas
            {
                childs = () => new REbase[] {
                    new REtext {
                        propsId = () => new REtext.IdSetter {
                            id = "ProveText"
                        },
                        propsText = () => new REtext.TextSetter {
                            text = "Hello World!",
                        },
                        useEffect = new REtext.UseEffect.Hook[] {
                            new REtext.UseEffect.Hook {
                                // Is executd each 1second per default in unscaled time mode
                                deltaFunction = (d, s) => {
                                    count++;
                                    s.textCmp.text = "C: " + count;
                                    throw new Exception("Expected error");
                                },
                            }
                        }
                    },
                },
            });
        }

        var routerProve = MainReactorComponent();

        yield return(new WaitForSecondsRealtime(1));

        // Draw the component
        routerProve.Draw();
        Debug.Log("Drawing");
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "Hello World!");

        // One message will be printed
        LogAssert.Expect(LogType.Error, new Regex("Expected error"));  // Regex - Contains that string


        // First check and hook must be runner 1
        yield return(new WaitForSecondsRealtime(1.2f));

        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "C: 1");



        yield return(new WaitForSecondsRealtime(2));

        routerProve.Erase();
    }
    public IEnumerator GenerateChildsFromArray()
    {
        var words = new string[]
        {
            "One",
            "Two",
            "Three",
            "Four",
            "Five",
        };

        // A Component
        REcanvas MainReactorComponent()
        {
            return(new REcanvas
            {
                childs = () => words.Select(c =>
                                            new REtext
                {
                    propsId = () => new REtext.IdSetter
                    {
                        id = c + "Num",
                    },
                    propsText = () => new REtext.TextSetter
                    {
                        text = c,
                    }
                }
                                            ),
            });
        }

        var routerProve = MainReactorComponent();

        yield return(new WaitForSecondsRealtime(1));

        Debug.Log("Drawing");
        routerProve.Draw();

        Debug.Log("Brothers");
        Assert.IsTrue(REtext.FindOne("#" + words[0] + "Num").brothersSelector.Length == 5);

        Debug.Log("Childs");
        foreach (var word in words)
        {
            //Debug.Log("Child: " + "#" + word + "Num" + " == " + word);
            //Debug.Log("Child: " + ReactorElement.Find<REtext.Selector>("#" + word + "Num")[0].textCmp.text + " == " + word);
            Assert.IsTrue(REtext.FindOne("#" + word + "Num").textCmp.text == word);
        }

        yield return(new WaitForSecondsRealtime(2));

        routerProve.Erase();
    }
Example #4
0
    public IEnumerator Hooks_UseStateUseEffect()
    {
        var wordState = new UseState <string>("Hola a todos !!");

        // A Component
        REcanvas MainReactorComponent()
        {
            return(new REcanvas
            {
                childs = () => new REbase[] {
                    new REtext {
                        propsId = () => new REtext.IdSetter
                        {
                            id = "Textmain",
                        },
                        propsText = () => new REtext.TextSetter {
                            text = wordState.value,
                        },
                        useState = new IuseState[] {
                            wordState,
                        },
                        useEffect = new REtext.UseEffect.Hook[] {
                            new REtext.UseEffect.Hook {
                                duration = 3,
                                deltaFunction = (d, s) => wordState.SetState("A new word"),
                            }
                        }
                    },
                },
            });
        }

        var routerProve = MainReactorComponent();

        routerProve.Draw();

        // Waint until useeffect act
        yield return(new WaitForSecondsRealtime(4));

        // Find the component
        Assert.IsTrue(REtext.FindOne("#Textmain").textCmp.text == "A new word");

        yield return(null);
    }
Example #5
0
    public IEnumerator Hooks_UseEffect_32InErasedElements_WillBeErasedToo()
    {
        // A Component
        REcanvas MainReactorComponent()
        {
            var count = 0;

            return(new REcanvas
            {
                childs = () => new REbase[] {
                    new REtext {
                        propsId = () => new REtext.IdSetter {
                            id = "ProveText"
                        },
                        propsText = () => new REtext.TextSetter {
                            text = "Hello World!",
                        },
                        useEffect = new REtext.UseEffect.Hook[] {
                            new REtext.UseEffect.Hook {
                                // Is executd each 1second per default in unscaled time mode
                                deltaFunction = (d, s) => {
                                    count++;
                                    s.textCmp.text = "C: " + count;
                                },
                            }
                        }
                    },
                },
            });
        }

        var routerProve = MainReactorComponent();

        yield return(new WaitForSecondsRealtime(1));

        // Draw the component
        routerProve.Draw();
        Debug.Log("Drawing");
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "Hello World!");

        // First check and hook must be runner 1
        yield return(new WaitForSecondsRealtime(1.2f));

        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "C: 1");



        // Hide the element
        routerProve.Erase();

        // Second check and hook must be runner 2
        yield return(new WaitForSecondsRealtime(3f));

        Assert.IsTrue(REtext.FindOne("#ProveText") == null);



        yield return(new WaitForSecondsRealtime(2));

        routerProve.Erase();
    }
Example #6
0
    public IEnumerator Hooks_UseEffect_30InHidedElements_RunNormally()
    {
        // A Component
        REcanvas MainReactorComponent()
        {
            var count = 0;

            return(new REcanvas
            {
                childs = () => new REbase[] {
                    new REtext {
                        propsId = () => new REtext.IdSetter {
                            id = "ProveText"
                        },
                        propsText = () => new REtext.TextSetter {
                            text = "Hello World!",
                        },
                        useEffect = new REtext.UseEffect.Hook[] {
                            new REtext.UseEffect.Hook {
                                // Is executd each 1second per default in unscaled time mode
                                deltaFunction = (d, s) => {
                                    count++;
                                    s.textCmp.text = "C: " + count;
                                },
                            }
                        }
                    },
                },
            });
        }

        var routerProve = MainReactorComponent();

        yield return(new WaitForSecondsRealtime(1));

        // Draw the component
        routerProve.Draw();
        Debug.Log("Drawing");
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "Hello World!");

        // First check and hook must be runner 1
        yield return(new WaitForSecondsRealtime(1.2f));

        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "C: 1");



        // Hide the element
        routerProve.Hide();
        Assert.IsFalse(((REcanvas.Selector)REbase.Find("#ProveText")[0].rootCanvasSelector).canvas.enabled);

        // Second check and hook must be runner 2
        yield return(new WaitForSecondsRealtime(1f));

        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "C: 2");



        // Enable and check
        routerProve.Show();
        Assert.IsTrue(((REcanvas.Selector)REbase.Find("#ProveText")[0].rootCanvasSelector).canvas.enabled);

        // Thirh check and hook must be runner 3
        yield return(new WaitForSecondsRealtime(1f));

        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "C: 3");



        yield return(new WaitForSecondsRealtime(2));

        routerProve.Erase();
    }
Example #7
0
    public IEnumerator Hooks_UseEffect_16DeltaUnscaledEffect_ManyHooks()
    {
        // A Component
        REcanvas MainReactorComponent()
        {
            var count  = 0;
            var count2 = 0;

            return(new REcanvas
            {
                childs = () => new REbase[] {
                    new REtext {
                        propsId = () => new REtext.IdSetter {
                            id = "ProveText"
                        },
                        propsText = () => new REtext.TextSetter {
                            text = "Hello World!",
                        },
                        useEffect = new REtext.UseEffect.Hook[] {
                            new REtext.UseEffect.Hook {
                                // Is executd each 1second per default
                                deltaFunction = (d, s) => {
                                    count++;
                                    s.textCmp.text = "C: " + count;
                                },
                            },

                            new REtext.UseEffect.Hook {
                                // Is executd each 1second per default
                                deltaFunction = (d, s) => {
                                    count2++;
                                    s.textCmp.fontSize = count2;
                                },
                            }
                        }
                    },
                },
            });
        }

        var routerProve = MainReactorComponent();

        yield return(new WaitForSecondsRealtime(1));

        // Draw the component
        routerProve.Draw();
        Debug.Log("Drawing");
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "Hello World!");

        // First check and hook must be runner 1
        yield return(new WaitForSecondsRealtime(1.2f));

        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "C: 1");
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.fontSize == 1);

        // Second check and hook must be runner 2
        yield return(new WaitForSecondsRealtime(1f));

        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "C: 2");
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.fontSize == 2);

        // Thirh check and hook must be runner 3
        yield return(new WaitForSecondsRealtime(1f));

        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "C: 3");
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.fontSize == 3);


        yield return(new WaitForSecondsRealtime(2));

        routerProve.Erase();
    }
Example #8
0
    public IEnumerator Hooks_UseEffect_10Basics()
    {
        // A Component
        REcanvas MainReactorComponent()
        {
            var count = 0;

            return(new REcanvas
            {
                childs = () => new REbase[] {
                    new REtext {
                        propsId = () => new REtext.IdSetter {
                            id = "ProveText"
                        },
                        propsText = () => new REtext.TextSetter {
                            text = "Hello World!",
                        },
                        useEffect = new REtext.UseEffect.Hook[] {
                            new REtext.UseEffect.Hook {
                                // Is executd each 1second per default in unscaled time mode
                                deltaFunction = (d, s) => {
                                    count++;
                                    s.textCmp.text = "C: " + count;
                                },
                            }
                        }
                    },
                },
            });
        }

        var routerProve = MainReactorComponent();

        yield return(new WaitForSecondsRealtime(1));

        // Draw the component
        routerProve.Draw();
        Debug.Log("Drawing");
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "Hello World!");

        // First check and hook must be runner 1
        yield return(new WaitForSecondsRealtime(1.2f));

        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "C: 1");

        // Second check and hook must be runner 2
        yield return(new WaitForSecondsRealtime(1f));

        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "C: 2");

        // Thirh check and hook must be runner 3
        yield return(new WaitForSecondsRealtime(1f));

        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "C: 3");

        // Time dont affect deltaUnscaledEffect
        Time.timeScale = .01f;


        // Four check and hook must be runner 4
        yield return(new WaitForSecondsRealtime(1f));

        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "C: 4");

        // Five check and hook must be runner 5
        yield return(new WaitForSecondsRealtime(1f));

        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "C: 5");


        // Time dont affect deltaUnscaledEffect
        Time.timeScale = 1f;


        // Four check and hook must be runner 6
        yield return(new WaitForSecondsRealtime(1f));

        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "C: 6");

        // Five check and hook must be runner 7
        yield return(new WaitForSecondsRealtime(1f));

        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "C: 7");



        yield return(new WaitForSecondsRealtime(2));

        routerProve.Erase();
    }
    public IEnumerator GenerateChildsFromDinamicList()
    {
        var words = new List <string>
        {
            "One",
            "Two",
            "Three",
            "Four",
            "Five",
        };

        // A Component
        REcanvas MainReactorComponent()
        {
            return(new REcanvas
            {
                childs = () => words.Select(c =>
                                            new REtext
                {
                    propsId = () => new REtext.IdSetter
                    {
                        id = c + "Num",
                    },
                    propsText = () => new REtext.TextSetter
                    {
                        text = c,
                    }
                }
                                            ),
            });
        }

        var routerProve = MainReactorComponent();

        yield return(new WaitForSecondsRealtime(1));

        // Draw the component
        Debug.Log("Drawing");
        routerProve.Draw();

        // First check
        Debug.Log("Brothers");
        Assert.IsTrue(REtext.FindOne("#" + words[0] + "Num").brothersSelector.Length == 5);

        Debug.Log("Childs");
        foreach (var word in words)
        {
            //Debug.Log("Child: " + "#" + word + "Num" + " == " + word);
            //Debug.Log("Child: " + ReactorElement.Find<REtext.Selector>("#" + word + "Num")[0].textCmp.text + " == " + word);
            Assert.IsTrue(REtext.FindOne("#" + word + "Num").textCmp.text == word);
        }



        // Cahnge the list
        words.Add("Perro");
        words.Add("Gato");

        // Second check must not change
        Debug.Log("Brothers");
        Assert.IsTrue(REtext.FindOne("#" + words[0] + "Num").brothersSelector.Length == 5);

        Debug.Log("Childs");
        foreach (var word in words)
        {
            if (word == "Perro" || word == "Gato")
            {
                continue;
            }

            Debug.Log("Child: " + "#" + word + "Num" + " == " + word);
            Debug.Log("Child: " + REtext.FindOne("#" + word + "Num").textCmp.text + " == " + word);
            Assert.IsTrue(REtext.FindOne("#" + word + "Num").textCmp.text == word);
        }



        // Draw again the component
        Debug.Log("Drawing again");
        routerProve.Draw();
        // Check
        Debug.Log("Brothers: " + REtext.FindOne("#" + words[0] + "Num").brothersSelector.Length);
        Assert.IsTrue(REtext.FindOne("#" + words[0] + "Num").brothersSelector.Length == 7);

        Debug.Log("Childs");
        foreach (var word in words)
        {
            //Debug.Log("Child: " + "#" + word + "Num" + " == " + word);
            //Debug.Log("Child: " + ReactorElement.Find<REtext.Selector>("#" + word + "Num")[0].textCmp.text + " == " + word);
            Assert.IsTrue(REtext.FindOne("#" + word + "Num").textCmp.text == word);
        }



        // Cahnge the list
        words.Remove("Perro");
        words.Remove("Gato");

        // Draw again the component
        Debug.Log("Drawing again");
        routerProve.Draw();

        // Check
        Debug.Log("Brothers");
        Assert.IsTrue(REtext.FindOne("#" + words[0] + "Num").brothersSelector.Length == 5);

        Debug.Log("Childs");
        foreach (var word in words)
        {
            //Debug.Log("Child: " + "#" + word + "Num" + " == " + word);
            //Debug.Log("Child: " + ReactorElement.Find<REtext.Selector>("#" + word + "Num")[0].textCmp.text + " == " + word);
            Assert.IsTrue(REtext.FindOne("#" + word + "Num").textCmp.text == word);
        }



        // Cahnge the list
        words.Clear();

        // Draw again the component
        Debug.Log("Drawing again");
        routerProve.Draw();

        // Check
        Debug.Log("Brothers");
        Assert.IsTrue(REtext.FindOne("#1") == null);



        yield return(new WaitForSecondsRealtime(2));

        routerProve.Erase();
    }
    public IEnumerator Hooks_GenerateChildWithUseState()
    {
        var listState = new UseState <List <string> >(new List <string>());

        // A Component
        REcanvas MainReactorComponent()
        {
            return(new REcanvas
            {
                propsId = () => new REcanvas.IdSetter
                {
                    id = "MainCanvas",
                },
                useState = new IuseState[]
                {
                    listState,
                },
                childs = () => listState.value.Select(c =>
                                                      new REtext
                {
                    propsId = () => new REtext.IdSetter
                    {
                        id = c + "Num",
                    },
                    propsText = () => new REtext.TextSetter
                    {
                        text = c,
                    }
                }
                                                      ),
            });
        }

        var routerProve = MainReactorComponent();

        yield return(new WaitForSecondsRealtime(1));

        // Draw the component
        Debug.Log("Drawing");
        routerProve.Draw();

        // First check
        Debug.Log("Childs: " + REbase.FindOne("#MainCanvas").childs.Length);
        Assert.IsTrue(REbase.FindOne("#MainCanvas").childs.Length == 0);



        // Simulate the fetch
        yield return(new WaitForSecondsRealtime(1));

        var fetchData = new List <string>
        {
            "Six",
            "Seven",
            "Eight",
            "Nine",
        };



        // Draw again the component
        Debug.Log("UseState: " + listState.value.Count());
        listState.SetState(fetchData);

        // Check
        Debug.Log("Childs: " + REbase.FindOne("#MainCanvas").childs.Length);
        Assert.IsTrue(REbase.FindOne("#MainCanvas").childs.Length == 4);

        Debug.Log("Childs");
        foreach (var word in listState.value)
        {
            //Debug.Log("Child: " + "#" + word + "Num" + " == " + word);
            //Debug.Log("Child: " + ReactorElement.Find<REtext.Selector>("#" + word + "Num")[0].textCmp.text + " == " + word);
            Assert.IsTrue(REtext.FindOne("#" + word + "Num").textCmp.text == word);
        }



        yield return(new WaitForSecondsRealtime(2));

        routerProve.Erase();
    }
    public IEnumerator FindAsChildOfOtherGO_AndDisableEnable()
    {
        // Create a reactor component
        REcanvas MainReactorComponent()
        {
            return(new REcanvas
            {
                childs = () => new REbase[] {
                    new REtext {
                        propsId = () => new REtext.IdSetter {
                            id = "ProveText"
                        },
                        propsText = () => new REtext.TextSetter {
                            text = "Hello world",
                        },
                        childs = () => new REbase[]
                        {
                            new REimage(),
                            new REimage(),
                        }
                    },
                    new REtext(),
                    new REtext(),
                    new REtext(),
                },
            });
        }

        var reactorComponent = MainReactorComponent();

        yield return(new WaitForSecondsRealtime(1));

        // Draw the component for the first time
        Debug.Log("Drawing");
        var go = new GameObject("AnyGameobject");

        reactorComponent.Draw(go);

        yield return(new WaitForSecondsRealtime(1));

        // Look fr the component
        Debug.Log("Finding");
        var textSelector = REtext.FindOne("#ProveText");

        Assert.IsTrue(textSelector.gameObject.activeSelf);

        // Check that the compoennt exist
        Assert.IsFalse(textSelector.isDisposed);
        Assert.IsFalse(textSelector.rectTransform == null);
        Assert.IsFalse(textSelector.gameObject == null);
        Assert.IsFalse(textSelector.parent == null);
        Assert.IsFalse(textSelector.childs == null);
        Assert.IsFalse(textSelector.brothersSelector == null);
        Assert.IsFalse(textSelector.canvasRenderer == null);
        Assert.IsTrue(textSelector.textCmp.text == "Hello world");

        // Disable the component
        Debug.Log("Disabling");
        go.SetActive(false);
        Assert.IsTrue(textSelector.gameObject.activeSelf);
        Assert.IsFalse(textSelector.gameObject.activeInHierarchy);
        Assert.IsTrue(textSelector.rootCanvasSelector.gameObject.activeSelf);

        // Check that the selector references are not null
        Assert.IsFalse(textSelector.isDisposed);
        Assert.IsFalse(textSelector.rectTransform == null);
        Assert.IsFalse(textSelector.gameObject == null);
        Assert.IsFalse(textSelector.parent == null);
        Assert.IsFalse(textSelector.childs == null);
        Assert.IsFalse(textSelector.brothersSelector == null);
        Assert.IsFalse(textSelector.canvasRenderer == null);
        Assert.IsTrue(textSelector.textCmp.text == "Hello world");

        // Show/Enable the component
        Debug.Log("Showing");
        go.SetActive(true);
        Assert.IsTrue(textSelector.gameObject.activeSelf);
        Assert.IsTrue(textSelector.gameObject.activeInHierarchy);
        Assert.IsTrue(textSelector.rootCanvasSelector.gameObject.activeSelf);

        // Check that the selector references are now null
        Assert.IsFalse(textSelector.isDisposed);
        Assert.IsFalse(textSelector.rectTransform == null);
        Assert.IsFalse(textSelector.gameObject == null);
        Assert.IsFalse(textSelector.parent == null);
        Assert.IsFalse(textSelector.childs == null);
        Assert.IsFalse(textSelector.brothersSelector == null);
        Assert.IsFalse(textSelector.canvasRenderer == null);
        Assert.IsTrue(textSelector.textCmp.text == "Hello world");

        yield return(new WaitForSecondsRealtime(2));

        reactorComponent.Erase();
    }
    public IEnumerator Find_ThenErase()
    {
        // Create a reactor component
        REcanvas MainReactorComponent()
        {
            return(new REcanvas
            {
                childs = () => new REbase[] {
                    new REtext {
                        propsId = () => new REtext.IdSetter {
                            id = "ProveText"
                        },
                        propsText = () => new REtext.TextSetter {
                            text = "Hello world",
                        },
                        childs = () => new REbase[]
                        {
                            new REimage(),
                            new REimage(),
                        }
                    },
                    new REtext(),
                    new REtext(),
                    new REtext(),
                },
            });
        }

        var reactorComponent = MainReactorComponent();

        yield return(new WaitForSecondsRealtime(1));

        // Draw the component for the first time
        Debug.Log("Drawing");
        reactorComponent.Draw();

        yield return(new WaitForSecondsRealtime(1));

        // Look fr the component
        Debug.Log("Finding");
        var textSelector = REtext.FindOne("#ProveText");

        // Check that the compoennt exist
        Assert.IsFalse(textSelector.isDisposed);
        Assert.IsFalse(textSelector.rectTransform == null);
        Assert.IsFalse(textSelector.gameObject == null);
        Assert.IsFalse(textSelector.parent == null);
        Assert.IsFalse(textSelector.childs == null);
        Assert.IsFalse(textSelector.brothersSelector == null);
        Assert.IsFalse(textSelector.canvasRenderer == null);
        Assert.IsTrue(textSelector.textCmp.text == "Hello world");

        // Erase the component
        Debug.Log("Erasing");
        reactorComponent.Erase();

        // Check that the selector references are now null
        Assert.IsTrue(textSelector.isDisposed);
        Assert.IsTrue(textSelector.rectTransform == null);
        Assert.IsTrue(textSelector.gameObject == null);
        Assert.IsTrue(textSelector.parent == null);
        Assert.IsTrue(textSelector.childs == null);
        Assert.IsTrue(textSelector.brothersSelector == null);
        Assert.IsTrue(textSelector.canvasRenderer == null);
        Assert.Throws <NullReferenceException>(() => Debug.Log("V: " + textSelector.rectTransform.rect));

        // Try to find again the component that it must not exist
        Debug.Log("Finding again");
        Assert.IsTrue(REtext.Find("#ProveText").Length == 0);

        yield return(new WaitForSecondsRealtime(2));

        reactorComponent.Erase();
    }
    public IEnumerator Find_AndUseState()
    {
        var letterState = new UseState <string>("Hello world");

        // Create a reactor component
        REcanvas MainReactorComponent()
        {
            return(new REcanvas
            {
                childs = () => new REbase[] {
                    new REtext {
                        propsId = () => new REtext.IdSetter {
                            id = "ProveText"
                        },
                        propsText = () => new REtext.TextSetter {
                            text = letterState.value,
                        },
                        useState = new IuseState[]
                        {
                            letterState,
                        },
                        childs = () => new REbase[]
                        {
                            new REimage(),
                            new REimage(),
                        }
                    },
                    new REtext(),
                    new REtext(),
                    new REtext(),
                },
            });
        }

        var reactorComponent = MainReactorComponent();

        yield return(new WaitForSecondsRealtime(1));

        // Draw the component for the first time
        Debug.Log("Drawing");
        reactorComponent.Draw();

        yield return(new WaitForSecondsRealtime(1));

        // Look fr the component
        Debug.Log("Finding");
        var textSelector = REtext.FindOne("#ProveText");

        // Check that the compoennt exist
        Assert.IsFalse(textSelector.isDisposed);
        Assert.IsFalse(textSelector.rectTransform == null);
        Assert.IsFalse(textSelector.gameObject == null);
        Assert.IsFalse(textSelector.parent == null);
        Assert.IsFalse(textSelector.childs == null);
        Assert.IsFalse(textSelector.brothersSelector == null);
        Assert.IsFalse(textSelector.canvasRenderer == null);
        Assert.IsTrue(textSelector.textCmp.text == "Hello world");

        // Redraw the component
        Debug.Log("Changing and drawing again");
        letterState.SetState("New text");

        // Check that the selector references are now null
        Debug.Log("Changing and drawing again");
        Assert.IsTrue(textSelector.isDisposed);
        Debug.Log("Changing and drawing again");
        Assert.IsTrue(textSelector.rectTransform == null);
        Debug.Log("Changing and drawing again");
        Assert.IsTrue(textSelector.gameObject == null);
        Debug.Log("Changing and drawing again");
        Assert.IsTrue(textSelector.parent == null);
        Debug.Log("Changing and drawing again");
        Assert.IsTrue(textSelector.childs == null);
        Debug.Log("Changing and drawing again");
        Assert.IsTrue(textSelector.brothersSelector == null);
        Debug.Log("Changing and drawing again");
        Assert.IsTrue(textSelector.canvasRenderer == null);
        Debug.Log("Changing and drawing again");
        Assert.Throws <NullReferenceException>(() => Debug.Log("V: " + textSelector.rectTransform.rect));
        Debug.Log("Changing and drawing again");
        // Try to find again the component that it must exist
        Debug.Log("Finding again");
        textSelector = REtext.FindOne("#ProveText");

        // Check that the compoennt exist
        Assert.IsFalse(textSelector.isDisposed);
        Assert.IsFalse(textSelector.rectTransform == null);
        Assert.IsFalse(textSelector.gameObject == null);
        Assert.IsFalse(textSelector.parent == null);
        Assert.IsFalse(textSelector.childs == null);
        Assert.IsFalse(textSelector.brothersSelector == null);
        Assert.IsFalse(textSelector.canvasRenderer == null);
        Assert.IsTrue(textSelector.textCmp.text == "New text");

        yield return(new WaitForSecondsRealtime(2));

        reactorComponent.Erase();
    }
    public IEnumerator Hooks_UseState_VariableNumberOfStates()
    {
        var wordState     = new UseState <string>("Hola a todos !!");
        var fontSizeState = new UseState <int>(20);

        // A Component
        REcanvas MainReactorComponent()
        {
            return(new REcanvas
            {
                childs = () => new REbase[] {
                    new REtext {
                        propsId = () => new REtext.IdSetter {
                            id = "ProveText"
                        },
                        propsText = () => new REtext.TextSetter {
                            text = wordState.value,
                            fontSize = fontSizeState.value,
                        },
                        useState = new IuseState[] {
                            wordState,
                            fontSizeState,
                        },
                    },
                },
            });
        }

        var routerProve = MainReactorComponent();

        yield return(new WaitForSecondsRealtime(1));

        // Draw the component
        routerProve.Draw();
        Debug.Log("Check");
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "Hola a todos !!");

        yield return(new WaitForSecondsRealtime(1));

        // Erase the component
        routerProve.Erase();
        wordState.SetState("NewWord");
        wordState.SetState("OtherWord");
        fontSizeState.SetState(23);
        wordState.PrevState();
        wordState.SetState("OtherWord");
        fontSizeState.SetState(44);
        wordState.SetState("Word");
        wordState.SetState("LastWord");
        fontSizeState.SetState(39);
        wordState.SetState("FinalWord");
        fontSizeState.SetState(34);

        // Draw the component again
        routerProve.Draw();
        Debug.Log("Check");
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "FinalWord");

        yield return(new WaitForSecondsRealtime(2));

        routerProve.Erase();
    }
    public IEnumerator Hooks_UseState_InDisabledElements()
    {
        var wordState = new UseState <string>("Hola a todos !!");

        // A Component
        REcanvas MainReactorComponent()
        {
            return(new REcanvas
            {
                childs = () => new REbase[] {
                    new REtext {
                        propsId = () => new REtext.IdSetter {
                            id = "ProveText"
                        },
                        propsText = () => new REtext.TextSetter {
                            text = wordState.value,
                        },
                        useState = new IuseState[] {
                            wordState,
                        },
                    },
                },
            });
        }

        var routerProve = MainReactorComponent();

        yield return(new WaitForSecondsRealtime(1));

        // Drawing the component
        Debug.Log("Drawing");
        routerProve.Draw();
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "Hola a todos !!");

        yield return(new WaitForSecondsRealtime(1));

        // Hide the element
        routerProve.Disable();
        Assert.IsFalse(REbase.FindOne("#ProveText").gameObject.activeInHierarchy);

        // Change the states
        wordState.SetState("NewWord");
        Debug.Log("Check");
        Assert.IsFalse(REbase.FindOne("#ProveText").gameObject.activeInHierarchy);
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "NewWord");
        wordState.SetState("OtherWord");
        Debug.Log("Check");
        Assert.IsFalse(REbase.FindOne("#ProveText").gameObject.activeInHierarchy);
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "OtherWord");
        wordState.PrevState();
        Debug.Log("Check");
        Assert.IsFalse(REbase.FindOne("#ProveText").gameObject.activeInHierarchy);
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "NewWord");
        wordState.SetState("OtherWord");
        wordState.SetState("Word");
        wordState.SetState("LastWord");
        wordState.SetState("FinalWord");
        Debug.Log("Check");
        Assert.IsFalse(REbase.FindOne("#ProveText").gameObject.activeInHierarchy);
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "FinalWord");
        wordState.PrevState(1);
        Debug.Log("Check");
        Assert.IsFalse(REbase.FindOne("#ProveText").gameObject.activeInHierarchy);
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "LastWord");
        wordState.PrevState(2);
        Debug.Log("Check");
        Assert.IsFalse(REbase.FindOne("#ProveText").gameObject.activeInHierarchy);
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "OtherWord");
        wordState.PrevState(10);
        Debug.Log("Check");
        Assert.IsFalse(REbase.FindOne("#ProveText").gameObject.activeInHierarchy);
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "Hola a todos !!");
        wordState.PrevState();
        Debug.Log("Check");
        Assert.IsFalse(REbase.FindOne("#ProveText").gameObject.activeInHierarchy);
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "Hola a todos !!");
        Debug.Log("Check");

        // Enable and check
        routerProve.Enable();
        Assert.IsTrue(REbase.FindOne("#ProveText").gameObject.activeInHierarchy);
        Assert.IsTrue(REtext.FindOne("#ProveText").textCmp.text == "Hola a todos !!");
        Debug.Log("Check");


        yield return(new WaitForSecondsRealtime(2));

        routerProve.Erase();
    }