当前位置: 首页>>代码示例>>C#>>正文


C# Verify.AreEqual方法代码示例

本文整理汇总了C#中Verify.AreEqual方法的典型用法代码示例。如果您正苦于以下问题:C# Verify.AreEqual方法的具体用法?C# Verify.AreEqual怎么用?C# Verify.AreEqual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Verify的用法示例。


在下文中一共展示了Verify.AreEqual方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ValidationResultCollection_Test1

 public void ValidationResultCollection_Test1()
 {
     using (var verify = new Verify())
     {
         var collection = new ValidationResultCollection();
         var result = collection.Add("Test", "FirstName", "LastName");
         verify.AreEqual("Test", result.ErrorMessage, "Error message");
         verify.AreEqual("FirstName", result.MemberNames.ToList()[0], "member 0");
         verify.AreEqual("LastName", result.MemberNames.ToList()[1], "member 1");
     }
 }
开发者ID:docevaad,项目名称:Anchor,代码行数:11,代码来源:ValidationResultCollectionTests.cs

示例2: ChildPropertyChangesWithCommit

        public void ChildPropertyChangesWithCommit()
        {
            using (var verify = new Verify())
            {
                var customer = CreateCustomer(verify);

                //more setup
                customer.FirstName = "Tom";
                customer.LastName = "Doe";
                customer.AcceptChanges();
                if (customer.IsChanged)
                    verify.Inconclusive("setup failed");

                var eventAssertCustomer = new PropertyChangedEventTest(verify, customer);

                customer.PropertyChanged += (s, e) => Debug.WriteLine(e.PropertyName);

                //local changes
                customer.FirstName = "Bob";
                eventAssertCustomer.ExpectEvent("FirstName");
                eventAssertCustomer.ExpectEvent("FullName");
                eventAssertCustomer.ExpectEvent("IsChangedLocal");
                eventAssertCustomer.ExpectEvent("IsChanged");
                eventAssertCustomer.ExpectNothing();
                verify.IsTrue(customer.IsChanged, "");
                verify.IsTrue(customer.IsChangedLocal, "");
                verify.AreEqual(1, customer.ChangedProperties().Count, "There should be one changed property");
                verify.AreEqual("FirstName", customer.ChangedProperties()[0], "The property should be FirstName");

                //this time IsChanged shouldn't be raised again
                customer.LastName = "Jones";
                eventAssertCustomer.ExpectEvent("LastName");
                eventAssertCustomer.ExpectEvent("FullName");
                eventAssertCustomer.ExpectNothing();
                verify.IsTrue(customer.IsChanged, "");
                verify.IsTrue(customer.IsChangedLocal, "");

                //accept changes
                customer.AcceptChanges();
                verify.IsFalse(customer.IsChanged, "");
                verify.IsFalse(customer.IsChangedLocal, "");
                eventAssertCustomer.ExpectEvent("IsChangedLocal");
                eventAssertCustomer.ExpectEvent("IsChanged");
                eventAssertCustomer.ExpectNothing();
                verify.AreEqual("Bob", customer.FirstName, "");
                verify.AreEqual("Jones", customer.LastName, "");
                verify.AreEqual(0, customer.ChangedProperties().Count, "There shouldn't be any changed properties");
            }
        }
开发者ID:docevaad,项目名称:Anchor,代码行数:49,代码来源:ChangeTrackingTests.cs

示例3: ItemEventArgs_ItemTest

 public void ItemEventArgs_ItemTest()
 {
     using (var verify = new Verify())
     {
         var x = new ItemEventArgs<string>("xxx");
         verify.AreEqual("xxx", x.Item, "Item property was not set correctly");
     }
 }
开发者ID:docevaad,项目名称:Anchor,代码行数:8,代码来源:ItemEventArgsTests.cs

示例4: ExtendedObservableCollection_AddRemoveOverrideTest

 public void ExtendedObservableCollection_AddRemoveOverrideTest()
 {
     using (var verify = new Verify())
     {
         var result = new FooCollection(new[] { new Foo(), new Foo(), new Foo() });
         verify.AreEqual(3, result.AddCount, "count was incorrect");
     }
 }
开发者ID:docevaad,项目名称:Anchor,代码行数:8,代码来源:ExtendedObservableCollectionTests.cs

示例5: CalculatedFieldAttribute_Test1

        public void CalculatedFieldAttribute_Test1()
        {
            using (var verify = new Verify())
            {
                string fields = "AAA, BBB,CCC";
                var result = new CalculatedFieldAttribute(fields);
                verify.AreEqual(fields, result.Sources, "the field list shouldn't be altered in any way");
                verify.ItemsAreEqual(new[] { "AAA", "BBB", "CCC" }, result.SourceProperties, "");

            }
        }
开发者ID:docevaad,项目名称:Anchor,代码行数:11,代码来源:CalculatedFieldAttributeTests.cs

示例6: RelayedEventArgs_Test1

 public void RelayedEventArgs_Test1()
 {
     using (var verify = new Verify())
     {
         try
         {
             var e = RelayedEventArgs.Create(new object(), (EventArgs)null);
             verify.Fail("Expected an ArgumentNullException");
         }
         catch (ArgumentNullException ex)
         {
             verify.AreEqual("eventArgs", ex.ParamName, "Parameter name is wrong");
         }
     }
 }
开发者ID:docevaad,项目名称:Anchor,代码行数:15,代码来源:RelayedEventArgsTests.cs

示例7: ExtendedObservableCollection_AddRange_Test2

 public void ExtendedObservableCollection_AddRange_Test2()
 {
     using (var verify = new Verify())
     {
         try
         {
             var result = new ObservableCollectionExtended<object>();
             result.AddRange(null);
             verify.Fail("Expected an ArgumentNullException exception");
         }
         catch (ArgumentNullException ex)
         {
             verify.AreEqual("list", ex.ParamName, "Parameter name is incorrect");
         }
     }
 }
