Skip to content
Snippets Groups Projects
Commit b7088850 authored by Abhay Menon's avatar Abhay Menon
Browse files

Merge branch 'File-management-for-console-app' into 'main'

JUNIT5 has been added in dependencies in all gradle files. Implemented two...

See merge request !8
parents 83aa282d 2e8ca16b
No related branches found
No related tags found
1 merge request!8JUNIT5 has been added in dependencies in all gradle files. Implemented two...
Pipeline #83691 passed
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/modules/utilities/notes-multi.utilities.test.iml" filepath="$PROJECT_DIR$/.idea/modules/utilities/notes-multi.utilities.test.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$/../../../utilities/src/test">
<sourceFolder url="file://$MODULE_DIR$/../../../utilities/src/test/kotlin" isTestSource="true" />
</content>
</component>
</module>
\ No newline at end of file
......@@ -9,9 +9,14 @@ plugins {
dependencies {
implementation 'org.apache.commons:commons-text'
implementation project(':utilities')
testImplementation 'org.jetbrains.kotlin:kotlin-test'
}
application {
// Define the main class for the application.
mainClass = 'notes.multi.app.AppKt'
}
test {
useJUnitPlatform()
}
......@@ -9,9 +9,14 @@ plugins {
dependencies {
implementation 'org.apache.commons:commons-text'
implementation project(':utilities')
testImplementation 'org.jetbrains.kotlin:kotlin-test'
}
application {
// Define the main class for the application.
mainClass = 'notes.multi.console.ConsoleKt'
}
test {
useJUnitPlatform()
}
......@@ -9,6 +9,6 @@ fun main() {
// thesea re test functions feel free to use
val f = Filemanager("${System.getProperty("user.dir")}/test/", "hello.txt")
f.writefile("hello world")
println(f.openfile())
f.deletefile()
println(f.openfile())
}
......@@ -8,4 +8,9 @@ plugins {
dependencies {
api project(':list')
testImplementation 'org.jetbrains.kotlin:kotlin-test'
}
test {
useJUnitPlatform()
}
......@@ -24,7 +24,9 @@ class Filemanager(private val dir: String, private val name: String) {
// create and write to that file
fun writefile(line:String) {
filepath.writeText(line)
listfiles.add(filepath)
if (!listfiles.contains(filepath)) {
listfiles.add(filepath)
}
}
// opens and read the existing file
......@@ -39,6 +41,9 @@ class Filemanager(private val dir: String, private val name: String) {
fun deletefile():Boolean {
listfiles.remove(filepath)
for (i in listfiles) {
println("Not Deleted!")
}
return filepath.delete()
}
......
import notes.multi.utilities.Filemanager
import kotlin.test.Test
import kotlin.test.assertEquals
internal class FilemanagerTest {
private val testmanager: Filemanager = Filemanager("${System.getProperty("user.dir")}/testfolder/", "hello.txt")
@Test
fun createreadfile() {
val expected = "hello from the moon"
testmanager.writefile(expected)
assertEquals(expected, testmanager.openfile())
}
@Test
fun ReadNoneExistingFile() {
val expected = ""
testmanager.writefile("walking to the mooon")
testmanager.deletefile()
assertEquals(expected, testmanager.openfile())
}
}
\ No newline at end of file
blahblah
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment