<commit_before>package fi.helsinki.cs.tmc.cli;

import static org.junit.Assert.assertEquals;

import fi.helsinki.cs.tmc.cli.io.Io;
import fi.helsinki.cs.tmc.cli.io.TerminalIo;
import fi.helsinki.cs.tmc.cli.io.TestIo;
import fi.helsinki.cs.tmc.cli.tmcstuff.WorkDir;
import static org.junit.Assert.assertNull;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

public class CliContextTest {

    @Before
    public void setUp() {
    }

    @Test
    public void getIoAfterItsSetInConstructor() {
        Io io = new TestIo();
        CliContext ctx = new CliContext(io);
        assertEquals(io, ctx.getIo());
    }

    @Test
    public void getIoWhenItsNotGiven() {
        CliContext ctx = new CliContext(null);
        assertEquals(TerminalIo.class, ctx.getIo().getClass());
    }

    @Test
    public void setAppAndGetIt() {
        CliContext ctx = new CliContext(null);
        Application app = new Application(ctx);
        ctx.setApp(app);
        assertEquals(app, ctx.getApp());
    }

    @Test(expected=RuntimeException.class)
    public void getAppWithoutSettingIt() {
        CliContext ctx = new CliContext(null);
        assertNull(ctx.getApp());
    }

    @Test
    public void setGetWorkDir() {
        WorkDir workDir = new WorkDir();
        CliContext ctx = new CliContext(null, null, workDir);
        assertEquals(workDir, ctx.getWorkDir());
    }


    @Ignore
    @Test
    public void backendInitWithoutCourse() {
    }

    @Ignore
    @Test
    public void backendInitWithCourse() {<commit_msg>Add some todo unit tests for cli context.<commit_after>package fi.helsinki.cs.tmc.cli;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

import fi.helsinki.cs.tmc.cli.io.Io;
import fi.helsinki.cs.tmc.cli.io.TerminalIo;
import fi.helsinki.cs.tmc.cli.io.TestIo;
import fi.helsinki.cs.tmc.cli.tmcstuff.WorkDir;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

public class CliContextTest {

    @Before
    public void setUp() {
    }

    @Test
    public void getIoAfterItsSetInConstructor() {
        Io io = new TestIo();
        CliContext ctx = new CliContext(io);
        assertEquals(io, ctx.getIo());
    }

    @Test
    public void getIoWhenItsNotGiven() {
        CliContext ctx = new CliContext(null);
        assertEquals(TerminalIo.class, ctx.getIo().getClass());
    }

    @Test
    public void setAppAndGetIt() {
        CliContext ctx = new CliContext(null);
        Application app = new Application(ctx);
        ctx.setApp(app);
        assertEquals(app, ctx.getApp());
    }

    @Test(expected = RuntimeException.class)
    public void getAppWithoutSettingIt() {
        CliContext ctx = new CliContext(null);
        assertNull(ctx.getApp());
    }

    @Test
    public void setGetWorkDir() {
        WorkDir workDir = new WorkDir();
        CliContext ctx = new CliContext(null, null, workDir);
        assertEquals(workDir, ctx.getWorkDir());
    }


    @Ignore
    @Test
    public void backendInitWithoutCourse() {
        CliContext ctx = new CliContext(null);
        assertTrue(ctx.loadBackend());
        assertEquals(null, ctx.getCourseInfo());
    }

    @Ignore
    @Test
    public void backendInitWithCourse() {
        CliContext ctx = new CliContext(null);
        assertTrue(ctx.loadBackend());
        assertNotSame(null, ctx.getCourseInfo());
    }

    @Ignore
    @Test
    public void backendInitWithInternet() {
        CliContext ctx = new CliContext(null);
        assertTrue(ctx.loadBackend());
        assertEquals(true, ctx.hasLogin());
    }

    @Ignore
    @Test
    public void backendInitWithoutInternet() {
        CliContext ctx = new CliContext(null);
        assertTrue(ctx.loadBackendWithoutLogin());
        assertEquals(false, ctx.hasLogin());
{'fraction_non_alphanumeric': 0.11227621483375959, 'fraction_numerical': 0.0, 'mean_word_length': 2.8838133068520357, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2765410', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1183, 'n_words': 258}