package org.mones.chartjsgenj;

import static org.junit.Assert.assertNotNull;

import java.util.Arrays;
import java.util.List;

import junit.framework.Assert;

import org.junit.Test;
import org.mones.chartjsgenj.Colour;
import org.mones.chartjsgenj.Dataset;

public class DatasetTest {

	@Test
	public void testAddJSON() {
		Dataset ds = new Dataset();
		assertNotNull(ds);

		ds.setLabel("Label");
		StringBuilder sb = new StringBuilder();
		ds.addJSON(sb);
		Assert.assertEquals("·{··label·:·\"Label\"··}·",
				sb.toString().replaceAll("\\s", "·"));
//		System.out.println(sb.toString().replaceAll("\\s", "·"));

		ds = new Dataset();
		ds.setData(new int[] { });
		sb = new StringBuilder();
		ds.addJSON(sb);
		Assert.assertEquals("·{··data·:·[··]··}·",
				sb.toString().replaceAll("\\s", "·"));
//		System.out.println(sb.toString().replaceAll("\\s", "·"));

		ds.setData(new float[] { 1.0f });
		sb = new StringBuilder();
		ds.addJSON(sb);
		Assert.assertEquals("·{··data·:·[·1.0·]··}·",
				sb.toString().replaceAll("\\s", "·"));
//		System.out.println(sb.toString().replaceAll("\\s", "·"));

		ds.setData(new int[] { 2, 1, 3 });
		sb = new StringBuilder();
		ds.addJSON(sb);
		Assert.assertEquals("·{··data·:·[·2,·1,·3·]··}·",
				sb.toString().replaceAll("\\s", "·"));
//		System.out.println(sb.toString().replaceAll("\\s", "·"));

		ds.setFillColor(new Colour("#102030"));
		sb = new StringBuilder();
		ds.addJSON(sb);
		Assert.assertEquals("·{··fillColor·:·\"rgba(16,·32,·48,·1.0)\",·data·:·[·2,·1,·3·]··}·",
				sb.toString().replaceAll("\\s", "·"));
//		System.out.println(sb.toString().replaceAll("\\s", "·"));

		ds.setLabel("LABEL");
		sb = new StringBuilder();
		ds.addJSON(sb);
		Assert.assertEquals("·{··fillColor·:·\"rgba(16,·32,·48,·1.0)\",·label·:·\"LABEL\",·data·:·[·2,·1,·3·]··}·",
				sb.toString().replaceAll("\\s", "·"));
//		System.out.println(sb.toString().replaceAll("\\s", "·"));
	}
}

@@ -605,24 +605,269 @@
 s%22, %22%C2%B7%22));%0A%0A
+%09%09ds.setValue(new Integer(7));%0A%09%09sb = new StringBuilder();%0A%09%09ds.addJSON(sb);%0A%09%09Assert.assertEquals(%22%C2%B7%7B%C2%B7%C2%B7value%C2%B7:%C2%B77,%C2%B7label%C2%B7:%C2%B7%5C%22Label%5C%22%C2%B7%C2%B7%7D%C2%B7%22,%0A%09%09%09%09sb.toString().replaceAll(%22%5C%5Cs%22, %22%C2%B7%22));%0A//%09%09System.out.println(sb.toString().replaceAll(%22%5C%5Cs%22, %22%C2%B7%22));%0A%0A
 %09%09ds = new D

Test the value too