Пример #1
0
        public void TestName()
        {
            var obj = new SimpleObject();

            using var counter = INPCCounter.VerifyInpcFired(obj, i => i.X);
            obj.X             = 10;
            Assert.Equal(10, obj.X);
        }
Пример #2
0
        public void TestOnChangedMethod()
        {
            var obj = new HasChangeMethod();

            using var counter = INPCCounter.VerifyInpcFired(obj, i => i.NotifyChanged, i => i.X);
            obj.X             = 10;
            Assert.Equal(10, obj.X);
            Assert.Equal("0 -> 10", obj.NotifyChanged);
        }
Пример #3
0
        public void MonitorForeignEvent()
        {
            var sc1 = new SimpleContainer();
            var sc2 = new SimpleContainer();

            sc2.DelegatePropertyChangeFrom(sc1, "Value", "Value");

            using (var foo = INPCCounter.VerifyInpcFired(sc2, o => o.Value))
            {
                sc1.Value = "This is not the default value";
            }
        }
Пример #4
0
        public void DeleteFromMainList()
        {
            int fired = 0;

            smc.CollectionChanged += (s, e) =>
            {
                Assert.Equal(NotifyCollectionChangedAction.Reset, e.Action);

                fired++;
            };

            using (var foo = INPCCounter.VerifyInpcFired(smc, i => i.Count))
            {
                allInts.RemoveAt(1);
            }

            Assert.Equal(1, fired);
        }
Пример #5
0
        public void InsertInMainList()
        {
            int fired = 0;

            smc.CollectionChanged += (s, e) =>
            {
                Assert.Equal(NotifyCollectionChangedAction.Reset, e.Action);

                fired++;
            };

            using (var foo = INPCCounter.VerifyInpcFired(smc, i => i.Count))
            {
                allInts.Add(new ThreadSafeBindableCollection <int>());
            }

            Assert.Equal(1, fired);
        }
Пример #6
0
        public void InsertInSubList()
        {
            int fired = 0;

            smc.CollectionChanged += (s, e) =>
            {
                Assert.Equal(1, e.NewItems.Count);
                Assert.Equal(100, e.NewItems[0]);
                Assert.Equal(8, e.NewStartingIndex);
                fired++;
            };

            using (var foo = INPCCounter.VerifyInpcFired(smc, i => i.Count))
            {
                ints2.Insert(2, 100);
            }

            Assert.Equal(1, fired);
        }
Пример #7
0
        public void DeleteFromSubList()
        {
            int fired = 0;

            smc.CollectionChanged += (s, e) =>
            {
                Assert.Equal(1, e.OldItems.Count);
                Assert.Equal(8, e.OldItems[0]);
                Assert.Equal(8, e.OldStartingIndex);
                fired++;
            };

            using (var foo = INPCCounter.VerifyInpcFired(smc, i => i.Count))
            {
                ints2.RemoveAt(2);
            }

            Assert.Equal(1, fired);
        }
Пример #8
0
        public void AddAndReleaseSemantics()
        {
            var parent = new SimpleParent();
            var child  = new Lists.ListMonitors.NotifyChildBase <SimpleParent>();
            var list   = new ParentList <Lists.ListMonitors.NotifyChildBase <SimpleParent>, SimpleParent>(parent);

            Assert.Null(child.Parent);

            using (var foo = INPCCounter.VerifyInpcFired(child, o => o.Parent))
            {
                list.Add(child);
            }

            Assert.Equal(parent, child.Parent);

            using (var foo = INPCCounter.VerifyInpcFired(child, o => o.Parent))
            {
                list.RemoveAt(0);
            }

            Assert.Null(child.Parent);
        }
 public void ExternalNotifyImplemented()
 {
     using var counter = new INPCCounter(this, new [] { "foo" });
     ((IExternalNotifyPropertyChanged)this).OnPropertyChanged("foo");
 }
 public void INPCWorks()
 {
     using var counter = INPCCounter.VerifyInpcFired(this, i => i.X);
     X = 10;
     Assert.Equal(10, X);
 }
 public void BothVarsNotify()
 {
     using var _ = INPCCounter.VerifyInpcFired(this, i => i.X, i => i.Y);
     X           = 10;
     Y           = 11;
 }
Пример #12
0
 public void DoPropertyTest()
 {
     using var _ = INPCCounter.VerifyInpcFired(this, i => i.X, i => i.X1);
     X           = 22;
 }
Пример #13
0
 public void DoPropertyTest()
 {
     other       = new DoNotFireForPropertyOnOtherObject();     // fixes a warning
     using var _ = INPCCounter.VerifyInpcFired(this, i => i.X); // does not notify X1
     X           = 22;
 }
Пример #14
0
 public void ThisShouldCompileWithoutWarnings()
 {
     using var _ = INPCCounter.VerifyInpcFired(this, i => i.X);
     X           = 20;
 }