public void Undo_PreviousAssignment_AssignmentCleared() { var groupWithJesus = m_testProject.CharacterGroupList.GroupContainingCharacterId("Jesus"); groupWithJesus.AssignVoiceActor(3); var action = new VoiceActorAssignmentUndoAction(m_testProject, groupWithJesus, 2); Assert.IsTrue(action.Undo()); Assert.AreEqual(3, groupWithJesus.VoiceActorId); Assert.AreEqual(groupWithJesus, action.GroupsAffectedByLastOperation.Single()); }
public void Undo_GroupWithAssignmentNotFound_ReturnsFalse() { var groupWithJesus = m_testProject.CharacterGroupList.GroupContainingCharacterId("Jesus"); groupWithJesus.AssignVoiceActor(2); var action = new VoiceActorAssignmentUndoAction(m_testProject, groupWithJesus, 3); // This will assign it to 3. groupWithJesus.AssignVoiceActor(2); groupWithJesus.Name = "Friend of Sinners"; Assert.IsFalse(action.Undo()); Assert.AreEqual(0, action.GroupsAffectedByLastOperation.Count()); }
public void Redo_GroupWithAssignmentSubsequentlySetToDifferentActor_AssignmentRestored() { var groupWithJesus = m_testProject.CharacterGroupList.GroupContainingCharacterId("Jesus"); groupWithJesus.AssignVoiceActor(2); var action = new VoiceActorAssignmentUndoAction(m_testProject, groupWithJesus, 3); // This will assign it to 3. action.Undo(); // This will reassign it back to 2. groupWithJesus.AssignVoiceActor(4); Assert.IsTrue(action.Redo(), "This should still work because we can find the group by name"); Assert.AreEqual(3, groupWithJesus.VoiceActorId); Assert.AreEqual(groupWithJesus, action.GroupsAffectedByLastOperation.Single()); }
public void Redo_GroupWithAssignmentNotFound_ReturnsFalse() { var groupWithJesus = m_testProject.CharacterGroupList.GroupContainingCharacterId("Jesus"); groupWithJesus.AssignVoiceActor(2); var action = new VoiceActorAssignmentUndoAction(m_testProject, groupWithJesus, 3); // This will assign it to 3. action.Undo(); // This will reassign it back to 2. groupWithJesus.AssignVoiceActor(4); groupWithJesus.GroupIdLabel = CharacterGroup.Label.Other; groupWithJesus.GroupIdOtherText = "Son of God"; Assert.IsFalse(action.Redo()); Assert.AreEqual(4, groupWithJesus.VoiceActorId); Assert.AreEqual(0, action.GroupsAffectedByLastOperation.Count()); }
public void Undo_AssignActorAlreadyAssignedToAnotherGroup_AssignmentRestoredOnOriginalGroup() { var otherGroup = AddCharacterGroup("Jacob", "Barnabas"); try { var groupWithJesus = m_testProject.CharacterGroupList.GroupContainingCharacterId("Jesus"); groupWithJesus.AssignVoiceActor(3); otherGroup.AssignVoiceActor(2); var action = new VoiceActorAssignmentUndoAction(m_testProject, groupWithJesus, 2); // UI shouldn't allow this. Assert.IsTrue(action.Undo()); Assert.AreEqual(3, groupWithJesus.VoiceActorId); Assert.AreEqual(2, otherGroup.VoiceActorId); Assert.AreEqual(groupWithJesus, action.GroupsAffectedByLastOperation.Single()); } finally { m_testProject.CharacterGroupList.CharacterGroups.Remove(otherGroup); } }
public void Redo_TwoGroupsWithSamePreviousAssignment_AssignmentRestoredOnlyToOriginalGroup() { var otherGroup = AddCharacterGroup("Jacob", "Barnabas"); try { var groupWithJesus = m_testProject.CharacterGroupList.GroupContainingCharacterId("Jesus"); groupWithJesus.AssignVoiceActor(3); otherGroup.AssignVoiceActor(3); // No longer possible via UI, but it used to be. var action = new VoiceActorAssignmentUndoAction(m_testProject, groupWithJesus, 2); action.Undo(); Assert.IsTrue(action.Redo()); Assert.AreEqual(2, groupWithJesus.VoiceActorId); Assert.AreEqual(3, otherGroup.VoiceActorId); Assert.AreEqual(groupWithJesus, action.GroupsAffectedByLastOperation.Single()); } finally { m_testProject.CharacterGroupList.CharacterGroups.Remove(otherGroup); } }
public void Redo_TwoGroupsWithSamePreviousAssignmentOriginalGroupRenamed_ReturnsFalse() { var otherGroup = AddCharacterGroup("Jacob", "Barnabas"); try { var groupWithJesus = m_testProject.CharacterGroupList.GroupContainingCharacterId("Jesus"); groupWithJesus.AssignVoiceActor(3); otherGroup.AssignVoiceActor(3); // No longer possible via UI, but it used to be. var action = new VoiceActorAssignmentUndoAction(m_testProject, groupWithJesus, 2); action.Undo(); groupWithJesus.Name = "Divine Son of God"; Assert.IsFalse(action.Redo()); Assert.AreEqual(3, groupWithJesus.VoiceActorId); Assert.AreEqual(3, otherGroup.VoiceActorId); Assert.AreEqual(0, action.GroupsAffectedByLastOperation.Count()); } finally { m_testProject.CharacterGroupList.CharacterGroups.Remove(otherGroup); } }