本文整理汇总了C#中Verify.AreSame方法的典型用法代码示例。如果您正苦于以下问题:C# Verify.AreSame方法的具体用法?C# Verify.AreSame怎么用?C# Verify.AreSame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Verify
的用法示例。
在下文中一共展示了Verify.AreSame方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConstructorAssertions
private static void ConstructorAssertions(Verify verify, ObservableCollectionExtended<object> result, WeakNotifier weakNotifier, Notifier notifier)
{
var itemAssert = new ItemPropertyChangedEventTest(verify, result);
var itemAddedEventQueue = new Queue<Tuple<object, ItemEventArgs<object>>>();
result.ItemAdded += (s, e) => itemAddedEventQueue.Enqueue(Tuple.Create(s, e));
var itemRemovedEventQueue = new Queue<Tuple<object, ItemEventArgs<object>>>();
result.ItemRemoved += (s, e) => itemRemovedEventQueue.Enqueue(Tuple.Create(s, e));
weakNotifier.Age += 1;
itemAssert.ExpectEvent(weakNotifier, "Age");
notifier.Age += 1;
itemAssert.ExpectEvent(notifier, "Age");
var oldCount = result.Count;
result.Clear();
verify.AreEqual(oldCount, itemRemovedEventQueue.Count, "incorrect number of items reported as being removed");
weakNotifier.Age += 1;
notifier.Age += 1;
verify.AreEqual(0, result.Count, "The collection should be empty");
itemAssert.ExpectCountEquals(0, "ItemPropertyChanged events were fired when the collection was supposed to be empty.");
result.Add(weakNotifier);
result.Add(notifier);
verify.AreEqual(2, result.Count, "The new items were not added");
verify.AreEqual(2, itemAddedEventQueue.Count, "The new item events didn't fire");
CollectionAssert.AreEqual(result, result.ReadOnlyWrapper);
itemRemovedEventQueue.Clear();
result.RemoveAt(0);
verify.AreEqual(1, itemRemovedEventQueue.Count, "the item wasn't removed");
verify.AreSame(notifier, result[0], "the wrong item was removed");
CollectionAssert.AreEqual(result, result.ReadOnlyWrapper);
itemAddedEventQueue.Clear();
itemRemovedEventQueue.Clear();
result[0] = weakNotifier;
verify.AreSame(weakNotifier, result[0], "the item wasn't updated");
verify.AreEqual(1, itemAddedEventQueue.Count, "the add event for replacing an item didn't fire");
verify.AreEqual(1, itemRemovedEventQueue.Count, "the remove event for replacing an item didn't fire");
CollectionAssert.AreEqual(result, result.ReadOnlyWrapper);
}
示例2: ExtendedObservableCollection_CollectionChangedListenerTest
public void ExtendedObservableCollection_CollectionChangedListenerTest()
{
using (var verify = new Verify())
{
var result = new FooCollection();
var collectionChangedEventQueue = new Queue<Tuple<object, NotifyCollectionChangedEventArgs>>();
var collectionChangedListener = new Listener<NotifyCollectionChangedEventArgs>((s, e) => collectionChangedEventQueue.Enqueue(Tuple.Create(s, e)));
result.AddHandler(collectionChangedListener);
result.Add(new Foo());
verify.AreEqual(1, collectionChangedEventQueue.Count, "event didn't fire");
var event1 = collectionChangedEventQueue.Dequeue();
verify.AreSame(result, event1.Item1, "event has the wrong item");
verify.AreEqual(NotifyCollectionChangedAction.Add, event1.Item2.Action, "event as the wrong action");
result.RemoveHandler(collectionChangedListener);
result.Add(new Foo());
verify.AreEqual(0, collectionChangedEventQueue.Count, "event handler wasn't removed");
}
}
示例3: ExtendedObservableCollection_PropertyChangedListenerTest
public void ExtendedObservableCollection_PropertyChangedListenerTest()
{
using (var verify = new Verify())
{
var result = new FooCollection();
var propertyChangedEventQueue = new Queue<Tuple<object, PropertyChangedEventArgs>>();
var propertyChangedListener = new Listener<PropertyChangedEventArgs>((s, e) => propertyChangedEventQueue.Enqueue(Tuple.Create(s, e)));
result.AddHandler(propertyChangedListener);
result.Boom += 1;
verify.AreEqual(1, propertyChangedEventQueue.Count, "event didn't fire");
var event1 = propertyChangedEventQueue.Dequeue();
verify.AreSame(result, event1.Item1, "event has the wrong item");
verify.AreEqual("Boom", event1.Item2.PropertyName, "event as the wrong parameter name");
result.RemoveHandler(propertyChangedListener);
result.Boom += 1;
verify.AreEqual(0, propertyChangedEventQueue.Count, "event handler wasn't removed");
}
}
示例4: ExtendedObservableCollection_ItemPropertyChangedListenerTest2
public void ExtendedObservableCollection_ItemPropertyChangedListenerTest2()
{
using (var verify = new Verify())
{
var result = new FooCollection();
var itemPropertyChangedEventQueue = new Queue<Tuple<object, RelayedEventArgs<PropertyChangedEventArgs>>>();
var itemPropertyChangedListener = new Listener<RelayedEventArgs<PropertyChangedEventArgs>>((s, e) => itemPropertyChangedEventQueue.Enqueue(Tuple.Create(s, e)));
var mutator = new Foo();
result.Add(mutator);
result.AddHandler(itemPropertyChangedListener);
mutator.FooBar = "AAA";
verify.AreEqual(1, itemPropertyChangedEventQueue.Count, "event didn't fire");
var event1 = itemPropertyChangedEventQueue.Dequeue();
verify.AreSame(result, event1.Item1, "event has the wrong item");
verify.AreEqual<object>(mutator, event1.Item2.OriginalSender, "event has the wrong original sender");
verify.AreEqual("FooBar", event1.Item2.EventArgs.PropertyName, "event as the wrong parameter name");
result.Remove(mutator);
mutator.FooBar = "BBB";
verify.AreEqual(0, itemPropertyChangedEventQueue.Count, "event handler wasn't removed");
}
}
示例5: MetadataCache_Test14B
public void MetadataCache_Test14B()
{
using (var verify = new Verify())
{
var result = MetadataCache.GetMetadata(typeof(StringIndexedMock));
var x = result.Properties["Item [System.String]"];
verify.IsNotNull(x, "Item [System.String] property is missing");
var y = result.Properties["Item[]"];
verify.IsNotNull(y, "Item[] property is missing");
verify.AreSame(x, y, "Item[] and Item [System.String] don't match");
}
}
示例6: MetadataCache_Test14
public void MetadataCache_Test14()
{
using (var verify = new Verify())
{
var result = MetadataCache.GetMetadata(typeof(List<int>));
foreach (var item in result.Properties)
{
Debug.WriteLine(item.Name);
}
var x = result.Properties["Item [Int32]"];
verify.IsNotNull(x, "Item [Int32] property is missing");
var y = result.Properties["Item[]"];
verify.IsNotNull(y, "Item[] property is missing");
verify.AreSame(x, y, "Item[] and Item [Int32] don't match");
}
}
示例7: MetadataCache_ReflexiveTest2
public void MetadataCache_ReflexiveTest2()
{
using (var verify = new Verify())
{
var fromTypeInfo = MetadataCache.GetMetadata(typeof(Mock).GetTypeInfo());
var fromType = MetadataCache.GetMetadata(typeof(Mock));
verify.AreSame(fromType, fromTypeInfo, "From TypeInfo was not cached");
}
}