Skip to content

Commit

Permalink
add application service
Browse files Browse the repository at this point in the history
Logic like the creation of an issue ID does not belong into the CLI app,
so we create the first class of the fix issue bounded context.
  • Loading branch information
arnemertz committed Aug 13, 2021
1 parent 6334eb3 commit 7d033e0
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generic test that uses conan libs

add_subdirectory(fix_cli)
add_subdirectory(domain)

add_executable(fix main.cpp)
target_link_libraries(
Expand Down
11 changes: 11 additions & 0 deletions src/domain/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set(DOMAIN_SOURCES
application_service.cpp
)

add_library(domain ${DOMAIN_SOURCES})
target_link_libraries(domain
PRIVATE
project_warnings
project_options
)
target_include_directories(domain PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
9 changes: 9 additions & 0 deletions src/domain/application_service.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "application_service.hpp"

using namespace fix::domain;

std::string application_service::create(std::string_view title, std::string_view description) { // NOLINT
(void) title;
(void) description;
return "thi-is-a-new-0000000";
}
16 changes: 16 additions & 0 deletions src/domain/application_service.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef FIX_DOMAIN_APPLICATION_SERVICE_HPP
#define FIX_DOMAIN_APPLICATION_SERVICE_HPP

#include <string>

namespace fix::domain {

class application_service {
public:
// cppcheck-suppress functionStatic
std::string create(std::string_view title, std::string_view description);
};

}

#endif // FIX_DOMAIN_APPLICATION_SERVICE_HPP
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ target_link_libraries(catch_main PUBLIC CONAN_PKG::catch2)
target_link_libraries(catch_main PRIVATE project_options)

add_subdirectory(fix_cli)
add_subdirectory(domain)
9 changes: 9 additions & 0 deletions test/domain/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set(DOMAIN_TEST_SOURCES
application_service_test.cpp
)

add_executable(domain_tests ${DOMAIN_TEST_SOURCES})
target_link_libraries(domain_tests
PRIVATE project_warnings project_options catch_main domain)

catch_discover_tests(domain_tests TEST_PREFIX "DOMAIN: ")
10 changes: 10 additions & 0 deletions test/domain/application_service_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <catch2/catch.hpp>

#include "application_service.hpp"

using fix::domain::application_service;

TEST_CASE("Create issue returns issue ID") {
application_service application_service;
CHECK_THAT(application_service.create("this is a new issue", "some text"), Catch::Matches("thi-is-a-new-[0-9a-f]{7}"));
}

0 comments on commit 7d033e0

Please sign in to comment.