#include "favoritethreadstest.h"
+#include "../favoritethreads.h"
+
void FavoriteThreadsTest::setUp()
-{}
+{
+ // FIXME: 2¤Ä¤Î¥¹¥ì¥Ã¥É¤Î½ç½ø¤òÊѹ¹¤¹¤ë¤È¤¦¤Þ¤¯¤¤¤«¤Ê¤¤¡£
+ // FIXME: resnum¤Ï¤¤¤é¤Ê¤¤
+ m_xml = "<favorites xmlns=\"http://kita.sourceforge.jp/ns/favorites\">\n"
+ "<thread xmlns=\"http://kita.sourceforge.jp/ns/thread\">\n"
+ "<daturl>http://pc.2ch.net/unix/dat/956134538.dat</daturl>\n"
+ "<name>NeXT</name>\n"
+ "<resnum>10</resnum>\n"
+ "<board xmlns=\"http://kita.sourceforge.jp/ns/board\">\n"
+ "<url>http://pc.2ch.net/unix/</url>\n"
+ "<name>Unix</name>\n"
+ "</board>\n"
+ "</thread>\n"
+ "<thread xmlns=\"http://kita.sourceforge.jp/ns/thread\">\n"
+ "<daturl>http://pc.2ch.net/linux/dat/1022744633.dat</daturl>\n"
+ "<name>2ch browser thread</name>\n"
+ "<resnum>20</resnum>\n"
+ "<board xmlns=\"http://kita.sourceforge.jp/ns/board\">\n"
+ "<url>http://pc.2ch.net/linux/</url>\n"
+ "<name>Linux</name>\n"
+ "</board>\n"
+ "</thread>\n"
+ "</favorites>\n";
+
+ FavoriteThreads::fromXml( m_xml );
+}
void FavoriteThreadsTest::tearDown()
{}
+void FavoriteThreadsTest::testToXML()
+{
+ CPPUNIT_ASSERT_EQUAL( m_xml, FavoriteThreads::getInstance() ->toXml() );
+}
+
+void FavoriteThreadsTest::testThreads()
+{
+ const QDict<Kita::Thread> threads = FavoriteThreads::getInstance() ->threads();
+ CPPUNIT_ASSERT_EQUAL( ( uint ) 2, threads.count() );
+
+ Kita::Thread* thread1 = threads[ "http://pc.2ch.net/unix/dat/956134538.dat" ];
+ CPPUNIT_ASSERT_EQUAL( QString( "NeXT" ), thread1->name() );
+ CPPUNIT_ASSERT_EQUAL( 10, thread1->resNum() );
+ CPPUNIT_ASSERT_EQUAL( QString( "http://pc.2ch.net/unix/" ), thread1->boardURL() );
+ CPPUNIT_ASSERT_EQUAL( QString( "Unix" ), thread1->boardName() );
+ CPPUNIT_ASSERT_EQUAL( QString( "unix" ), thread1->boardID() );
+
+ Kita::Thread* thread2 = threads[ "http://pc.2ch.net/linux/dat/1022744633.dat" ];
+ CPPUNIT_ASSERT_EQUAL( QString( "2ch browser thread" ), thread2->name() );
+ CPPUNIT_ASSERT_EQUAL( 20, thread2->resNum() );
+ CPPUNIT_ASSERT_EQUAL( QString( "http://pc.2ch.net/linux/" ), thread2->boardURL() );
+ CPPUNIT_ASSERT_EQUAL( QString( "Linux" ), thread2->boardName() );
+ CPPUNIT_ASSERT_EQUAL( QString( "linux" ), thread2->boardID() );
+}