- Option Strict On 
- Option Explicit On 
- Class Person 
-     Public Property Name As String 
- End Class 
- Class PhonebookEntry 
-     Public Property Phone As String 
-     Public Property Person As Person 
- End Class 
- Class Phonebook 
-     Private _Entries(1) As PhonebookEntry 
-     Private _Count As Integer 
-     Public ReadOnly Property Count() As Integer 
-         Get 
-             Count = _Count 
-         End Get 
-     End Property 
-     Public ReadOnly Property Capacity() As Integer 
-         Get 
-             Capacity = _Entries.Length 
-         End Get 
-     End Property 
-     ' Fill In 
- End Class 
- Module PhonebookTestFixture 
-     Sub Main() 
-         Dim phone1 As String = "012/34.56.78" 
-         Dim person1 As New Person 
-         person1.Name = "John" 
-         Dim phone2 As String = "123/45.67.89" 
-         Dim person2 As New Person 
-         person2.Name = "Jane" 
-         Dim phone3 As String = "234/56.78.90" 
-         Dim person3 As New Person 
-         person3.Name = "Paul" 
-         Dim phone4 As String = "345/67.89.01" 
-         Dim person4 As New Person 
-         person4.Name = "Mia" 
-         ' 
-         ' Test Scenario : Initial State :  
-         Dim target As New Phonebook 
-         Assert.IsTrue(target.Count = 0, "No entries to start with.") 
-         Assert.IsTrue(target.Capacity = 2, "Initial Capacity is 2.") 
-         Assert.IsTrue(target.IndexOf(phone1) = -1, "IndexOf -1 for unfound phone.") 
-         Assert.IsTrue(target.Contains(phone1) = False, "Does not contains unfound phone.") 
-         Assert.IsTrue(target.Item(0) Is Nothing, "Indexer delivers no Entry.") 
-         Assert.IsTrue(target.Item(phone1) Is Nothing, "Quantifier delivers no Person.") 
-         ' 
-         ' Test Scenario : Adding with Add Method : 
-         target.Add(phone1, person1) ' Adding a new entry for phone1 with person1. 
-         ' 0 : phone1 -> person1 
-         Assert.IsTrue(target.Count = 1, "Contains 1 element after first Add.") 
-         Assert.IsTrue(target.Capacity = 2, "Capacity is unchanged after first Add.") 
-         Assert.IsTrue(target.IndexOf(phone1) = 0, "IndexOf found phone after first Add.") ' Logical equality. 
-         Assert.IsTrue(target.IndexOf(phone2) = -1, "IndexOf -1 for unfound phone after first Add.") 
-         Assert.IsTrue(target.Contains(phone1) = True, "Contains found phone after first Add.") ' Logical equality. 
-         Assert.IsTrue(target.Contains(phone2) = False, "Does not contain phone after first Add.") 
-         Assert.IsTrue(target.Item(0).Person Is person1, "Indexer delivers Entry after first Add.") ' Physical equality. 
-         Assert.IsTrue(target.Item(0).Phone = phone1, "Indexer delivers Entry after first Add.") ' Logical equality. 
-         Assert.IsTrue(target.Item(1) Is Nothing, "Indexer delivers no Entry after first Add.") 
-         Assert.IsTrue(target.Item(phone1) Is person1, "Quantifier delivers Person after first Add.") ' Physical equality. 
-         Assert.IsTrue(target.Item(phone2) Is Nothing, "Quantifier delivers no Person after first Add.") 
-         target.Add(phone2, person2) ' Adding a new entry for phone2 with person2. 
-         ' 0 : phone1 -> person1 
-         ' 1 : phone2 -> person2 
-         target.Add(phone3, person1) ' Adding a new entry for phone3 with person1. 
-         ' 0 : phone1 -> person1 
-         ' 1 : phone2 -> person2 
-         ' 2 : phone3 -> person1 
-         Assert.IsTrue(target.Count = 3, "Each call to Add increases the Count with 1.") 
-         Assert.IsTrue(target.Capacity = 4, "Capacity doubles when insufficient.") 
-         Assert.IsTrue(target.IndexOf(phone1) = 0, "IndexOf found phone after Add.") 
-         Assert.IsTrue(target.IndexOf(phone2) = 1, "IndexOf found phone after Add.") 
-         Assert.IsTrue(target.IndexOf(phone3) = 2, "IndexOf found phone after Add.") 
-         Assert.IsTrue(target.Contains(phone1) = True, "Contains found phone after Add.") 
-         Assert.IsTrue(target.Contains(phone2) = True, "Contains found phone after Add.") 
-         Assert.IsTrue(target.Contains(phone3) = True, "Contains found phone after Add.") 
-         Assert.IsTrue(target.Item(0).Person Is person1, "Indexer delivers Entry after Add.") 
-         Assert.IsTrue(target.Item(0).Phone = phone1, "Indexer delivers Entry after Add.") 
-         Assert.IsTrue(target.Item(1).Person Is person2, "Indexer delivers Entry after Add.") 
-         Assert.IsTrue(target.Item(1).Phone = phone2, "Indexer delivers Entry after Add.") 
-         Assert.IsTrue(target.Item(2).Person Is person1, "Indexer delivers Entry after Add.") 
-         Assert.IsTrue(target.Item(2).Phone = phone3, "Indexer delivers Entry after Add.") 
-         Assert.IsTrue(target.Item(phone1) Is person1, "Quantifier delivers Person after Add.") 
-         Assert.IsTrue(target.Item(phone2) Is person2, "Quantifier delivers Person after Add.") 
-         Assert.IsTrue(target.Item(phone3) Is person1, "Quantifier delivers Person after Add.") 
-         ' 
-         ' Test Scenario : Replacing a Complete Entry thru Use of Indexer : 
-         target.Item(1) = New PhonebookEntry ' Replacing complete entry at Index 1. 
-         target.Item(1).Phone = phone4 
-         target.Item(1).Person = person4 
-         ' 0 : phone1 -> person1 
-         ' 1 : phone4 -> person4 
-         ' 2 : phone3 -> person1 
-         Assert.IsTrue(target.Count = 3, "Replacing an entry does not affect Count.") 
-         Assert.IsTrue(target.IndexOf(phone2) = -1, "Entry with phone2 removed after replacing thru indexer.") 
-         Assert.IsTrue(target.IndexOf(phone4) = 1, "Entry for phone4 at index 1 after replacing thru indexer.") 
-         Assert.IsTrue(target.Item(1).Person Is person4, "Indexer delivers Entry after replacing thru indexer.") 
-         Assert.IsTrue(target.Item(1).Phone = phone4, "Indexer delivers Entry after replacing thru indexer.") 
-         Assert.IsTrue(target.Item(phone2) Is Nothing, "Quantifier delivers no Person after replacing thru indexer.") 
-         Assert.IsTrue(target.Item(phone4) Is person4, "Quantifier delivers Person after replacing thru indexer.") 
-         ' 
-         ' Test Scenario : Replacing a Person on a Certain Phone thru Use of Quantifier : 
-         target.Item(phone3) = person2 ' Changing person1 to person2 for existing phone3. 
-         ' 0 : phone1 -> person1 
-         ' 1 : phone4 -> person4 
-         ' 2 : phone3 -> person2 
-         Assert.IsTrue(target.Count = 3, "Changing the person on a phone does not affect Count.") 
-         Assert.IsTrue(target.IndexOf(phone3) = 2, "IndexOf found phone after replacing thru quantifier.") 
-         Assert.IsTrue(target.Item(0).Person Is person1, "Indexer delivers Entry after replacing thru quantifier.") 
-         Assert.IsTrue(target.Item(0).Phone = phone1, "Indexer delivers Entry after replacing thru quantifier.") 
-         Assert.IsTrue(target.Item(2).Person Is person2, "Indexer delivers Entry after replacing thru quantifier.") 
-         Assert.IsTrue(target.Item(2).Phone = phone3, "Indexer delivers Entry after replacing thru quantifier.") 
-         Assert.IsTrue(target.Item(phone1) Is person1, "Quantifier delivers Person after replacing thru quantifier.") 
-         Assert.IsTrue(target.Item(phone3) Is person2, "Quantifier delivers Person after replacing thru quantifier.") 
-         ' 
-         ' Test Scenario : Adding an Entry thru Use of Quantifier : 
-         target.Item(phone2) = person1 ' Adding a new entry for phone2 with person1. 
-         ' 0 : phone1 -> person1 
-         ' 1 : phone4 -> person4 
-         ' 2 : phone3 -> person2 
-         ' 3 : phone2 -> person1 
-         Assert.IsTrue(target.Count = 4, "Adding thru quantifier increases Count with 1.") 
-         Assert.IsTrue(target.Capacity = 4, "Adding thru quantifier could double Capacity.") 
-         Assert.IsTrue(target.IndexOf(phone1) = 0, "IndexOf found phone after adding thru quantifier.") 
-         Assert.IsTrue(target.IndexOf(phone4) = 1, "IndexOf found phone after adding thru quantifier.") 
-         Assert.IsTrue(target.IndexOf(phone3) = 2, "IndexOf found phone after adding thru quantifier.") 
-         Assert.IsTrue(target.IndexOf(phone2) = 3, "IndexOf found phone after adding thru quantifier.") 
-         Assert.IsTrue(target.Item(3).Person Is person1, "Indexer delivers Entry after replacing thru quantifier.") 
-         Assert.IsTrue(target.Item(3).Phone = phone2, "Indexer delivers Entry after adding thru quantifier.") 
-         ' 
-         ' Test Scenario : Removing an Entry with Certain Phone : 
-         target.Remove(phone1) ' Removing complete entry with phone1. 
-         ' 0 : phone4 -> person4 
-         ' 1 : phone3 -> person2 
-         ' 2 : phone2 -> person1 
-         Assert.IsTrue(target.Count = 3, "Removing thru Remove decreases Count with 1.") 
-         Assert.IsTrue(target.Capacity = 4, "Capacity stays unchanged after Remove.") 
-         Assert.IsTrue(target.IndexOf(phone1) = -1, "IndexOf -1 for unfound phone after Remove.") 
-         Assert.IsTrue(target.IndexOf(phone4) = 0, "IndexOf found phone after Remove.") 
-         Assert.IsTrue(target.IndexOf(phone3) = 1, "IndexOf found phone after Remove.") 
-         Assert.IsTrue(target.IndexOf(phone2) = 2, "IndexOf found phone after Remove.") 
-         Assert.IsTrue(target.Contains(phone1) = False, "Does not contain phone after Remove.") 
-         ' 
-         ' Test Scenario : Removing an Entry at a Specific Index : 
-         target.RemoveAt(0) ' Remove entry at Index 0. 
-         target.RemoveAt(1) ' Remove entry at Index 1. 
-         ' 0 : phone3 -> person2 
-         Assert.IsTrue(target.Count = 1, "Removing thru RemoveAt decreases Count with 1.") 
-         Assert.IsTrue(target.Capacity = 4, "Capacity stays unchanged after RemoveAt.") 
-         Assert.IsTrue(target.IndexOf(phone1) = -1, "IndexOf -1 for unfound phone after RemoveAt.") 
-         Assert.IsTrue(target.IndexOf(phone4) = -1, "IndexOf -1 for unfound phone after RemoveAt.") 
-         Assert.IsTrue(target.IndexOf(phone2) = -1, "IndexOf -1 for unfound phone after RemoveAt.") 
-         Assert.IsTrue(target.IndexOf(phone3) = 0, "IndexOf found phone after RemoveAt.") 
-         ' 
-         ' Test Scenario : Removing all Entries : 
-         target.Add(phone1, person1) 
-         ' 0 : phone3 -> person2 
-         ' 1 : phone1 -> person1 
-         target.Clear() ' Removing all entries. 
-         ' ..empty.. 
-         Assert.IsTrue(target.Count = 0, "Zero items after Clear.") 
-         Assert.IsTrue(target.Capacity = 2, "Initial Capacity (2) reset after Clear.") 
-         Assert.IsTrue(target.IndexOf(phone1) = -1, "IndexOf -1 for unfound phone after Clear.") 
-         ' 
-         Console.WriteLine("Test Score : " & Assert.Score / 73 * 30 & " / 30") 
-         Console.WriteLine("Deze score kan nog verminderd worden door bijvoorbeeld : ") 
-         Console.WriteLine("- minder ideale implementatie (omslachtige algoritmes, teveel dataholder, ...)") 
-         Console.WriteLine("- minder ideale definitie (bijvoorbeeld vergeten van type specifiers)") 
-         Console.WriteLine("- ongewenste abstractie (bijvoorbeeld settable maken van readonly gegeven)") 
-         ' 
-         Console.ReadLine() 
-     End Sub 
- End Module 
- Module Assert 
-     Public Score As Integer 
-     Public Sub IsTrue(ByVal condition As Boolean, ByVal message As String) 
-         If condition Then 
-             Console.Write("Assertion Correct : ") 
-             Score += 1 
-         Else 
-             Console.Write("Assertion Failed  : ") 
-         End If 
-         Console.WriteLine(message) 
-     End Sub 
- End Module