public void ReversableFirstOrDefault_SetToExistingItem_Correct() { INotifyCollection <string> collection = new NotifyCollection <string>() { "a", "b", "c" }; SetValue(() => collection.FirstOrDefault(), "b"); Assert.AreEqual(3, collection.Count); Assert.IsTrue(collection.Contains("a")); Assert.IsTrue(collection.Contains("b")); Assert.IsTrue(collection.Contains("c")); }
public void ReversableFirstOrDefault_WithPredicate_SetToExistingItem_Correct() { var collection = new NotifyCollection <string>() { "a", "b", "c" }; SetValue(() => collection.FirstOrDefault(s => string.Compare(s, "a") > 0), "b"); Assert.AreEqual(3, collection.Count); Assert.IsTrue(collection.Contains("a")); Assert.IsTrue(collection.Contains("b")); Assert.IsTrue(collection.Contains("c")); }
public void Contains_ObservableSourceElementAdded_NoUpdateWhenDetached() { var update = false; var coll = new NotifyCollection<int>() { 1, 2, 3 }; var test = Observable.Expression(() => coll.Contains(4)); test.ValueChanged += (o, e) => update = true; Assert.IsFalse(test.Value); Assert.IsFalse(update); test.Detach(); update = false; coll.Add(4); Assert.IsFalse(update); test.Attach(); Assert.IsTrue(update); Assert.IsTrue(test.Value); update = false; coll.Remove(4); Assert.IsTrue(update); }
public void Contains_ObservableSourceElementAdded_NoUpdateWhenDetached() { var update = false; var coll = new NotifyCollection <int>() { 1, 2, 3 }; var test = Observable.Expression(() => coll.Contains(4)); test.ValueChanged += (o, e) => update = true; Assert.IsFalse(test.Value); Assert.IsFalse(update); test.Detach(); update = false; coll.Add(4); Assert.IsFalse(update); test.Attach(); Assert.IsTrue(update); Assert.IsTrue(test.Value); update = false; coll.Remove(4); Assert.IsTrue(update); }