1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
/*
* Copyright 2013-2016, Corvusoft Ltd, All Rights Reserved.
*/
//System Includes
#include <string>
#include <memory>
#include <stdexcept>
//Project Includes
#include <restbed>
//External Includes
#include <catch.hpp>
//System Namespaces
using std::string;
using std::shared_ptr;
using std::make_shared;
using std::invalid_argument;
//Project Namespaces
using namespace restbed;
//External Namespaces
SCENARIO( "publishing duplicate resources", "[service]" )
{
GIVEN( "I publish a resource at '/resources/1'" )
{
auto resource = make_shared< Resource >( );
resource->set_path( "/resources/1" );
auto settings = make_shared< Settings >( );
settings->set_port( 1984 );
Service service;
service.publish( resource );
WHEN( "I attempt to publish another resource at '/resources/1'" )
{
THEN( "I should see an invalid argument error of 'Resource would pollute namespace. Please ensure all published resources have unique paths.'" )
{
REQUIRE_THROWS_AS( service.publish( resource ), invalid_argument );
}
}
service.stop( );
}
}
|