コード例 #1
0
        public void ModelTrackerCollection_ExistingCollection_UpdateModel_ModelUpdated()
        {
            var ex = Existing.First();

            ex.Data = "new data";
            Existing.Update(ex.Id, ex);
        }
コード例 #2
0
        public void ModelTrackerCollection_ExistingCollection_UpdateModel_EventInvoked()
        {
            var m       = Existing.Skip(1).First();
            var oldData = m.Data;
            var oldId   = m.Id;

            m      = new TestModel();
            m.Id   = oldId;
            m.Data = Guid.NewGuid().ToString();

            bool updated = false;

            Existing.ModelUpdatedEvent += (s, e) => {
                Assert.AreEqual(e.UpdatedModel.Data, m.Data);
                Assert.AreEqual(e.UpdatedModel.Id, m.Id);
                Assert.AreEqual(e.OldModel.Data, oldData);
                Assert.AreEqual(e.OldModel.Id, oldId);
                updated = true;
            };

            Existing.Update(m.Id, m);
            Assert.IsTrue(updated);
        }