public void ShouldBeAbleToChangeCreateWrapperFunction() { var wrapper1 = new ModelWrapper(new Model { Name = "One" }); var wrapper2 = new ModelWrapper(new Model { Name = "Two" }); var collectionA = new ObservableCollection<Model>(); var wrapper = new ObservableCollectionWrapper<Model, ModelWrapper>(collectionA, item => wrapper1); collectionA.Add(wrapper1.Source); wrapper.Contains(wrapper1).ShouldBe(true); // --- wrapper.CreateWrapper = item => wrapper2; collectionA.Add(wrapper2.Source); wrapper.Contains(wrapper2).ShouldBe(true); }
public void ShouldRemoveStringWrapperItems() { var list = new List<string> { "item1", "Clown", "item1", "Zebra"}; var collectionA = new ObservableCollection<string>(); collectionA.AddRange(list); var wrappers = new ObservableCollectionWrapper<string, StringWrapper>(collectionA, item => new StringWrapper(item)); wrappers.Count.ShouldBe(4); var wrapper1 = wrappers[0]; var wrapper2 = wrappers[1]; var wrapper3 = wrappers[2]; var wrapper4 = wrappers[3]; collectionA.RemoveAt(2); wrappers.Count.ShouldBe(3); wrappers.Contains(wrapper1).ShouldBe(true); wrappers.Contains(wrapper3).ShouldBe(false); // Should remove the 3rd item, not the 1st item (of the same string value). }