PageRenderTime 36ms CodeModel.GetById 16ms app.highlight 14ms RepoModel.GetById 1ms app.codeStats 0ms

/Source Code/UnitTests/SongItemTest.vb

#
Visual Basic | 95 lines | 54 code | 22 blank | 19 comment | 0 complexity | 471d663b852eded173cf0058fc1b4ace MD5 | raw file
 1Imports System
 2Imports System.Collections.Generic
 3Imports Microsoft.VisualStudio.TestTools.UnitTesting
 4Imports PowerSong.SongDatabase.Items
 5
 6'''<summary>
 7'''This is a test class for SongItemTest and is intended
 8'''to contain all SongItemTest Unit Tests
 9'''</summary>
10<TestClass()> _
11Public Class SongItemTest
12
13    '''<summary>
14    '''A test for SongID
15    '''</summary>
16    <TestMethod()> _
17    Public Sub SongIDTest()
18
19        Dim target As SongItem = New SongItem
20        Dim ID As Guid = Guid.NewGuid
21        target.SongID = ID
22        Assert.AreEqual(ID, target.SongID)
23
24    End Sub
25
26    ''' <summary>
27    ''' Checks that an exception is thrown whenever trying to access an ID of a song without an ID.
28    ''' </summary>
29    <TestMethod(), ExpectedException(GetType(ApplicationException))> _
30    Public Sub SongIDInvalidTest()
31
32        Dim target As SongItem = New SongItem
33        Dim ID As Guid = target.SongID
34
35    End Sub
36
37    '''<summary>
38    '''A test for Authors
39    '''</summary>
40    <TestMethod()> _
41    Public Sub AuthorsTest()
42
43        Dim target As New SongItem("Test Title", "Test Part 1", "Test part 2", "Test part 3")
44
45        target.Authors.Add("A")
46        target.Authors.Add("B")
47        target.Authors.Add("C")
48
49        Dim actual As List(Of String) = target.Authors
50        Assert.AreEqual(3, actual.Count)
51        Assert.AreEqual("A", actual(0))
52        Assert.AreEqual("B", actual(1))
53        Assert.AreEqual("C", actual(2))
54
55    End Sub
56
57    '''<summary>
58    '''A test for SongItem Constructor
59    '''</summary>
60    <TestMethod()> _
61    Public Sub SongItemConstructorTest1()
62
63        Dim Song As SongItem = New SongItem
64
65        Assert.AreEqual("", Song.Title)
66        Assert.AreEqual(0, Song.Parts.Count)
67        Assert.AreEqual(0, Song.Authors.Count)
68        Assert.AreEqual(0, Song.Categories.Count)
69        Assert.IsTrue(Song.CopyrightLine = "")
70
71    End Sub
72
73    '''<summary>
74    '''A test for SongItem Constructor
75    '''</summary>
76    <TestMethod()> _
77    Public Sub SongItemConstructorTest()
78
79        Dim title As String = "Test Title"
80        Dim parts() As String = {"Part 1", "Part 2", "Part 3"}
81        Dim Song As SongItem = New SongItem(title, parts)
82
83        Assert.AreEqual("Test Title", Song.Title)
84        Assert.AreEqual(3, Song.Parts.Count)
85        Assert.AreEqual("Part 1", Song.Parts(0))
86        Assert.AreEqual("Part 2", Song.Parts(1))
87        Assert.AreEqual("Part 3", Song.Parts(2))
88
89        Assert.AreEqual(0, Song.Authors.Count)
90        Assert.AreEqual(0, Song.Categories.Count)
91        Assert.IsTrue(Song.CopyrightLine = "")
92
93    End Sub
94
95End Class