Created
April 16, 2011 16:41
-
-
Save biot023/923262 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <boost/test/unit_test.hpp> | |
#include "../include/game_factory.h" | |
#include <vector> | |
#include <sstream> | |
#include <iostream> | |
#include <boost/shared_ptr.hpp> | |
#include <boost/pointer_cast.hpp> | |
#include <boost/serialization/shared_ptr.hpp> | |
#include <boost/archive/xml_oarchive.hpp> | |
#include <boost/archive/xml_iarchive.hpp> | |
using namespace std; | |
using namespace boost; | |
using namespace cbiots; | |
struct FeatureGameRenderer { | |
vector<string> _frames; | |
void render( shared_ptr<Game> _game ) { | |
Game& game = *_game; | |
stringstream buf( stringstream::in | stringstream::out ); | |
buf << "Some text" << endl; | |
string str( buf.str() ); | |
boost::archive::xml_oarchive archive( buf ); // FIXME | |
archive << BOOST_SERIALIZATION_NVP( game ); | |
_frames.push_back( buf.str() ); | |
} | |
}; | |
struct GeneratingAGameFixture { | |
GeneratingAGameFixture() {} | |
~GeneratingAGameFixture() {} | |
}; | |
BOOST_FIXTURE_TEST_CASE( generating_a_game, GeneratingAGameFixture ) { | |
/* Given I have a game factory */ | |
GameFactory game_factory = GameFactory(); | |
/* And I have a game renderer */ | |
FeatureGameRenderer renderer = FeatureGameRenderer(); | |
/* When I create a game with the game factory */ | |
shared_ptr<IGame> game = game_factory.build(); | |
/* And I render it with the renderer */ | |
renderer.render( dynamic_pointer_cast<Game>( game ) ); | |
string str = renderer._frames.back(); | |
cout << str << endl; | |
/* Then I should see the board rendered */ | |
BOOST_REQUIRE_MESSAGE( false, "Pending" ); | |
/* And I should not see any biots rendered */ | |
BOOST_REQUIRE_MESSAGE( false, "Pending" ); | |
/* And I should not see any events rendered */ | |
BOOST_REQUIRE_MESSAGE( false, "Pending" ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment