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()); }
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 BehaviorContextStub GetContext() { return(ViewModelStub .WithProperties(Build()) .BuildContext()); }