// Verify that if tag data == track name & number in db then track is not updated
{
Track trackBefore = cm.getTrack(1);
Tag newTag = createNiceMock( Tag.class );
expect(newTag.getTrack()).andReturn(trackBefore.getName());
expect(newTag.getTrackNumber()).andReturn(trackBefore.getNumber());
replay(newTag);
cm.checkTrackTagInfo(newTag, trackBefore);
Track trackAfter = cm.getTrack(1);
assertEquals(trackBefore.getId(), trackAfter.getId());
assertEquals(trackBefore.getName(), trackAfter.getName());
assertEquals(trackBefore.getNumber(), trackAfter.getNumber());
}
// Verify that if tag track name changes then track is updated in db
{
Track trackBefore = cm.getTrack(2);
Tag newTag = createNiceMock( Tag.class );
expect(newTag.getTrack()).andReturn( trackBefore.getName() + " changed!" ).anyTimes();
expect(newTag.getTrackNumber()).andReturn( trackBefore.getNumber() ).anyTimes();
replay(newTag);
cm.checkTrackTagInfo(newTag, trackBefore);
Track trackAfter = cm.getTrack(2);
assertEquals(trackBefore.getId(), trackAfter.getId());
assertFalse(trackBefore.getName().equals(trackAfter.getName()));
assertEquals(trackBefore.getNumber(), trackAfter.getNumber());
}
// Verify that if tag track number changes then track is updated in db
{
Track trackBefore = cm.getTrack(3);
Tag newTag = createNiceMock( Tag.class );
expect(newTag.getTrack()).andReturn( trackBefore.getName() ).anyTimes();
expect(newTag.getTrackNumber()).andReturn( trackBefore.getNumber() + 1 ).anyTimes();
replay(newTag);
cm.checkTrackTagInfo(newTag, trackBefore);
Track trackAfter = cm.getTrack(3);