static constexpr char RESOURCE_TYPE[]{ "resourceType" };
static constexpr char KEY[]{ "key" };
-TEST(ServerResourceBuilderTest, ThrowIfUriIsInvalid)
+TEST(ServerResourceBuilderCreateTest, ThrowIfUriIsInvalid)
{
ASSERT_THROW(PrimitiveServerResource::Builder("", "", "").create(), PlatformException);
}
-TEST(ServerResourceBuilderTest, RegisterResourceWhenCallCreate)
+class ServerResourceBuilderTest: public Test
{
+public:
MockRepository mocks;
- mocks.ExpectCallFuncOverload(
- static_cast<registerResourceSig>(OCPlatform::registerResource)).Return(OC_STACK_OK);
+protected:
+ void SetUp() override
+ {
+ mocks.OnCallFuncOverload(static_cast<registerResourceSig>(OCPlatform::registerResource))
+ .Return(OC_STACK_OK);
+ }
+};
+TEST_F(ServerResourceBuilderTest, RegisterResourceWhenCallCreate)
+{
+ mocks.ExpectCallFuncOverload(static_cast<registerResourceSig>(OCPlatform::registerResource))
+ .Return(OC_STACK_OK);
PrimitiveServerResource::Builder(RESOURCE_URI, RESOURCE_TYPE, "").create();
}
-TEST(ServerResourceBuilderTest, ResourceServerHasPropertiesSetByBuilder)
+TEST_F(ServerResourceBuilderTest, ResourceServerHasPropertiesSetByBuilder)
{
auto serverResource = PrimitiveServerResource::Builder(RESOURCE_URI, RESOURCE_TYPE, "").
setDiscoverable(false).setObservable(true).create();
EXPECT_TRUE(serverResource->isObservable());
}
-TEST(ServerResourceBuilderTest, ResourceServerHasAttrsSetByBuilder)
+TEST_F(ServerResourceBuilderTest, ResourceServerHasAttrsSetByBuilder)
{
ResourceAttributes attrs;
attrs[KEY] = 100;
constexpr char EXISTING[]{ "ext" };
constexpr int ORIGIN_VALUE{ 100 };
+using RegisterResource = OCStackResult (*)(OCResourceHandle&, std::string&,
+ const std::string&, const std::string&, OC::EntityHandler, uint8_t);
+
class SimpleRequestHandlerTest: public Test
{
public:
ResourceAttributes requestAttrs;
+ MockRepository mocks;
+
protected:
void SetUp() override
{
+ mocks.OnCallFuncOverload(static_cast<RegisterResource>(OC::OCPlatform::registerResource))
+ .Return(OC_STACK_OK);
+
server = PrimitiveServerResource::Builder("a/test", "resourceType", "").create();
server->setAttribute(EXISTING, ORIGIN_VALUE);
ResourceAttributes requestAttrs;
RequestHandler::Ptr setRequestProxyHandler;
+ MockRepository mocks;
+
protected:
void SetUp() override
{
+ mocks.OnCallFuncOverload(static_cast<RegisterResource>(OC::OCPlatform::registerResource))
+ .Return(OC_STACK_OK);
+
setRequestProxyHandler = make_shared<SetRequestProxyHandler>(
make_shared<SimpleRequestHandler>());