diff --git a/Usability/Data Classes/Exercise 1/src/Task.kt b/Usability/Data Classes/Exercise 1/src/Task.kt index f5138e7d..e47ec1e2 100644 --- a/Usability/Data Classes/Exercise 1/src/Task.kt +++ b/Usability/Data Classes/Exercise 1/src/Task.kt @@ -9,9 +9,11 @@ data class AirlineTicket( ) fun main() { +/* val ticket = AirlineTicket("Bruce", "Eckel", 123456, "DEN", "HND") println(ticket) +*/ } /* Expected output: -AirlineTicket(first=Bruce, last=Eckel, ticket=123456, origin=DEN, destination=HND) +AirlineTicket(firstName=Bruce, lastName=Eckel, ticket=123456, origin=DEN, destination=HND) */ \ No newline at end of file diff --git a/Usability/Data Classes/Exercise 1/task-info.yaml b/Usability/Data Classes/Exercise 1/task-info.yaml index 7ad1b827..4f56ce5e 100644 --- a/Usability/Data Classes/Exercise 1/task-info.yaml +++ b/Usability/Data Classes/Exercise 1/task-info.yaml @@ -2,5 +2,9 @@ type: edu files: - name: src/Task.kt visible: true + placeholders: + - offset: 30 + length: 143 + placeholder_text: // Implement AirlineTicket class - name: test/Tests.kt visible: false diff --git a/Usability/Data Classes/Exercise 1/test/Tests.kt b/Usability/Data Classes/Exercise 1/test/Tests.kt index 8fa59590..f0639f55 100644 --- a/Usability/Data Classes/Exercise 1/test/Tests.kt +++ b/Usability/Data Classes/Exercise 1/test/Tests.kt @@ -1,10 +1,30 @@ package dataClassesExercise1 +import org.junit.Assert import org.junit.Test import util.TIMEOUT -import util.untestable +import util.checkParametersOfConstructor +import util.loadClass +import util.runAndCheckSystemOutput class TestDataClassesExercise1 { @Test(timeout = TIMEOUT) - fun test() = untestable() + fun test() { + val ticketClass = loadClass("dataClassesExercise1", "AirlineTicket") + + val constructor = ticketClass.constructors.first() + checkParametersOfConstructor(constructor, ticketClass, listOf( + "firstName" to "kotlin.String", + "lastName" to "kotlin.String", + "ticket" to "kotlin.Int", + "origin" to "kotlin.String", + "destination" to "kotlin.String" + )) + Assert.assertTrue("'AirlineTicket' class is expected to be defined as 'data' class", ticketClass.isData) + runAndCheckSystemOutput("Wrong output", + "AirlineTicket(firstName=Bruce, lastName=Eckel, ticket=123456, origin=DEN, destination=HND)") { + val ticket = constructor.call("Bruce", "Eckel", 123456, "DEN", "HND") + println(ticket) + } + } } \ No newline at end of file diff --git a/Usability/Data Classes/Exercise 2/src/Task.kt b/Usability/Data Classes/Exercise 2/src/Task.kt index ad5d7965..b28c0bbf 100644 --- a/Usability/Data Classes/Exercise 2/src/Task.kt +++ b/Usability/Data Classes/Exercise 2/src/Task.kt @@ -19,6 +19,6 @@ fun main() { val ticket = AirlineTicket("Bruce", "Eckel", 123456, "DEN", "HND") println(ticket.transferTicket("Svetlana", "Isakova")) } -/* Expected output: -AirlineTicket(first=Svetlana, last=Isakova, ticket=123456, origin=DEN, destination=HND) +/* Output: +AirlineTicket(firstName=Svetlana, lastName=Isakova, ticket=123456, origin=DEN, destination=HND) */ \ No newline at end of file diff --git a/Usability/Data Classes/Exercise 2/task-info.yaml b/Usability/Data Classes/Exercise 2/task-info.yaml index 7ad1b827..a100f10d 100644 --- a/Usability/Data Classes/Exercise 2/task-info.yaml +++ b/Usability/Data Classes/Exercise 2/task-info.yaml @@ -2,5 +2,9 @@ type: edu files: - name: src/Task.kt visible: true + placeholders: + - offset: 280 + length: 70 + placeholder_text: TODO() - name: test/Tests.kt visible: false diff --git a/Usability/Data Classes/Exercise 2/test/Tests.kt b/Usability/Data Classes/Exercise 2/test/Tests.kt index a6c6f225..e759728c 100644 --- a/Usability/Data Classes/Exercise 2/test/Tests.kt +++ b/Usability/Data Classes/Exercise 2/test/Tests.kt @@ -4,8 +4,11 @@ import org.junit.Assert import org.junit.Test class TestDataClassesExercise2 { - @Test fun testSolution() { - //TODO: implement your test here - Assert.assertTrue("Tests not implemented for the task", false) - } + @Test + fun testTransferTicket() { + val ticket = AirlineTicket("Bruce", "Eckel", 123456, "DEN", "HND") + Assert.assertEquals("Wrong result after copy", + AirlineTicket("Svetlana", "Isakova", 123456, "DEN", "HND"), + ticket.transferTicket("Svetlana", "Isakova")) + } } \ No newline at end of file