Skip to content

Commit 7d033e0

Browse files
committed
add application service
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.
1 parent 6334eb3 commit 7d033e0

7 files changed

Lines changed: 57 additions & 0 deletions

File tree

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Generic test that uses conan libs
22

33
add_subdirectory(fix_cli)
4+
add_subdirectory(domain)
45

56
add_executable(fix main.cpp)
67
target_link_libraries(

src/domain/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
set(DOMAIN_SOURCES
2+
application_service.cpp
3+
)
4+
5+
add_library(domain ${DOMAIN_SOURCES})
6+
target_link_libraries(domain
7+
PRIVATE
8+
project_warnings
9+
project_options
10+
)
11+
target_include_directories(domain PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)

src/domain/application_service.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include "application_service.hpp"
2+
3+
using namespace fix::domain;
4+
5+
std::string application_service::create(std::string_view title, std::string_view description) { // NOLINT
6+
(void) title;
7+
(void) description;
8+
return "thi-is-a-new-0000000";
9+
}

src/domain/application_service.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ifndef FIX_DOMAIN_APPLICATION_SERVICE_HPP
2+
#define FIX_DOMAIN_APPLICATION_SERVICE_HPP
3+
4+
#include <string>
5+
6+
namespace fix::domain {
7+
8+
class application_service {
9+
public:
10+
// cppcheck-suppress functionStatic
11+
std::string create(std::string_view title, std::string_view description);
12+
};
13+
14+
}
15+
16+
#endif // FIX_DOMAIN_APPLICATION_SERVICE_HPP

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ target_link_libraries(catch_main PUBLIC CONAN_PKG::catch2)
1010
target_link_libraries(catch_main PRIVATE project_options)
1111

1212
add_subdirectory(fix_cli)
13+
add_subdirectory(domain)

test/domain/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
set(DOMAIN_TEST_SOURCES
2+
application_service_test.cpp
3+
)
4+
5+
add_executable(domain_tests ${DOMAIN_TEST_SOURCES})
6+
target_link_libraries(domain_tests
7+
PRIVATE project_warnings project_options catch_main domain)
8+
9+
catch_discover_tests(domain_tests TEST_PREFIX "DOMAIN: ")
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <catch2/catch.hpp>
2+
3+
#include "application_service.hpp"
4+
5+
using fix::domain::application_service;
6+
7+
TEST_CASE("Create issue returns issue ID") {
8+
application_service application_service;
9+
CHECK_THAT(application_service.create("this is a new issue", "some text"), Catch::Matches("thi-is-a-new-[0-9a-f]{7}"));
10+
}

0 commit comments

Comments
 (0)