#include <UnitTest++.h>

#include "../src/ToJsonWriter.h"

SUITE(ArticleToJsonWriterTests)
{
    TEST(WriteArticleWithoutLinks)
    {
        ToJsonWriter atj;
        Article a("Farm");
        CHECK_EQUAL("{\"Farm\":{\"forward_links\":[]}}", atj.convertToJson(&a));
    }

    TEST(WriteArticleWithOneLink)
    {
        ToJsonWriter atj;
        Article a("Farm");
        a.addLink(new Article("Animal"));
        CHECK_EQUAL("{\"Farm\":{\"forward_links\":[\"Animal\"]}}", atj.convertToJson(&a));
    }

    TEST(WriteArticleWithMultipleLinks)
    {
        ToJsonWriter atj;
        Article a("Farm");
        a.addLink(new Article("Animal"));
        a.addLink(new Article("Pig"));
        a.addLink(new Article("Equality"));
        CHECK_EQUAL("{\"Farm\":{\"forward_links\":[\"Animal\",\"Pig\",\"Equality\"]}}", atj.convertToJson(&a));
    }

    TEST(WriteEmptyArticleCollection)
    {
        ToJsonWriter atj;
        ArticleCollection ac;
        CHECK_EQUAL("{}", atj.convertToJson(ac));
    }

    TEST(WriteArticleCollection_OneArticleWithoutLinks)
    {
        ToJsonWriter atj;
        ArticleCollection ac;
        ac.add(new Article("Foo"));
        CHECK_EQUAL("{\"Foo\":{\"forward_links\":[]}}", atj.convertToJson(ac));
    }
}

#include <UnitTest++.h>

#include "../src/ToJsonWriter.h"

SUITE(ArticleToJsonWriterTests)
{
    TEST(WriteArticleWithoutLinks)
    {
        ToJsonWriter atj;
        Article a("Farm");
        CHECK_EQUAL("{\"Farm\":[]}", atj.convertToJson(&a));
    }

    TEST(WriteArticleWithOneLink)
    {
        ToJsonWriter atj;
        Article a("Farm");
        a.addLink(new Article("Animal"));
        CHECK_EQUAL("{\"Farm\":[\"Animal\"]}", atj.convertToJson(&a));
    }

    TEST(WriteArticleWithMultipleLinks)
    {
        ToJsonWriter atj;
        Article a("Farm");
        a.addLink(new Article("Animal"));
        a.addLink(new Article("Pig"));
        a.addLink(new Article("Equality"));
        CHECK_EQUAL("{\"Farm\":[\"Animal\",\"Pig\",\"Equality\"]}", atj.convertToJson(&a));
    }

    TEST(WriteEmptyArticleCollection)
    {
        ToJsonWriter atj;
        ArticleCollection ac;
        CHECK_EQUAL("{}", atj.convertToJson(ac));
    }

    TEST(WriteArticleCollection_OneArticleWithoutLinks)
    {
        ToJsonWriter atj;
        ArticleCollection ac;
        ac.add(new Article("Foo"));
        CHECK_EQUAL("{\"Foo\":[]}", atj.convertToJson(ac));
    }
}

--- 
+++ 
@@ -8,7 +8,7 @@
     {
         ToJsonWriter atj;
         Article a("Farm");
-        CHECK_EQUAL("{\"Farm\":[]}", atj.convertToJson(&a));
+        CHECK_EQUAL("{\"Farm\":{\"forward_links\":[]}}", atj.convertToJson(&a));
     }
 
     TEST(WriteArticleWithOneLink)
@@ -16,7 +16,7 @@
         ToJsonWriter atj;
         Article a("Farm");
         a.addLink(new Article("Animal"));
-        CHECK_EQUAL("{\"Farm\":[\"Animal\"]}", atj.convertToJson(&a));
+        CHECK_EQUAL("{\"Farm\":{\"forward_links\":[\"Animal\"]}}", atj.convertToJson(&a));
     }
 
     TEST(WriteArticleWithMultipleLinks)
@@ -26,7 +26,7 @@
         a.addLink(new Article("Animal"));
         a.addLink(new Article("Pig"));
         a.addLink(new Article("Equality"));
-        CHECK_EQUAL("{\"Farm\":[\"Animal\",\"Pig\",\"Equality\"]}", atj.convertToJson(&a));
+        CHECK_EQUAL("{\"Farm\":{\"forward_links\":[\"Animal\",\"Pig\",\"Equality\"]}}", atj.convertToJson(&a));
     }
 
     TEST(WriteEmptyArticleCollection)
@@ -41,6 +41,6 @@
         ToJsonWriter atj;
         ArticleCollection ac;
         ac.add(new Article("Foo"));
-        CHECK_EQUAL("{\"Foo\":[]}", atj.convertToJson(ac));
+        CHECK_EQUAL("{\"Foo\":{\"forward_links\":[]}}", atj.convertToJson(ac));
     }
 }
Change requirements for json writer:

  must not include links as "plain array", but inside another object.
  so later, I can add e.g. "reverse links".
