package com.atlassian.bitbucket.mesh.sidecar;

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

import java.io.PrintWriter;
import java.io.StringWriter;

import static org.junit.Assert.assertEquals;

public class WriterSidecarChannelTest {

    private WriterSidecarChannel channel;
    private StringWriter writer;

    @Before
    public void setup() {
        writer = new StringWriter();

        channel = new WriterSidecarChannel(new PrintWriter(writer));
    }

    @Test
    public void testSendKeyValue() {
        channel.send("Key", "Value");

        assertEquals("Key: Value\n", writer.toString());
    }

    @Test
    public void testSendMessage() {
        channel.send("Test");

        assertEquals("Test\n", writer.toString());
    }
}