示例#1
0
        public void VoiceActorAddedUndoAction_Undo_Normal_ActorDeleted()
        {
            m_testProject.VoiceActorList.Actors.Add(
                new Glyssen.VoiceActor.VoiceActor {
                Id = 3, Name = "Chuck", Age = ActorAge.YoungAdult
            });
            var action = new VoiceActorAddedUndoAction(m_testProject, 3);

            Assert.IsTrue(action.Undo());
            Assert.IsFalse(m_testProject.VoiceActorList.Actors.Any(a => a.Name == "Chuck" || a.Id == 3));
        }
示例#2
0
        public void VoiceActorAddedUndoAction_Undo_ActorSubsequentlyDeleted_ReturnsFalse()
        {
            m_testProject.VoiceActorList.Actors.Add(
                new Glyssen.VoiceActor.VoiceActor {
                Id = 3, Name = "Chuck", Age = ActorAge.YoungAdult
            });
            var action = new VoiceActorAddedUndoAction(m_testProject, 3);

            m_testProject.VoiceActorList.Actors.Clear();
            Assert.AreEqual(0, m_testProject.VoiceActorList.Actors.Count);

            Assert.IsFalse(action.Undo());
            Assert.AreEqual(0, m_testProject.VoiceActorList.Actors.Count);
        }
示例#3
0
        public void VoiceActorAddedUndoAction_Undo_ActorSubsequentlyModified_ActorDeleted()
        {
            var addedActor = new Glyssen.VoiceActor.VoiceActor {
                Id = 3, Name = "Chuck", Age = ActorAge.YoungAdult
            };

            m_testProject.VoiceActorList.Actors.Add(addedActor);
            var action = new VoiceActorAddedUndoAction(m_testProject, 3);

            addedActor.Name         = "Charlie";
            addedActor.VoiceQuality = VoiceQuality.Authoritative;

            Assert.IsTrue(action.Undo());
            Assert.AreEqual(0, m_testProject.VoiceActorList.Actors.Count);
        }
示例#4
0
        public void VoiceActorAddedUndoAction_Redo_Normal_ActorReinstated()
        {
            m_testProject.VoiceActorList.Actors.Add(
                new Glyssen.VoiceActor.VoiceActor {
                Id = 3, Name = "Chuck", Age = ActorAge.YoungAdult
            });
            var action = new VoiceActorAddedUndoAction(m_testProject, 3);

            action.Undo();

            Assert.IsTrue(action.Redo());
            var reAddedActor = m_testProject.VoiceActorList.GetVoiceActorById(3);

            Assert.AreEqual("Chuck", reAddedActor.Name);
            Assert.AreEqual(ActorAge.YoungAdult, reAddedActor.Age);
        }
示例#5
0
        public void VoiceActorAddedUndoAction_Redo_AddedActorWithSameNameAfterUndo_ReturnsFalse()
        {
            m_testProject.VoiceActorList.Actors.Add(
                new Glyssen.VoiceActor.VoiceActor {
                Id = 3, Name = "Chuck", Age = ActorAge.YoungAdult
            });
            var action = new VoiceActorAddedUndoAction(m_testProject, 3);

            m_testProject.VoiceActorList.Actors.Clear();
            Assert.AreEqual(0, m_testProject.VoiceActorList.Actors.Count);
            action.Undo();
            m_testProject.VoiceActorList.Actors.Add(
                new Glyssen.VoiceActor.VoiceActor {
                Id = 40, Name = "Chuck", Age = ActorAge.Elder
            });

            Assert.IsFalse(action.Redo());
            Assert.AreEqual(ActorAge.Elder, m_testProject.VoiceActorList.Actors.Single().Age);
        }
示例#6
0
        public void VoiceActorAddedUndoAction_Undo_ActorSubsequentlyAssignedToGroup_ReturnsFalse()
        {
            var group = new CharacterGroup(m_testProject, m_priorityComparer);

            group.CharacterIds = new CharacterIdHashSet(new[] { "Moses" });
            m_testProject.CharacterGroupList.CharacterGroups.Add(group);

            var addedActor = new Glyssen.VoiceActor.VoiceActor {
                Id = 3, Name = "Chuck", Age = ActorAge.YoungAdult
            };

            m_testProject.VoiceActorList.Actors.Add(addedActor);
            var action = new VoiceActorAddedUndoAction(m_testProject, 3);

            group.AssignVoiceActor(addedActor.Id);

            Assert.IsFalse(action.Undo());
            Assert.AreEqual(3, m_testProject.VoiceActorList.Actors.Single().Id);
        }
示例#7
0
        public void VoiceActorAddedUndoAction_Redo_AddedDifferentActorWithSameIdAfterUndo_ActorReinstatedWithUniqueId()
        {
            m_testProject.VoiceActorList.Actors.Add(
                new Glyssen.VoiceActor.VoiceActor {
                Id = 3, Name = "Chuck", Age = ActorAge.YoungAdult
            });
            var action = new VoiceActorAddedUndoAction(m_testProject, 3);

            m_testProject.VoiceActorList.Actors.Clear();
            Assert.AreEqual(0, m_testProject.VoiceActorList.Actors.Count);
            action.Undo();
            m_testProject.VoiceActorList.Actors.Add(
                new Glyssen.VoiceActor.VoiceActor {
                Id = 3, Name = "Maggie", Gender = ActorGender.Female
            });

            Assert.IsTrue(action.Redo());
            Assert.AreEqual(2, m_testProject.VoiceActorList.Actors.Count);
            var reAddedActor = m_testProject.VoiceActorList.Actors.Single(a => a.Id != 3);

            Assert.AreEqual("Chuck", reAddedActor.Name);
            Assert.AreEqual(ActorAge.YoungAdult, reAddedActor.Age);
        }