package Ġcom . ba eld ung . filesystem Ċ Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġjava . io . File Ċ import Ġkotlin . test . assertEquals Ċ Ċ internal Ġclass ĠFile Writer UnitTest Ġ{ ĊĊĠĠĠ Ġprivate Ġval ĠfileName Ġ= Ġ" src / test / resources / Kotlin . out " ĊĊĠĠĠ Ġprivate Ġval Ġfile Content Ġ= Ġ" Kotlin \ n Con c ise , ĠSafe , ĠInter oper able , ĠTool - friendly " ĊĊĠĠĠ Ġprivate Ġval Ġfile Writer Ġ= ĠFile Writer () ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Written With PrintWriter _ then Correct () Ġ{ ĊĠĠĠĠĠĠĠ Ġfile Writer . writeFile Using PrintWriter ( fileName , Ġfile Content ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( file Content , ĠFile ( fileName ). read Text ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Written With Buffered Writer _ then Correct () Ġ{ ĊĠĠĠĠĠĠĠ Ġfile Writer . writeFile Using Buffered Writer ( fileName , Ġfile Content ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( file Content , ĠFile ( fileName ). read Text ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Written Direct ly _ then Correct () Ġ{ ĊĠĠĠĠĠĠĠ Ġfile Writer . writeFile Direct ly ( fileName , Ġfile Content ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( file Content , ĠFile ( fileName ). read Text ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Written Direct ly As Bytes _ then Correct () Ġ{ ĊĠĠĠĠĠĠĠ Ġfile Writer . writeFile Direct ly As Bytes ( fileName , Ġfile Content ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( file Content , ĠFile ( fileName ). read Text ()) ĊĠĠĠ Ġ} Ċ Ċ }