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();
    }
    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_InDisabledCanvas()
    {
        var alphaState = new UseState <float>(0f);

        // A Component
        REcanvas MainReactorComponent()
        {
            return(new REcanvas
            {
                propsId = () => new REcanvas.IdSetter
                {
                    id = "ProveCanvas"
                },
                propsCanvasGroup = () => new REcanvas.CanvasGroupSetter
                {
                    alpha = alphaState.value,
                },
                useState = new IuseState[]
                {
                    alphaState,
                },
                childs = () => new REbase[] {
                    new REtext(),
                },
            });
        }

        var routerProve = MainReactorComponent();

        yield return(new WaitForSecondsRealtime(1));

        // Drawing the component
        Debug.Log("Drawing");
        routerProve.Draw();
        Assert.IsTrue(REcanvas.FindOne("#ProveCanvas").canvasGroup.alpha == 0f);

        yield return(new WaitForSecondsRealtime(1));

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

        // Change the states
        alphaState.SetState(.33f);
        Assert.IsTrue(REcanvas.FindOne("#ProveCanvas").canvasGroup.alpha == .33f);

        // Will disable after one frame, because need to be active to calculate all the rect transform parameters
        yield return(new WaitForSecondsRealtime(.3f));

        Assert.IsFalse(REbase.FindOne("#ProveCanvas").gameObject.activeSelf);

        alphaState.SetState(.66f);
        // Will disable after one frame, because need to be active to calculate all the rect transform parameters
        yield return(new WaitForSecondsRealtime(.3f));

        Assert.IsTrue(REcanvas.FindOne("#ProveCanvas").canvasGroup.alpha == .66f);
        Assert.IsFalse(REbase.FindOne("#ProveCanvas").gameObject.activeSelf);

        alphaState.PrevState();

        // Will disable after one frame, because need to be active to calculate all the rect transform parameters
        yield return(new WaitForSecondsRealtime(.3f));

        Assert.IsTrue(REcanvas.FindOne("#ProveCanvas").canvasGroup.alpha == .33f);
        Assert.IsFalse(REbase.FindOne("#ProveCanvas").gameObject.activeSelf);


        // Enable and check
        routerProve.Enable();
        // Will disable after one frame, because need to be active to calculate all the rect transform parameters
        yield return(new WaitForSecondsRealtime(.3f));

        Assert.IsTrue(REcanvas.FindOne("#ProveCanvas").canvasGroup.alpha == .33f);
        Assert.IsTrue(REbase.FindOne("#ProveCanvas").gameObject.activeSelf);


        yield return(new WaitForSecondsRealtime(2));

        routerProve.Erase();
    }
    public IEnumerator Hooks_UseState_InHidedCanvas()
    {
        var alphaState = new UseState <float>(0f);

        // A Component
        REcanvas MainReactorComponent()
        {
            return(new REcanvas
            {
                propsId = () => new REcanvas.IdSetter
                {
                    id = "ProveCanvas"
                },
                propsCanvasGroup = () => new REcanvas.CanvasGroupSetter
                {
                    alpha = alphaState.value,
                },
                useState = new IuseState[]
                {
                    alphaState,
                },
                childs = () => new REbase[] {
                    new REtext(),
                },
            });
        }

        var routerProve = MainReactorComponent();

        yield return(new WaitForSecondsRealtime(1));

        // Drawing the component
        Debug.Log("Drawing");
        routerProve.Draw();
        Assert.IsTrue(REcanvas.FindOne("#ProveCanvas").canvasGroup.alpha == 0f);

        yield return(new WaitForSecondsRealtime(1));

        // Hide the element
        routerProve.Hide();
        Assert.IsFalse(REbase.FindOne("#ProveCanvas").rootCanvasSelector.canvas.enabled);

        // Change the states
        alphaState.SetState(.33f);
        Assert.IsTrue(REcanvas.FindOne("#ProveCanvas").canvasGroup.alpha == .33f);
        Assert.IsFalse(REcanvas.FindOne("#ProveCanvas").rootCanvasSelector.canvas.enabled);
        alphaState.SetState(.66f);
        Assert.IsTrue(REcanvas.FindOne("#ProveCanvas").canvasGroup.alpha == .66f);
        Assert.IsFalse(REcanvas.FindOne("#ProveCanvas").rootCanvasSelector.canvas.enabled);
        alphaState.PrevState();
        Assert.IsTrue(REcanvas.FindOne("#ProveCanvas").canvasGroup.alpha == .33f);
        Assert.IsFalse(REcanvas.FindOne("#ProveCanvas").rootCanvasSelector.canvas.enabled);

        // Enable and check
        routerProve.Show();
        Assert.IsTrue(REcanvas.FindOne("#ProveCanvas").canvasGroup.alpha == .33f);
        Assert.IsTrue(REcanvas.FindOne("#ProveCanvas").rootCanvasSelector.canvas.enabled);


        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();
    }