Example #1
0
        public void Remove_SoleChangedObjectIsRemoved_HasChangesIsFalse()
        {
            _InitializeDependencies();

            // stub change tracking object
            var changedObject = new Mock <IChangeTracking>();

            changedObject.Setup(o => o.IsChanged)
            .Returns(true);

            var target = new ChangeTrackingService();

            target.Add(changedObject.Object);
            target.Remove(changedObject.Object);

            Assert.IsFalse(target.HasChanges);
        }
Example #2
0
        public void Remove_SoleChangedObjectIsRemoved_RaisesHasChangesChangedEvent()
        {
            _InitializeDependencies();

            // stub change tracking object
            var changedObject = new Mock <IChangeTracking>();

            changedObject.Setup(o => o.IsChanged)
            .Returns(true);

            bool eventWasRaised = false;

            var target = new ChangeTrackingService();

            target.Add(changedObject.Object);

            target.HasChangesChanged += (o, e) => eventWasRaised = true;
            target.Remove(changedObject.Object);

            Assert.IsTrue(eventWasRaised);
        }