2020 int id ;
2121 char name[50 ];
2222 int processed;
23- } Entity ;
23+ } ObjcEntity ;
2424
2525typedef struct {
2626 int x;
2727 int y;
28- } ValueObject ;
28+ } ObjcValueObject ;
2929
3030typedef struct {
3131 int id ;
3232 int child_count;
33- Entity children[10 ];
34- } AggregateRoot ;
33+ ObjcEntity children[10 ];
34+ } ObjcAggregateRoot ;
3535
3636typedef struct {
37- Entity entities[10 ];
37+ ObjcEntity entities[10 ];
3838 int count;
39- } Repository ;
39+ } ObjcRepository ;
4040
4141typedef struct {
4242 bool dummy;
43- } Service ;
43+ } ObjcService ;
4444
45- Entity create_entity (int id , const char *name) {
46- Entity entity;
45+ ObjcEntity create_entity (int id , const char *name) {
46+ ObjcEntity entity;
4747 entity.id = id ;
4848 strcpy (entity.name , name);
4949 entity.processed = 0 ;
5050 return entity;
5151}
5252
53- ValueObject create_value_object (int x, int y) {
54- ValueObject vo;
53+ ObjcValueObject create_value_object (int x, int y) {
54+ ObjcValueObject vo;
5555 vo.x = x;
5656 vo.y = y;
5757 return vo;
5858}
5959
60- int value_object_equals (ValueObject vo1, ValueObject vo2) {
60+ int value_object_equals (ObjcValueObject vo1, ObjcValueObject vo2) {
6161 return (vo1.x == vo2.x && vo1.y == vo2.y );
6262}
6363
64- AggregateRoot create_aggregate_root (int id ) {
65- AggregateRoot ar;
64+ ObjcAggregateRoot create_aggregate_root (int id ) {
65+ ObjcAggregateRoot ar;
6666 ar.id = id ;
6767 ar.child_count = 0 ;
6868 return ar;
6969}
7070
71- void add_child_entity (AggregateRoot *ar, Entity entity) {
71+ void add_child_entity (ObjcAggregateRoot *ar, ObjcEntity entity) {
7272 if (ar->child_count < 10 ) {
7373 ar->children [ar->child_count++] = entity;
7474 }
7575}
7676
77- Repository create_repository (void ) {
78- Repository repo;
77+ ObjcRepository create_repository (void ) {
78+ ObjcRepository repo;
7979 repo.count = 0 ;
8080 return repo;
8181}
8282
83- void repository_add (Repository *repo, Entity entity) {
83+ void repository_add (ObjcRepository *repo, ObjcEntity entity) {
8484 if (repo->count < 10 ) {
8585 repo->entities [repo->count++] = entity;
8686 }
8787}
8888
89- int repository_count (Repository *repo) {
89+ int repository_count (ObjcRepository *repo) {
9090 return repo->count ;
9191}
9292
93- Entity repository_get (Repository *repo, int id ) {
93+ ObjcEntity repository_get (ObjcRepository *repo, int id ) {
9494 for (int i = 0 ; i < repo->count ; ++i) {
9595 if (repo->entities [i].id == id ) {
9696 return repo->entities [i];
9797 }
9898 }
99- Entity empty_entity = {0 };
99+ ObjcEntity empty_entity = {0 };
100100 return empty_entity;
101101}
102102
103- Service create_service (void ) {
104- Service service;
103+ ObjcService create_service (void ) {
104+ ObjcService service;
105105 service.dummy = 0 ;
106106 // Initialize service-specific fields
107107 return service;
108108}
109109
110- void service_process (Service *service, Entity *entity) {
110+ void service_process (ObjcService *service, ObjcEntity *entity) {
111111 entity->processed = 1 ;
112112 service->dummy = 1 ;
113113}
@@ -141,26 +141,26 @@ void service_process(Service *service, Entity *entity) {
141141
142142FOSSIL_TEST (objc_ddd_entity_creation) {
143143 // Example of creating an entity
144- Entity entity = create_entity (42 , " Sample Entity " );
144+ ObjcEntity entity = create_entity (42 , " Sample ObjcEntity " );
145145
146146 // Test cases
147- FOSSIL_TEST_ASSUME (entity.id == 42 , " Entity ID should be 42" );
148- FOSSIL_TEST_ASSUME (strcmp (entity.name , " Sample Entity " ) == 0 , " Entity name should be 'Sample Entity '" );
147+ FOSSIL_TEST_ASSUME (entity.id == 42 , " ObjcEntity ID should be 42" );
148+ FOSSIL_TEST_ASSUME (strcmp (entity.name , " Sample ObjcEntity " ) == 0 , " ObjcEntity name should be 'Sample ObjcEntity '" );
149149} // end case
150150
151151FOSSIL_TEST (objc_ddd_value_object_equality) {
152152 // Example of value object equality
153- ValueObject vo1 = create_value_object (10 , 20 );
154- ValueObject vo2 = create_value_object (10 , 20 );
153+ ObjcValueObject vo1 = create_value_object (10 , 20 );
154+ ObjcValueObject vo2 = create_value_object (10 , 20 );
155155
156156 // Test cases
157157 FOSSIL_TEST_ASSUME (value_object_equals (vo1, vo2), " Value objects should be equal" );
158158} // end case
159159
160160FOSSIL_TEST (objc_ddd_aggregate_root_behavior) {
161161 // Example of aggregate root behavior
162- AggregateRoot ar = create_aggregate_root (1 );
163- add_child_entity (&ar, create_entity (2 , " Child Entity " ));
162+ ObjcAggregateRoot ar = create_aggregate_root (1 );
163+ add_child_entity (&ar, create_entity (2 , " Child ObjcEntity " ));
164164
165165 // Test cases
166166 FOSSIL_TEST_ASSUME (ar.child_count == 1 , " Aggregate root should have one child entity" );
@@ -169,23 +169,23 @@ void service_process(Service *service, Entity *entity) {
169169
170170FOSSIL_TEST (objc_ddd_repository_usage) {
171171 // Example of repository usage
172- Repository repo = create_repository ();
173- Entity entity = create_entity (1 , " Repo Entity " );
172+ ObjcRepository repo = create_repository ();
173+ ObjcEntity entity = create_entity (1 , " Repo ObjcEntity " );
174174 repository_add (&repo, entity);
175175
176176 // Test cases
177- FOSSIL_TEST_ASSUME (repository_count (&repo) == 1 , " Repository should contain one entity" );
177+ FOSSIL_TEST_ASSUME (repository_count (&repo) == 1 , " ObjcRepository should contain one entity" );
178178 FOSSIL_TEST_ASSUME (repository_get (&repo, 1 ).id == 1 , " Retrieved entity ID should be 1" );
179179} // end case
180180
181181FOSSIL_TEST (objc_ddd_service_layer) {
182182 // Example of service layer usage
183- Service service = create_service ();
184- Entity entity = create_entity (1 , " Service Entity " );
183+ ObjcService service = create_service ();
184+ ObjcEntity entity = create_entity (1 , " ObjcService ObjcEntity " );
185185 service_process (&service, &entity);
186186
187187 // Test cases
188- FOSSIL_TEST_ASSUME (entity.processed == true , " Entity should be processed by the service" );
188+ FOSSIL_TEST_ASSUME (entity.processed == true , " ObjcEntity should be processed by the service" );
189189} // end case
190190
191191// * * * * * * * * * * * * * * * * * * * * * * * *
0 commit comments