Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Johannes Loher
d-webservice-example
Commits
be59006d
Commit
be59006d
authored
Dec 19, 2018
by
Johannes Loher
Browse files
Merge branch 'bugfix/do_not_genrate_new_id_on_update' into 'master'
fix: do not generate a new id on update See merge request
!2
parents
24922952
214ffef3
Pipeline
#119
passed with stages
in 11 minutes and 15 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
source/d_webservice_example/dataaccess/in_memory_todo_repository.d
View file @
be59006d
...
...
@@ -3,6 +3,11 @@ module d_webservice_example.dataaccess.in_memory_todo_repository;
import
aermicioi
.
aedi
:
component
,
qualifier
;
import
d_webservice_example
.
business
.
todo_service
:
TodoRepository
;
version
(
unittest
)
{
import
fluent
.
asserts
;
}
@component
@qualifier
!
TodoRepository
()
class
InMemoryTodoRepository
:
TodoRepository
{
import
d_webservice_example
.
model
.
todo
:
Todo
;
...
...
@@ -15,11 +20,46 @@ private:
public
:
override
Todo
save
(
Todo
todo
)
{
todo
.
id
=
randomUUID
.
toString
;
import
std
.
range
.
primitives
:
empty
;
if
(
todo
.
id
.
empty
)
todo
.
id
=
randomUUID
.
toString
;
todos
[
todo
.
id
]
=
todo
;
return
todo
;
}
unittest
{
// given
auto
underTest
=
new
InMemoryTodoRepository
;
auto
todo
=
Todo
(
"some title"
,
"some content"
,
UUID
(
"00000000-0000-0000-0000-000000000001"
));
// when
auto
savedTodo
=
underTest
.
save
(
todo
);
// then
savedTodo
.
title
.
should
.
equal
(
todo
.
title
);
savedTodo
.
content
.
should
.
equal
(
todo
.
content
);
savedTodo
.
uuid
.
should
.
equal
(
todo
.
uuid
);
savedTodo
.
id
.
length
.
should
.
equal
(
36
);
}
unittest
{
// given
auto
underTest
=
new
InMemoryTodoRepository
;
auto
todo
=
Todo
(
"some title"
,
"some content"
,
UUID
(
"00000000-0000-0000-0000-000000000001"
),
"00000000-0000-0000-0000-000000000002"
);
// when
auto
savedTodo
=
underTest
.
save
(
todo
);
// then
savedTodo
.
should
.
equal
(
todo
);
}
override
Todo
[]
findAll
()
{
import
std
.
array
:
array
;
...
...
source/d_webservice_example/model/todo.d
View file @
be59006d
...
...
@@ -18,6 +18,14 @@ struct Todo
this
.
uuid
=
uuid
;
}
this
(
string
title
,
string
content
,
UUID
uuid
,
string
id
)
nothrow
pure
@safe
@nogc
{
this
.
title
=
title
;
this
.
content
=
content
;
this
.
uuid
=
uuid
;
this
.
id
=
id
;
}
string
title
;
string
content
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment