Skip to content

Commit 9901d4e

Browse files
authored
Merge pull request #164 from modelix/feature/document-local-testing-with-model-api
docs(model-api): explain local testing
2 parents fcc0a3f + b38ca73 commit 9901d4e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
= How-To test `model-api` client code without a model-server
2+
:navtitle: Test `model-api` client code without a model-server
3+
4+
If you want to test code that processes `model-api` instances, you can do this in-process without a running (light-) model-server.
5+
Use the following pattern to set up your test fixture containing `model-api` instances:
6+
7+
[source,kotlin]
8+
--
9+
val branch = ModelFacade.toLocalBranch(ModelFacade.newLocalTree())
10+
branch.runWrite {
11+
val root = branch.getRootNode()
12+
val someRootNode = root.addNewChild(null, C_SomeConcept.untyped()).typed<N_SomeConcept>()
13+
someRootNode.member.addNew(-1, C_OtherConcept).apply {
14+
name = "some test property value"
15+
}
16+
}
17+
--
18+
19+
All classes of the pattern `C_*` and `N_*` are generated using the `model-api-gen`.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
* xref:core:howto/usage-model-server.adoc[]
22
* xref:core:howto/usage-model-api-gen-gradle.adoc[]
33
* xref:core:howto/usage-light-model-client.adoc[]
4+
* xref:core:howto/testing-against-model-api.adoc[]
45

0 commit comments

Comments
 (0)