Exemple #1
0
        public void ModelBase_RemoveHandlerNullTest()
        {
            var person = new SimplePerson();

            try
            {
                person.RemoveHandler(null);
                Assert.Fail("Excepted an ArgumentNullException");
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("eventHandler", ex.ParamName);
            }
        }
Exemple #2
0
        public void ModelBase_AddRemoveHandlerTest()
        {
            var fired    = false;
            var person   = new SimplePerson();
            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);
        }