public void On_child_updated_while_a_render_operation_is_in_progress_gets_queued()
        {
            _terminal.Height     = 40;
            _terminal.Width      = 100;
            _terminal.CursorLeft = _terminal.CursorTop = 20;

            var screen = new ScreenView(_renderer, _terminal, _synchronizationContext);
            var view   = new TestView();

            void BeforeRenderAction()
            {
                view.BeforeRender = null;
                view.RaiseUpdated();
                view.RaiseUpdated();
            }

            view.BeforeRender = BeforeRenderAction;
            screen.Child      = view;

            //Simulate multiple concurrent updates
            view.RaiseUpdated();
            _synchronizationContext.InvokePostCallbacks();

            _synchronizationContext.PostInvocationCount.Should().Be(2);
            view.RenderedRegions
            .Should()
            .BeEquivalentSequenceTo(
                new Region(0, 0, 100, 40),
                new Region(0, 0, 100, 40));
        }
        public void On_child_updated_the_render_operation_is_synchronized()
        {
            _terminal.Height     = 40;
            _terminal.Width      = 100;
            _terminal.CursorLeft = _terminal.CursorTop = 20;

            var screen = new ScreenView(_renderer, _terminal, _synchronizationContext);
            var view   = new TestView();

            screen.Child = view;

            //Simulate multiple concurrent updates
            view.RaiseUpdated();
            view.RaiseUpdated();
            _synchronizationContext.InvokePostCallbacks();

            _synchronizationContext.PostInvocationCount.Should().Be(1);
            view.RenderedRegions.Should().BeEquivalentSequenceTo(new Region(0, 0, 100, 40));
        }
Exemple #3
0
        public void Child_added_to_layout_registers_for_updated()
        {
            var layout = new TestLayout();
            var view   = new TestView();

            layout.Add(view);

            view.RaiseUpdated();

            layout.OnChildUpdatedInvocationCount.Should().Be(1);
        }
        public void Dispose_unregisters_from_updated_event()
        {
            var screen = new ScreenView(_renderer, _terminal, _synchronizationContext);
            var view   = new TestView();

            screen.Child = view;

            screen.Dispose();
            view.RaiseUpdated();

            _synchronizationContext.PostInvocationCount.Should().Be(0);
        }
Exemple #5
0
        public void Removing_child_from_layout_unregisters_for_updated()
        {
            var layout = new TestLayout();
            var view   = new TestView();

            layout.Add(view);
            layout.Remove(view);
            view.RaiseUpdated();

            layout.OnChildUpdatedInvocationCount.Should().Be(0);
            layout.Children.Should().BeEmpty();
        }