public void SetBindingTest()
        {
            var context = new TestContext <string> {
                Property = contextInitial
            };
            var view = new TestView <string> {
                Value = viewInitial
            };

            view.Bind(view)
            .ViewProperty(v => v.Value)
            .To <TestContext <string> >(ctx => ctx.Property);

            Assert.AreEqual(contextInitial, context.Property);
            Assert.AreEqual(viewInitial, view.Value);
        }
        public void BindingConverterFullFlowTest()
        {
            var viewInitialLocal    = "100";
            var contextInitialLocal = 200;
            var viewUpdatedLocal    = "300";
            var contextUpdatedLocal = 400;

            var context = new TestContext <int> {
                Property = contextInitialLocal
            };
            var view = new TestView <string> {
                Value = viewInitialLocal
            };

            // set binding => nothing should be cnahged
            view.Bind(view)
            .ViewProperty(v => v.Value)
            .ViewEvent(nameof(view.ValueChanged))
            .Converter(Converters.IntString)
            .To <TestContext <int> >(ctx => ctx.Property);

            Assert.AreEqual(contextInitialLocal, context.Property);
            Assert.AreEqual(viewInitialLocal, view.Value);

            // set context => view should be updated
            BindingStorage.SetContext(view, context);

            Assert.AreEqual(contextInitialLocal, context.Property);
            Assert.AreEqual(Converters.IntString.Convert(contextInitialLocal), view.Value);

            // view updated > context shold be updated
            view.Value = viewUpdatedLocal;

            Assert.AreEqual(Converters.IntString.ConvertBack(viewUpdatedLocal), context.Property);
            Assert.AreEqual(viewUpdatedLocal, view.Value);

            // context update => view should be updated
            context.Property = contextUpdatedLocal;

            Assert.AreEqual(contextUpdatedLocal, context.Property);
            Assert.AreEqual(Converters.IntString.Convert(contextUpdatedLocal), view.Value);
        }
        public void UpdateContextValueTest()
        {
            var context = new TestContext <string> {
                Property = contextInitial
            };
            var view = new TestView <string> {
                Value = viewInitial
            };

            view.Bind(view)
            .ViewProperty(v => v.Value)
            .To <TestContext <string> >(ctx => ctx.Property);

            BindingStorage.SetContext(view, context);

            context.Property = contextUpdated;

            Assert.AreEqual(contextUpdated, context.Property);
            Assert.AreEqual(contextUpdated, view.Value);
        }
        public void TwoWayBindingFullFlowTest()
        {
            var context = new TestContext <string> {
                Property = contextInitial
            };
            var view = new TestView <string> {
                Value = viewInitial
            };

            // set binding => nothing should be cnahged
            view.Bind(view)
            .ViewProperty(v => v.Value)
            .ViewEvent(nameof(view.ValueChanged))
            .To <TestContext <string> >(ctx => ctx.Property);

            Assert.AreEqual(contextInitial, context.Property);
            Assert.AreEqual(viewInitial, view.Value);

            // set context => view should be updated
            BindingStorage.SetContext(view, context);

            Assert.AreEqual(contextInitial, context.Property);
            Assert.AreEqual(contextInitial, view.Value);

            // view updated > context shold be updated
            view.Value = viewUpdated;

            Assert.AreEqual(viewUpdated, context.Property);
            Assert.AreEqual(viewUpdated, view.Value);

            // context update => view should be updated
            context.Property = contextUpdated;

            Assert.AreEqual(contextUpdated, context.Property);
            Assert.AreEqual(contextUpdated, view.Value);
        }