Exemple #1
0
        public void ObjWitChildsTracking()
        {
            //Arrange
            MyComplextRepositoryItem item = new MyComplextRepositoryItem();

            item.Name   = "abc";
            item.childs = new ObservableList <MyComplextRepositoryItemChild>();
            MyComplextRepositoryItemChild child1 = new MyComplextRepositoryItemChild()
            {
                Name = "Child 1"
            };

            item.childs.Add(child1);
            item.StartDirtyTracking();

            item.OnDirtyStatusChanged += aaa;

            //Act
            child1.Name = "def";

            //Assert
            Assert.AreEqual(eDirtyStatus.Modified, item.DirtyStatus, "item dirty status changedt to modified");
            Assert.AreEqual(eDirtyStatus.Modified, child1.DirtyStatus, "child item dirty status changed to modified");
            Assert.IsTrue(DirtyStatusChangedTriggered, "DirtyStatusChangedTriggered=true");
        }
Exemple #2
0
        public void RemoveChildFromList()
        {
            //Arrange
            MyComplextRepositoryItem item = new MyComplextRepositoryItem();

            item.Name   = "abc";
            item.childs = new ObservableList <MyComplextRepositoryItemChild>();
            item.childs.Add(new MyComplextRepositoryItemChild()
            {
                Name = "Child 1"
            });
            item.childs.Add(new MyComplextRepositoryItemChild()
            {
                Name = "Child 2"
            });
            item.childs.Add(new MyComplextRepositoryItemChild()
            {
                Name = "Child 3"
            });

            item.StartDirtyTracking();

            //Act
            item.childs.RemoveAt(1);

            //Assert
            Assert.AreEqual(eDirtyStatus.Modified, item.DirtyStatus, "item dirty status changed to modified since one child was removed");
        }
Exemple #3
0
        public void ObjWithoutTracking()
        {
            //Arrange
            MyComplextRepositoryItem item = new MyComplextRepositoryItem();

            item.Name = "aaa";

            //Act


            //Assert
            Assert.AreEqual(eDirtyStatus.NoTracked, item.DirtyStatus, "item is not tracked");
        }
Exemple #4
0
        public void PropertyNotSerializedNochangetoDirty()
        {
            //Arrange
            MyComplextRepositoryItem item = new MyComplextRepositoryItem();

            item.Name = "aaa";
            item.StartDirtyTracking();

            //Act
            item.DontSaveMe = "create at run time do not save do not track";

            //Assert
            Assert.AreEqual(eDirtyStatus.NoChange, item.DirtyStatus, "item is dirty");
        }
Exemple #5
0
        public void CheckObjDirty()
        {
            //Arrange
            MyComplextRepositoryItem item = new MyComplextRepositoryItem();

            item.Name = "aaa";
            item.StartDirtyTracking();

            //Act
            item.Name = "bbb";

            //Assert
            Assert.AreEqual(eDirtyStatus.Modified, item.DirtyStatus, "item is dirty");
        }
        public void CopyItemIsDirty()
        {
            //Arrange
            MyComplextRepositoryItem item = new MyComplextRepositoryItem();

            item.Name = "abc";
            item.StartDirtyTracking();

            //Act
            MyComplextRepositoryItem item2 = (MyComplextRepositoryItem)item.CreateCopy();

            //Assert
            Assert.AreEqual(eDirtyStatus.Modified, item2.DirtyStatus, "item dirty status changed to modified since it is a copy");
        }
        public void EditNewAddedChildToList()
        {
            //Arrange
            MyComplextRepositoryItem item = new MyComplextRepositoryItem();

            item.Name   = "abc";
            item.childs = new ObservableList <MyComplextRepositoryItemChild>();
            item.StartDirtyTracking();

            //Act
            MyComplextRepositoryItemChild newChild = new MyComplextRepositoryItemChild()
            {
                Name = "Child 1"
            };

            item.childs.Add(newChild);       //here parent will be marked as dirty
            item.SetDirtyStatusToNoChange(); //like been done on Save item to clear dirty
            newChild.Name = "NewName";       //expecting parent to show as dirty again because one of it's childs modified

            //Assert
            Assert.AreEqual(eDirtyStatus.Modified, item.DirtyStatus, "item dirty status changed to modified since one child was added and then child was modified");
        }
Exemple #8
0
        public void UpdateChildPropertyWhichisNotSerialzied()
        {
            //Arrange
            MyComplextRepositoryItem item = new MyComplextRepositoryItem();

            item.Name   = "Runtime";
            item.childs = new ObservableList <MyComplextRepositoryItemChild>();
            MyComplextRepositoryItemChild child1 = new MyComplextRepositoryItemChild()
            {
                Name = "Child 1"
            };

            item.childs.Add(child1);
            item.StartDirtyTracking();


            //Act
            child1.Status = "Pass";

            //Assert
            Assert.AreEqual(eDirtyStatus.NoChange, item.DirtyStatus, "item dirty status is not modified");
            Assert.AreEqual(eDirtyStatus.NoChange, child1.DirtyStatus, "child item dirty status is not modified");
        }