public void MyCollection_Should_Work_With_Linq() { var myCollection = new MyCollection(); myCollection[3] = new Item { Id = 3, Name = "Item 3" }; Assert.NotNull(myCollection.FirstOrDefault(i => i.Id == 3)); }
private void OnCollectionChanged(int?id) { var cartItem = Items.FirstOrDefault(x => x.Id == id); if (cartItem == null) { return; } cartItem.IsFavorite = !cartItem.IsFavorite; if (cartItem.IsFavorite) { MyCollection.Add(cartItem); } else { MyCollection.Remove(MyCollection.FirstOrDefault(x => x.Id == id)); } }