public void VoiceActorDeletedUndoAction_Redo_ActorAssignedToGroupButAssignedToDifferentGroupFollowingUndo_ReturnsFalse() { var assignedGroup = AddCharacterGroup("Barnabas", "Caleb", "Hosea"); var differentGroup = AddCharacterGroup("Thomas", "Jonah"); var removedActor = new Glyssen.VoiceActor.VoiceActor { Id = 4, Name = "Dominic", Age = ActorAge.YoungAdult }; var action = new VoiceActorDeletedUndoAction(m_testProject, removedActor, assignedGroup); action.Undo(); Assert.AreEqual(1, m_testProject.CharacterGroupList.CountVoiceActorsAssigned()); Assert.AreEqual(4, assignedGroup.VoiceActorId); assignedGroup.RemoveVoiceActor(); differentGroup.AssignVoiceActor(m_testProject.VoiceActorList.GetVoiceActorById(4).Id); Assert.IsFalse(action.Redo()); var restoredActor = m_testProject.VoiceActorList.GetVoiceActorById(4); // Equals is just defined as having the same ID, so we need to check name and details separately. Assert.AreEqual(restoredActor.Name, removedActor.Name); Assert.IsTrue(restoredActor.IsInterchangeableWith(removedActor)); Assert.AreEqual(4, differentGroup.VoiceActorId); }
public void VoiceActorDeletedUndoAction_Description_Normal_DeletedActorReferencedByName() { var action = new VoiceActorDeletedUndoAction(m_testProject, new Glyssen.VoiceActor.VoiceActor { Id = 4, Name = "Dominic", Age = ActorAge.YoungAdult }); Assert.AreEqual("Delete voice actor Dominic", action.Description); }
public void VoiceActorDeletedUndoAction_Constructor_Normal_NotARename() { var action = new VoiceActorDeletedUndoAction(m_testProject, new Glyssen.VoiceActor.VoiceActor { Id = 4, Name = "Dominic", Age = ActorAge.YoungAdult }); Assert.IsFalse(action.JustChangedName); Assert.IsNull(action.ActorAffected); Assert.AreEqual("Dominic", action.DeletedActorName); }
public void VoiceActorDeletedUndoAction_Redo_Normal_ActorReDeleted() { var removedActor = new Glyssen.VoiceActor.VoiceActor { Id = 4, Name = "Dominic", Age = ActorAge.YoungAdult }; var action = new VoiceActorDeletedUndoAction(m_testProject, removedActor); action.Undo(); Assert.IsTrue(action.Redo()); Assert.IsNull(m_testProject.VoiceActorList.GetVoiceActorById(4)); Assert.IsNull(m_testProject.VoiceActorList.Actors.SingleOrDefault(a => a.Name == "Dominic")); }
public void VoiceActorDeletedUndoAction_Undo_AnotherActorAddedWithSameName_ReturnsFalse() { var removedActor = new Glyssen.VoiceActor.VoiceActor { Id = 4, Name = "Dominic", Age = ActorAge.YoungAdult }; var action = new VoiceActorDeletedUndoAction(m_testProject, removedActor); m_testProject.VoiceActorList.Actors.Add(new Glyssen.VoiceActor.VoiceActor { Id = 2, Name = "Dominic", Age = ActorAge.Child }); Assert.IsFalse(action.Undo()); }
public void VoiceActorDeletedUndoAction_Redo_ActorAssignedToGroup_ActorReDeletedAndAssignmentRemoved() { var assignedGroup = AddCharacterGroup("Barnabas", "Caleb", "Hosea"); var removedActor = new Glyssen.VoiceActor.VoiceActor { Id = 4, Name = "Dominic", Age = ActorAge.YoungAdult }; var action = new VoiceActorDeletedUndoAction(m_testProject, removedActor, assignedGroup); action.Undo(); Assert.IsTrue(action.Redo()); Assert.IsNull(m_testProject.VoiceActorList.GetVoiceActorById(4)); Assert.IsNull(m_testProject.VoiceActorList.Actors.SingleOrDefault(a => a.Name == "Dominic")); Assert.AreEqual(0, m_testProject.CharacterGroupList.CountVoiceActorsAssigned()); }
public void VoiceActorDeletedUndoAction_Undo_Normal_ActorRestored() { var removedActor = new Glyssen.VoiceActor.VoiceActor { Id = 4, Name = "Dominic", Age = ActorAge.YoungAdult }; var action = new VoiceActorDeletedUndoAction(m_testProject, removedActor); Assert.IsTrue(action.Undo()); var restoredActor = m_testProject.VoiceActorList.GetVoiceActorById(4); Assert.IsNotNull(restoredActor); // Equals is just defined as having the same ID, so we need to check name and details separately. Assert.AreEqual(restoredActor.Name, removedActor.Name); Assert.IsTrue(restoredActor.IsInterchangeableWith(removedActor)); }
public void VoiceActorDeletedUndoAction_Undo_ActorAssignedToGroup_ActorAndAssignmentRestored() { var assignedGroup = AddCharacterGroup("Barnabas", "Caleb", "Hosea"); var removedActor = new Glyssen.VoiceActor.VoiceActor { Id = 4, Name = "Dominic", Age = ActorAge.YoungAdult }; var action = new VoiceActorDeletedUndoAction(m_testProject, removedActor, assignedGroup); Assert.IsTrue(action.Undo()); var restoredActor = m_testProject.VoiceActorList.GetVoiceActorById(4); Assert.IsNotNull(restoredActor); // Equals is just defined as having the same ID, so we need to check name and details separately. Assert.AreEqual(restoredActor.Name, removedActor.Name); Assert.IsTrue(restoredActor.IsInterchangeableWith(removedActor)); Assert.AreEqual(4, assignedGroup.VoiceActorId); }
public void VoiceActorDeletedUndoAction_Redo_ActorSubsequentlyDeleted_ReturnsTrueButNoChange() { var removedActor = new Glyssen.VoiceActor.VoiceActor { Id = 4, Name = "Dominic", Age = ActorAge.YoungAdult }; var action = new VoiceActorDeletedUndoAction(m_testProject, removedActor); action.Undo(); var restoredActor = m_testProject.VoiceActorList.Actors.Single(a => a.Name == "Dominic"); Assert.IsNotNull(restoredActor); m_testProject.VoiceActorList.Actors.Remove(restoredActor); Assert.IsTrue(action.Redo()); Assert.IsNull(m_testProject.VoiceActorList.GetVoiceActorById(4)); Assert.IsNull(m_testProject.VoiceActorList.Actors.SingleOrDefault(a => a.Name == "Dominic")); }
public void VoiceActorDeletedUndoAction_Undo_ActorAssignedToGroupWhichIsSubsequentlyDeleted_ReturnsFalse() { var assignedGroup = AddCharacterGroup("Barnabas", "Caleb", "Hosea"); var removedActor = new Glyssen.VoiceActor.VoiceActor { Id = 4, Name = "Dominic", Age = ActorAge.YoungAdult }; var action = new VoiceActorDeletedUndoAction(m_testProject, removedActor, assignedGroup); m_testProject.CharacterGroupList.CharacterGroups.Remove(assignedGroup); Assert.AreEqual(0, m_testProject.CharacterGroupList.CharacterGroups.Count); AddCharacterGroup("Caleb", "Hosea"); AddCharacterGroup("Barnabas", "Joshua"); AddCharacterGroup("Martha"); Assert.AreEqual(3, m_testProject.CharacterGroupList.CharacterGroups.Count); Assert.IsFalse(action.Undo()); Assert.IsNull(m_testProject.VoiceActorList.GetVoiceActorById(4)); Assert.IsNull(m_testProject.VoiceActorList.Actors.SingleOrDefault(a => a.Name == "Dominic")); Assert.AreEqual(0, m_testProject.CharacterGroupList.CountVoiceActorsAssigned()); }
public void VoiceActorDeletedUndoAction_Undo_AnotherActorAddedWithSameId_ActorRestoredWithUniqueId() { var removedActor = new Glyssen.VoiceActor.VoiceActor { Id = 4, Name = "Dominic", Age = ActorAge.YoungAdult }; var action = new VoiceActorDeletedUndoAction(m_testProject, removedActor); var reAddedActor = new Glyssen.VoiceActor.VoiceActor { Id = 4, Name = "Marshall", Age = ActorAge.Elder }; m_testProject.VoiceActorList.Actors.Add(reAddedActor); Assert.IsTrue(action.Undo()); var restoredActor = m_testProject.VoiceActorList.Actors.Single(a => a.Name == "Dominic"); Assert.IsNotNull(restoredActor); // Equals is just defined as having the same ID, so we need to check name and details separately. Assert.AreEqual(restoredActor.Name, removedActor.Name); Assert.IsTrue(restoredActor.IsInterchangeableWith(removedActor)); Assert.AreEqual(m_testProject.VoiceActorList.Actors.Count, m_testProject.VoiceActorList.Actors.Select(a => a.Id).Distinct().Count()); }