You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.9 KiB
57 lines
1.9 KiB
#pragma once |
|
|
|
#include "domain/entities/Item.h" |
|
#include "domain/entities/User.h" |
|
#include <chrono> |
|
#include <string> |
|
|
|
namespace nxl::autostore::domain { |
|
// Equality operator for Item to make trompeloeil work |
|
inline bool operator==(const Item& lhs, const Item& rhs) |
|
{ |
|
return lhs.id == rhs.id && lhs.name == rhs.name |
|
&& lhs.orderUrl == rhs.orderUrl && lhs.userId == rhs.userId |
|
&& lhs.expirationDate == rhs.expirationDate; |
|
} |
|
} // namespace nxl::autostore::domain |
|
|
|
namespace test { |
|
|
|
constexpr const char* TEST_ITEM_ID_1 = "item123"; |
|
constexpr const char* TEST_ITEM_ID_2 = "item456"; |
|
constexpr const char* TEST_ITEM_NAME_1 = "testitem"; |
|
constexpr const char* TEST_ORDER_URL_1 = "https://example.com/order1"; |
|
constexpr const char* TEST_USER_ID_1 = "user123"; |
|
constexpr const char* TEST_USER_ID_2 = "user456"; |
|
|
|
// Fixed test timepoint: 2020-01-01 12:00 |
|
constexpr std::chrono::system_clock::time_point TEST_TIMEPOINT_NOW = |
|
std::chrono::system_clock::time_point(std::chrono::seconds(1577880000)); |
|
|
|
// Helper function to create a test item with default values |
|
nxl::autostore::domain::Item |
|
createTestItem(const std::string& id = TEST_ITEM_ID_1, |
|
const std::string& name = TEST_ITEM_NAME_1, |
|
const std::string& orderUrl = TEST_ORDER_URL_1, |
|
const std::string& userId = TEST_USER_ID_1, |
|
const std::chrono::system_clock::time_point& expirationDate = |
|
std::chrono::system_clock::now() + std::chrono::hours(24)) |
|
{ |
|
nxl::autostore::domain::Item item; |
|
item.id = id; |
|
item.name = name; |
|
item.orderUrl = orderUrl; |
|
item.userId = userId; |
|
item.expirationDate = expirationDate; |
|
return item; |
|
} |
|
|
|
// Helper function to create an expired test item |
|
nxl::autostore::domain::Item createExpiredTestItem() |
|
{ |
|
return createTestItem(TEST_ITEM_ID_1, TEST_ITEM_NAME_1, TEST_ORDER_URL_1, |
|
TEST_USER_ID_1, |
|
TEST_TIMEPOINT_NOW - std::chrono::hours(1)); |
|
} |
|
|
|
} // namespace test
|