Exemple #1
0
        public void EditableObjectModelBase_AddHandlerNullTest()
        {
            var person = new EditablePerson();

            try
            {
                person.AddHandler(null);
                Assert.Fail("Excepted an ArgumentNullException");
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("eventHandler", ex.ParamName);
            }
        }
Exemple #2
0
        public void EditableObjectModelBase_AddRemoveHandlerTest()
        {
            var fired    = false;
            var person   = new EditablePerson();
            var listener = new Listener <PropertyChangedEventArgs>((sender, e) => { fired = true; });

            person.ErrorsChanged += (sender, e) => { };
            person.AddHandler(listener);
            person.FirstName = "Tom";
            Assert.IsTrue(fired);
            fired = false;
            person.RemoveHandler(listener);
            person.FirstName = "Sam";
            Assert.IsFalse(fired);
        }