Exemplo n.º 1
0
        public void Get_Affinity_For_View_Should_Return_Non_Zero_For_Visual_Elements()
        {
            var userControl = new TestUserControl();
            var activationForViewFetcher = new AvaloniaActivationForViewFetcher();

            var forUserControl    = activationForViewFetcher.GetAffinityForView(userControl.GetType());
            var forNonUserControl = activationForViewFetcher.GetAffinityForView(typeof(object));

            Assert.NotEqual(0, forUserControl);
            Assert.Equal(0, forNonUserControl);
        }
Exemplo n.º 2
0
        public void Visual_Element_Is_Activated_And_Deactivated()
        {
            var userControl = new TestUserControl();
            var activationForViewFetcher = new AvaloniaActivationForViewFetcher();

            activationForViewFetcher
            .GetActivationForView(userControl)
            .ToObservableChangeSet(scheduler: ImmediateScheduler.Instance)
            .Bind(out var activated)
            .Subscribe();

            var fakeRenderedDecorator = new TestRoot();

            fakeRenderedDecorator.Child = userControl;
            Assert.True(activated[0]);
            Assert.Equal(1, activated.Count);

            fakeRenderedDecorator.Child = null;
            Assert.True(activated[0]);
            Assert.False(activated[1]);
            Assert.Equal(2, activated.Count);
        }