public void SetItems_ListChangedIsRaisedAfterBehaviors()
        {
            var actionLog = new StringBuilder();

            var changeListener = new TestChangeListener();

            var ownerProperty = PropertyStub
                                .WithBehaviors(changeListener)
                                .Build();

            var ownerVM = ViewModelStub
                          .WithProperties(ownerProperty)
                          .Build();

            var collection = new VMCollection <IViewModel>(ownerVM, ownerProperty);

            changeListener.HandleChange += delegate {
                actionLog.Append("ChangeHandlerBehavior ");
            };

            collection.ListChanged += delegate {
                actionLog.Append("ListChanged ");
            };

            IVMCollection <IViewModel> c = collection;

            c.ReplaceItems(new[] { ViewModelStub.Build(), ViewModelStub.Build() }, null);

            Assert.AreEqual("ChangeHandlerBehavior ListChanged ", actionLog.ToString());
        }
Esempio n. 2
0
        public void NotifyChange_WithValidationResultChangeForDescendantProperty_DoesNothing()
        {
            VMInterface.NotifyChange(ChangeArgs
                                     .ValidationResultChanged(PropertyStub.Build(), ValueStage.Value)
                                     .PrependViewModel(ViewModelStub.Build())
                                     .PrependViewModel(VM)
                                     );

            Assert.IsNull(VM.LastOnPropertyChangedInvocation);
            Assert.IsNull(VM.LastOnValidationStateChangedInvocation);
        }
Esempio n. 3
0
        public void NotifyChange_WithValidationResultChangeForOwnProperty_CallsValidationResultChanged()
        {
            var property = PropertyStub.Build();

            VMInterface.NotifyChange(ChangeArgs
                                     .ValidationResultChanged(property, ValueStage.Value)
                                     .PrependViewModel(VM)
                                     );

            Assert.AreEqual(property, VM.LastOnValidationStateChangedInvocation);
        }
Esempio n. 4
0
        public void NotifyChange_WithPropertyChangeForOwnProperty_CallsOnPropertyChanged()
        {
            var property = PropertyStub.Build();

            VMInterface.NotifyChange(ChangeArgs
                                     .PropertyChanged(property, ValueStage.DisplayValue)
                                     .PrependViewModel(VM)
                                     );

            Assert.AreEqual(property, VM.LastOnPropertyChangedInvocation);
        }
        public void Setup()
        {
            BehaviorStub = new ModificationCollectionBehaviorStub();
            var owner = new Mock <IViewModel> {
                DefaultValue = DefaultValue.Mock
            };

            Collection = new VMCollection <IViewModel>(
                owner.Object,
                PropertyStub.WithBehaviors(BehaviorStub).Build()
                );
        }
        public void GetItemProperties_ReturnsPropertyDescriptorCollection()
        {
            var itemTypeDescriptorBehavior = new TypeDescriptorProviderBehavior();

            var itemDescriptor = DescriptorStub
                                 .WithBehaviors(itemTypeDescriptorBehavior)
                                 .Build();

            var ownerProperty = PropertyStub
                                .WithBehaviors(new ItemDescriptorProviderBehavior(itemDescriptor))
                                .Build();

            var ownerVM = ViewModelStub
                          .WithProperties(ownerProperty)
                          .Build();

            var collection = new VMCollection <IViewModel>(ViewModelStub.Build(), ownerProperty);

            Assert.AreSame(itemTypeDescriptorBehavior.PropertyDescriptors, collection.GetItemProperties(null));
        }
 public VMCollectionStubBuilder()
 {
     _ownerVM       = ViewModelStub.Build();
     _ownerProperty = PropertyStub.Build();
     _items         = Enumerable.Empty <T>();
 }
 private VMCollection <IViewModel> CreateCollection()
 {
     return(new VMCollection <IViewModel>(ViewModelStub.Build(), PropertyStub.Build()));
 }