开发者ID:docevaad,项目名称:Anchor,代码行数:16,代码来源:ExtendedObservableCollectionTests.cs

示例8: PropertyMetadataCollection_CopyTo_Test1

        public void PropertyMetadataCollection_CopyTo_Test1()
        {
            using (var verify = new Verify())
            {
                try
                {
                    var result = MetadataCache.GetMetadata(typeof(Tests.Metadata.Mock)).Properties;
                    result.CopyTo(null, 0);

                    verify.Fail("Expected an ArgumentNullException");
                }
                catch (ArgumentNullException ex)
                {
                    verify.AreEqual("array", ex.ParamName, "Incorrect parameter name");
                }
            }
        }
开发者ID:docevaad,项目名称:Anchor,代码行数:17,代码来源:PropertyMetadataCollectionTests.cs

示例9: MetadataCache_Test11

 public void MetadataCache_Test11()
 {
     using (var verify = new Verify())
     {
         var result = MetadataCache.GetMetadata(typeof(Mock));
         var mock = new Mock();
         var prop = result.Properties["PublicProperty"];
         prop.InvokeSet(mock, 5);
         var value = (int)prop.InvokeGet(mock);
         verify.AreEqual(5, value, "InvokeGet");
     }
 }
开发者ID:docevaad,项目名称:Anchor,代码行数:12,代码来源:MetadataCacheTests.cs

示例10: 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);
        }
开发者ID:docevaad,项目名称:Anchor,代码行数:46,代码来源:ExtendedObservableCollectionTests.cs

示例11: ExtendedObservableCollection_SerializationTest2

        public void ExtendedObservableCollection_SerializationTest2()
        {
            using (var verify = new Verify())
            {
                var collection = new FooCollection();
                collection.Add(new Foo());
                collection.Add(new Foo());
                collection.Add(new Foo());

                var stream = new System.IO.MemoryStream();
                var fooSerializer = new DataContractSerializer(typeof(FooCollection));
                fooSerializer.WriteObject(stream, collection);
                stream.Position = 0;
                var newFoo = (FooCollection)fooSerializer.ReadObject(stream);

                verify.AreEqual(collection.Count, newFoo.Count, "collection count was off");

            }
        }
开发者ID:docevaad,项目名称:Anchor,代码行数:19,代码来源:ExtendedObservableCollectionTests.cs

示例12: 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");
            }
        }
开发者ID:docevaad,项目名称:Anchor,代码行数:20,代码来源:ExtendedObservableCollectionTests.cs

示例13: ExtendedObservableCollection_MixedAddRemoveTest

        public void ExtendedObservableCollection_MixedAddRemoveTest()
        {
            using (var verify = new Verify())
            {
                var fired = 0;
                var result = new FooCollection();
                PropertyChangedEventHandler eventHandler = (s, e) => fired += 1;

                result.PropertyChanged += eventHandler;
                result.Add(new Foo());
                verify.AreEqual(2, fired, "events were not fired"); //Count and Item[]

                ((INotifyPropertyChanged)result).PropertyChanged -= eventHandler;
                result.Add(new Foo());

                verify.AreEqual(2, fired, "handler wasn't removed"); //Count and Item[]

            }
        }
开发者ID:docevaad,项目名称:Anchor,代码行数:19,代码来源:ExtendedObservableCollectionTests.cs

示例14: 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");
            }
        }
开发者ID:docevaad,项目名称:Anchor,代码行数:27,代码来源:ExtendedObservableCollectionTests.cs

示例15: ExtendedReadOnlyObservableCollection_MemoryTest

        public void ExtendedReadOnlyObservableCollection_MemoryTest()
        {
            using (var verify = new Verify())
            {

                Func<WeakReference> builder = () =>
                {

                    var source = new ObservableCollectionExtended<int>();
                    var target = new ReadOnlyObservableCollectionExtended<int>(source);

                    var sourceEvents = new Queue<NotifyCollectionChangedEventArgs>();
                    var targetEvents = new Queue<NotifyCollectionChangedEventArgs>();

                    var sourceEvents2 = new Queue<PropertyChangedEventArgs>();
                    var targetEvents2 = new Queue<PropertyChangedEventArgs>();

                    source.CollectionChanged += (s, e) => sourceEvents.Enqueue(e);
                    target.CollectionChanged += (s, e) => targetEvents.Enqueue(e);

                    source.PropertyChanged += (s, e) => sourceEvents2.Enqueue(e);
                    target.PropertyChanged += (s, e) => targetEvents2.Enqueue(e);

                    Memory.CycleGC();

                    source.Add(1);
                    source.Add(2);
                    source.Add(3);

                    verify.AreEqual(3, sourceEvents.Count, "NotifyCollectionChangedEventArgs in source was wrong");
                    verify.AreEqual(3, targetEvents.Count, "NotifyCollectionChangedEventArgs in target was wrong");
                    verify.AreEqual(6, sourceEvents2.Count, "PropertyChangedEventArgs in source was wrong.  There should be 2 per add.");
                    verify.AreEqual(6, targetEvents2.Count, "PropertyChangedEventArgs in target was wrong. There should be 2 per add.");

                    verify.ItemsAreEqual(source, target, "");

                    return new WeakReference(target);
                };

                var wr = builder();

                Memory.CycleGC();

                verify.IsFalse(wr.IsAlive, "wr wasn't GC'd");
            }
        }
开发者ID:docevaad,项目名称:Anchor,代码行数:46,代码来源:ExtendedReadOnlyObservableCollectionTests.cs


注:本文中的Verify.AreEqual方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。