package com.alexrnl.subtitlecorrector.io.subrip;

import static org.junit.Assert.fail;

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

/**
 * Test suite for the {@link SubRipWriter} class.
 * @author Alex
 */
public class SubRipWriterTest {
	/** The writer to use for the test */
	private SubRipWriter	writer;

	/**
	 * Set up test attributes.
	 */
	@Before
	public void setUp () {
		writer = new SubRipWriter();
	}
	
	/**
	 * Test method for {@link com.alexrnl.subtitlecorrector.io.SubtitleWriter#writeFile(com.alexrnl.subtitlecorrector.common.SubtitleFile, java.nio.file.Path)}.
	 */
	@Test
	public void testWriteFile () {
		fail("Not yet implemented"); // TODO
	}
}

@@ -78,61 +78,281 @@
 ert.
-fail;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test
+assertArrayEquals;%0A%0Aimport java.io.IOException;%0Aimport java.net.URISyntaxException;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Path;%0Aimport java.nio.file.Paths;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport com.alexrnl.subtitlecorrector.common.SubtitleFile
 ;%0A%0A/
@@ -803,87 +803,1695 @@
 %0A%09 *
-/%0A%09@Test%0A%09public void testWriteFile () %7B%0A%09%09fail(%22Not yet implemented%22); // TODO
+ @throws URISyntaxException%0A%09 *         if the path to the file is badly formatted.%0A%09 * @throws IOException%0A%09 *         if and IO error occurs.%0A%09 */%0A%09@Test%0A%09public void testWriteFile () throws IOException, URISyntaxException %7B%0A%09%09final Path original = Paths.get(getClass().getResource(%22/Suits.S03E01.srt%22).toURI());%0A%09%09final Path output = Files.createTempFile(%22subtitle%22, %22.srt%22);%0A%09%09%0A%09%09final SubRipReader reader = new SubRipReader();%0A%09%09final SubtitleFile subtitle = reader.readFile(original);%0A%09%09%0A%09%09writer.writeFile(subtitle, output);%0A%09%09%0A%09%09assertArrayEquals(Files.readAllBytes(original), Files.readAllBytes(output));%0A%09%09%0A%09%09Files.delete(output);%0A%09%7D%0A%09%0A%09/**%0A%09 * Test method for %7B@link com.alexrnl.subtitlecorrector.io.SubtitleWriter#writeFile(com.alexrnl.subtitlecorrector.common.SubtitleFile, java.nio.file.Path)%7D.%0A%09 * @throws IOException%0A%09 *         if and IO error occurs.%0A%09 */%0A%09@Test(expected = IllegalArgumentException.class)%0A%09public void testWriteFileDirectory () throws IOException %7B%0A%09%09final Path temporaryDirectory = Files.createTempDirectory(%22tmpdir%22);%0A%09%09temporaryDirectory.toFile().deleteOnExit();%0A%09%09writer.writeFile(new SubtitleFile(null), temporaryDirectory);%0A%09%7D%0A%09%0A%0A%09%0A%09/**%0A%09 * Test method for %7B@link com.alexrnl.subtitlecorrector.io.SubtitleWriter#writeFile(com.alexrnl.subtitlecorrector.common.SubtitleFile, java.nio.file.Path)%7D.%0A%09 * @throws IOException%0A%09 *         if and IO error occurs.%0A%09 */%0A%09@Test(expected = IllegalArgumentException.class)%0A%09public void testWriteFileNotWritable () throws IOException %7B%0A%09%09final Path temporaryFile = Files.createTempFile(%22subtitle%22, %22.srt%22);%0A%09%09temporaryFile.toFile().setWritable(false);%0A%09%09writer.writeFile(new SubtitleFile(null), temporaryFile);
 %0A%09%7D%0A

Complete tests of SubRipWriter