forked from dawson-brown/CPS406
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestPlaylist.java
121 lines (120 loc) · 4.03 KB
/
TestPlaylist.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import static org.junit.Assert.*;
import org.junit.Test;
public class TestPlaylist {
/*
* Testers for testing each methods of our playlist object
*/
@Test
public void testToString() {
Playlist list = new Playlist();
Song song = new Song("Test", "TestArtist", 2019, 560);
list.add(song);
StringBuilder playlistAsString = new StringBuilder("Playlist:\n");
playlistAsString.append(song.toString());
playlistAsString.append("\n");
assertEquals(playlistAsString.toString(),list.toString());
}
@Test
public void testLinkedList() {
Playlist playlist = new Playlist();
assertEquals(true,playlist.playlist.isEmpty());
}
@Test
public void testAdd() {
Playlist list = new Playlist();
Song song = new Song("Test", "TestArtist", 2019, 560);
list.add(song);
assertEquals(song, list.getRecentSong());
}
@Test
public void testDelete() {
Playlist list = new Playlist();
Song song = new Song("Test", "TestArtist", 2019, 560);
Song song2 = new Song("Test2", "TestArtist2", 2020, 570);
list.add(song);
list.add(song2);
list.delete(song2);
assertEquals(song.toString(), list.getRecentSong().toString());
}
@Test
public void testGetPlaylistLength() {
Playlist list = new Playlist();
Song song = new Song("Test", "TestArtist", 2019, 560);
Song song2 = new Song("ATest2", "TestArtist2", 2020, 570);
list.add(song);
list.add(song2);
assertEquals(false, list.getPlaylistLength());
}
@Test
public void testSortByName() {
Playlist list = new Playlist();
Playlist sortedList = new Playlist();
Song song = new Song("Test", "TestArtist", 2019, 560);
Song song2 = new Song("ATest2", "TestArtist2", 2020, 570);
list.add(song);
list.add(song2);
sortedList.add(song2);
sortedList.add(song);
list.sortByName();
assertEquals(sortedList.toString(),list.toString());
}
@Test
public void testSortByArtist() {
Playlist list = new Playlist();
Playlist sortedList = new Playlist();
Song song = new Song("Test", "TestArtist", 2019, 560);
Song song2 = new Song("ATest2", "ATestArtist2", 2020, 570);
list.add(song);
list.add(song2);
sortedList.add(song2);
sortedList.add(song);
list.sortByArtist();
assertEquals(sortedList.toString(),list.toString());
}
@Test
public void testSortByYearOldtoNew() {
Playlist list = new Playlist();
Playlist sortedList = new Playlist();
Song song = new Song("Test", "TestArtist", 2019, 560);
Song song2 = new Song("ATest2", "ATestArtist2", 2018, 570);
list.add(song);
list.add(song2);
sortedList.add(song2);
sortedList.add(song);
list.sortByYearOldtoNew();
assertEquals(sortedList.toString(),list.toString());
}
@Test
public void testSortByYearNewtoOld() {
Playlist list = new Playlist();
Playlist sortedList = new Playlist();
Song song = new Song("Test", "TestArtist", 2019, 560);
Song song2 = new Song("ATest2", "ATestArtist2", 2018, 570);
list.add(song);
list.add(song2);
sortedList.add(song);
sortedList.add(song2);
list.sortByYearNewtoOld();
assertEquals(sortedList.toString(),list.toString());
}
@Test
public void testSortByLength() {
Playlist list = new Playlist();
Playlist sortedList = new Playlist();
Song song = new Song("Test", "TestArtist", 2019, 560);
Song song2 = new Song("ATest2", "ATestArtist2", 2018, 570);
list.add(song2);
list.add(song);
sortedList.add(song);
sortedList.add(song2);
list.sortByLength();
assertEquals(sortedList.toString(),list.toString());
}
@Test
public void testPlaylistIsValidByLength() {
Playlist list = new Playlist();
Song LongSong = new Song("A","B",2019, 4000);
list.add(LongSong);
assertEquals(true, list.getPlaylistLength());
}
}