本文整理汇总了C#中Microsoft.VisualStudio.TestTools.UnitTesting.List.WithUpdates方法的典型用法代码示例。如果您正苦于以下问题:C# List.WithUpdates方法的具体用法?C# List.WithUpdates怎么用?C# List.WithUpdates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.VisualStudio.TestTools.UnitTesting.List
的用法示例。
在下文中一共展示了List.WithUpdates方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Distinct_ObservableSource_NoUpdateWhenDetached
public void Distinct_ObservableSource_NoUpdateWhenDetached()
{
var update = false;
var coll = new List<int>() { 1, 2, 2, 3 };
var test = coll.WithUpdates().Distinct();
test.CollectionChanged += (o, e) => update = true;
Assert.AreEqual(3, test.Count());
Assert.IsFalse(update);
test.Detach();
update = false;
coll.Add(4);
Assert.IsFalse(update);
test.Attach();
Assert.IsTrue(update);
Assert.AreEqual(4, test.Count());
update = true;
coll.Remove(4);
Assert.IsTrue(update);
}
示例2: Min_NoObservableSourceNewMinAdded_NoUpdate
public void Min_NoObservableSourceNewMinAdded_NoUpdate()
{
var update = false;
var coll = new List<int>() { 1, 2, 3 };
var test = Observable.Expression(() => coll.WithUpdates().Min());
test.ValueChanged += (o, e) => update = true;
Assert.AreEqual(1, test.Value);
Assert.AreEqual(1, coll.WithUpdates().Min());
Assert.IsFalse(update);
coll.Add(0);
Assert.IsFalse(update);
}
示例3: LambdaMax_NoObservableSourceNewMaxAdded_NoUpdate
public void LambdaMax_NoObservableSourceNewMaxAdded_NoUpdate()
{
var update = false;
var coll = new List<Dummy<int>>() { new Dummy<int>(-1), new Dummy<int>(-2), new Dummy<int>(-3) };
var test = Observable.Expression(() => coll.WithUpdates().Max(d => d.Item));
test.ValueChanged += (o, e) => update = true;
Assert.AreEqual(-1, test.Value);
Assert.AreEqual(-1, coll.WithUpdates().Max(d => d.Item));
Assert.IsFalse(update);
coll.Add(new Dummy<int>(0));
Assert.IsFalse(update);
}
示例4: Distinct_NoObservableSourceNewItemAdded_NoUpdate
public void Distinct_NoObservableSourceNewItemAdded_NoUpdate()
{
var update = false;
var coll = new List<int>() { 1, 2, 2, 3 };
var test = coll.WithUpdates().Distinct();
test.CollectionChanged += (o, e) => update = true;
Assert.AreEqual(3, test.Count());
Assert.IsFalse(update);
coll.Add(4);
Assert.IsFalse(update);
}
示例5: Count_NoObservableSourceItemAdded_NoUpdate
public void Count_NoObservableSourceItemAdded_NoUpdate()
{
var update = false;
var coll = new List<int>() { 1, 2, 3 };
var test = Observable.Expression(() => coll.WithUpdates().Count());
test.ValueChanged += (o, e) => update = true;
Assert.AreEqual(3, test.Value);
Assert.IsFalse(update);
coll.Add(4);
Assert.IsFalse(update);
}
示例6: Contains_NoObservableSourceElementAdded_NoUpdate
public void Contains_NoObservableSourceElementAdded_NoUpdate()
{
var update = false;
var coll = new List<int>() { 1, 2, 3 };
var test = Observable.Expression(() => coll.WithUpdates().Contains(4));
test.ValueChanged += (o, e) => update = true;
Assert.IsFalse(test.Value);
Assert.IsFalse(update);
coll.Add(4);
Assert.IsFalse(update);
}
示例7: Any_NoObservableSourceItemRemovedThusEmptyCollection_NoUpdate
public void Any_NoObservableSourceItemRemovedThusEmptyCollection_NoUpdate()
{
var update = false;
var coll = new List<int>() { 1 };
var test = Observable.Expression(() => coll.WithUpdates().Any());
test.ValueChanged += (o, e) => update = true;
Assert.IsTrue(test.Value);
Assert.IsFalse(update);
coll.Remove(1);
Assert.IsFalse(update);
}
示例8: FirstOrDefault_NoObservableSourceFirstItemAdded_NoUpdate
public void FirstOrDefault_NoObservableSourceFirstItemAdded_NoUpdate()
{
var update = false;
var coll = new List<string>();
var test = Observable.Expression(() => coll.WithUpdates().FirstOrDefault());
test.ValueChanged += (o, e) => update = true;
Assert.IsNull(test.Value);
Assert.IsFalse(update);
coll.Add("42");
Assert.IsFalse(update);
}
示例9: OfTypeTests_NoObservableSourceItemRemoved_NoUpdate
public void OfTypeTests_NoObservableSourceItemRemoved_NoUpdate()
{
var update = false;
var coll = new List<object>() { 23, "42", null };
var test = coll.WithUpdates().OfType<string>();
test.CollectionChanged += (o, e) => update = true;
test.AssertSequence("42");
Assert.IsFalse(update);
coll.Remove("42");
Assert.IsFalse(update);
}
示例10: OfTypeTests_ItemOfOtherTypeAdded_NoUpdate
public void OfTypeTests_ItemOfOtherTypeAdded_NoUpdate()
{
var update = false;
var coll = new List<object>() { 23, "42", null };
var test = coll.WithUpdates().OfType<string>();
test.CollectionChanged += (o, e) => update = true;
test.AssertSequence("42");
Assert.IsFalse(update);
coll.Add(2.0);
Assert.IsFalse(update);
}
示例11: OrderBy_NoObservableSourceItemAdded_NoUpdate
public void OrderBy_NoObservableSourceItemAdded_NoUpdate()
{
var update = false;
var coll = new List<string>() { "C", "A", "D" };
var test = coll.WithUpdates().OrderBy(item => item);
test.CollectionChanged += (o, e) => update = true;
test.AssertSequence("A", "C", "D");
Assert.AreEqual(3, test.Sequences.Count());
Assert.IsFalse(update);
coll.Add("B");
Assert.IsFalse(update);
}
示例12: Concat_NoObservableSource1ItemAdded_NoUpdate
public void Concat_NoObservableSource1ItemAdded_NoUpdate()
{
var update = false;
var coll1 = new List<int>() { 1, 2, 3 };
var coll2 = new List<int>() { 4, 5, 6 };
var test = coll1.WithUpdates().Concat(coll2);
test.CollectionChanged += (o, e) => update = true;
test.AssertSequence(1, 2, 3, 4, 5, 6);
Assert.IsFalse(update);
coll1.Add(4);
Assert.IsFalse(update);
}
示例13: Select_NoObservableSourceItemAdded_NoUpdate
public void Select_NoObservableSourceItemAdded_NoUpdate()
{
var update = false;
ICollection<Dummy<string>> coll = new List<Dummy<string>>();
var test = coll.WithUpdates().Select(d => d.Item);
test.CollectionChanged += (o, e) => update = true;
Assert.IsTrue(!test.Any());
Assert.IsFalse(update);
coll.Add(new Dummy<string>() { Item = "42" });
Assert.IsTrue(!test.Any());
Assert.IsFalse(update);
}
示例14: All_NoObservableSourceItemRemoved_NoUpdate
public void All_NoObservableSourceItemRemoved_NoUpdate()
{
var update = false;
var coll = new List<int>() { 1, 2, 3, -1 };
var test = Observable.Expression(() => coll.WithUpdates().All(i => i > 0));
test.ValueChanged += (o, e) => update = true;
Assert.IsFalse(test.Value);
Assert.IsFalse(update);
coll.Remove(-1);
Assert.IsFalse(update);
}
示例15: Where_NoObservableSourceSuppressedAdded_NoUpdates
public void Where_NoObservableSourceSuppressedAdded_NoUpdates()
{
var update = false;
ICollection<Dummy<bool>> coll = new List<Dummy<bool>>();
var dummy = new Dummy<bool>() { Item = false };
var test = coll.WithUpdates().Where(d => d.Item);
test.CollectionChanged += (o, e) => update = true;
Assert.IsFalse(Sys.Contains(test, dummy));
Assert.IsFalse(update);
coll.Add(dummy);
Assert.IsFalse(update);
Assert.IsFalse(Sys.Contains(test, dummy));
}