Пример #1
0
        public void DependencyObjectAutoViewModel()
        {
            var obj = new DependencyObject();

            IocBehavior.SetAutoViewModel(obj, typeof(DefinedType));
            IocBehavior.GetAutoViewModel(obj).Should().Be(typeof(DefinedType));
            IocBehavior.SetAutoViewModel(obj, typeof(UndefinedType));
            IocBehavior.GetAutoViewModel(obj).Should().Be(typeof(UndefinedType));
        }
Пример #2
0
        public void FrameworkElementAutoViewModel()
        {
            var obj = new FrameworkElement();

            IocBehavior.SetAutoViewModel(obj, typeof(DefinedType));
            IocBehavior.GetAutoViewModel(obj).Should().Be(typeof(DefinedType));
            obj.DataContext.Should().Be(new DefinedType());
            IocBehavior.SetAutoViewModel(obj, typeof(UndefinedType));
            IocBehavior.GetAutoViewModel(obj).Should().Be(typeof(UndefinedType));
            obj.DataContext.Should().BeNull();
        }