public void DoesNotReactOnViewChangeIfHorizontal()
        {
            var actual = 0;

            _onViewChange = () => actual++;
            _subs.Subscribe(isVertical: false);

            Assert.Equal(0, actual);

            _textView.Raise(tv => tv.ViewportHeightChanged += null, EventArgs.Empty);
            Assert.Equal(0, actual);

            var zlcea = new Mock <ZoomLevelChangedEventArgs>(100, null);

            _textView.Raise(tv => tv.ZoomLevelChanged += null, zlcea.Object);
            Assert.Equal(0, actual);
        }
        public void FmsIsNotLeakedDueToEvents(bool isVertical)
        {
            var subs = new FrameMarginSubscriptions(
                _mappingEvents.Object,
                _textView.Object,
                (_, __) => _onMappingChange?.Invoke(),
                (_, __) => _onViewChange?.Invoke());

            var weakSubs = new WeakReference(subs);

            subs.Subscribe(isVertical);
            subs.Unsubscribe();
            subs = null;

            RunGarbageCollector();

            Assert.Null(weakSubs.Target);
        }
Exemplo n.º 3
0
        private async Task InitializeAsync(string filePath, IWpfTextView textView)
        {
            void updateHorizontalHeight(object sender, EventArgs e)
            {
                Height = textView.ViewportHeight * (textView.ZoomLevel / 100);
            }

            var props = new FrameMarginProperties(filePath);

            await UpdateAllVisualsAsync(props);

            ClipToBounds = true;

            _subscriptions = new FrameMarginSubscriptions(
                (await Global.GetPackageAsync()).Services.MappingEvents,
                textView,
                CreateHandlerForUpdateEverything(props),
                updateHorizontalHeight);

            _subscriptions.Subscribe(_isVertical);
        }