-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
94 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
app/src/main/java/com/github/braillesystems/learnbraille/data/entities/XmlAble.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.github.braillesystems.learnbraille.data.entities | ||
|
||
interface XmlAble { | ||
val xmlTag: String | ||
val xmlParams: Map<String, String> | ||
val xmlBody: HtmlText | ||
fun toXml(): HtmlText { | ||
var paramsString = "" | ||
for ((key, value) in xmlParams) { | ||
paramsString += " $key=\"$value\"" | ||
} | ||
return "<$xmlTag$paramsString>\n$xmlBody\n</$xmlTag>" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
app/src/test/java/com/github/braillesystems/learnbraille/data/entities/ToXmlTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.github.braillesystems.learnbraille.data.entities | ||
|
||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
|
||
import com.github.braillesystems.learnbraille.data.entities.BrailleDot.F | ||
import com.github.braillesystems.learnbraille.data.entities.BrailleDot.E | ||
|
||
class ToXmlTest { | ||
@Test | ||
fun stepsToXml() { | ||
val cases = mapOf<String, StepData>( | ||
"""<text type="info">dummy text</text>""" to Info("dummy text"), | ||
"""<text type="info">dummy last text</text>""" to LastInfo("dummy last text"), | ||
"""<reading type="reading" title="look at these dots!">(F, F, F, F, F, F)</reading>""" | ||
to ShowDots("look at these dots!", BrailleDots()), | ||
"""<practice type="practice" title="type in these dots!">(F, F, T, F, F, T)</practice>""" | ||
to InputDots("type in these dots!", BrailleDots(E, E, F, E, E, F)) | ||
) | ||
for ((expectedXml, stepData) in cases) { | ||
assertEquals(expectedXml, stepData.toXml().replace("\n", "")) | ||
} | ||
} | ||
} |