Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FIT-Connect-SDK - .NET
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FIT-Connect
FIT-Connect-SDK - .NET
Commits
d1afb3d4
Commit
d1afb3d4
authored
1 year ago
by
Klaus Fischer
Browse files
Options
Downloads
Patches
Plain Diff
Mocking destination with multiple Schemas
parent
cde6791c
No related branches found
No related tags found
2 merge requests
!58
Issue/release preparation
,
!42
Issue/872 check submission data schema
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Tests/BasicUnitTest/SenderTests.cs
+6
-2
6 additions, 2 deletions
Tests/BasicUnitTest/SenderTests.cs
Tests/MockContainer/MockContainer.cs
+20
-7
20 additions, 7 deletions
Tests/MockContainer/MockContainer.cs
with
26 additions
and
9 deletions
Tests/BasicUnitTest/SenderTests.cs
+
6
−
2
View file @
d1afb3d4
using
System
;
using
System.Linq
;
using
System.Net.Mime
;
using
System.Text.RegularExpressions
;
using
Autofac
;
...
...
@@ -25,7 +26,10 @@ public class SenderTests {
private
ILogger
?
logger
;
const
string
JSON_SCHEMA_URI
=
"https://git.fitko.de/fit-connect/sdk-dotnet/-/raw/issue/872-check-submission-data-schema/Examples/example.schema.json"
;
"https://www.leika.nl/fitconnect/v1/schema"
;
const
string
XML_SCHEMA_URI
=
"https://git.fitko.de/fit-connect/sdk-dotnet/-/raw/issue/872-check-submission-data-schema/Examples/schema.xsd"
;
[
OneTimeSetUp
]
...
...
@@ -131,7 +135,7 @@ public class SenderTests {
.
SetServiceType
(
serviceIdentifier
,
""
)
.
SetXmlData
(
@"<?xml version=""1.0"" encoding=""UTF-8""?> <root> <child>value</child> </root> "
,
new
Uri
(
"urn:ietf:rfc:3986"
))
new
Uri
(
XML_SCHEMA_URI
))
.
AddAttachments
(
Array
.
Empty
<
Attachment
>())
.
Build
();
sender
.
SendAsync
(
outgoing
).
Wait
();
...
...
This diff is collapsed.
Click to expand it.
Tests/MockContainer/MockContainer.cs
+
20
−
7
View file @
d1afb3d4
...
...
@@ -27,7 +27,7 @@ public class TestFile {
public
static
class
Container
{
public
const
string
JSON_SCHEMA_URI
=
"https://www.leika.nl/fitconnect/v1/schema"
;
public
static
IContainer
Create
()
{
var
builder
=
new
ContainerBuilder
();
var
settings
=
CreateEncryptionSettings
(
builder
);
...
...
@@ -54,15 +54,28 @@ public static class Container {
var
mock
=
new
Mock
<
IDestinationService
>();
mock
.
Setup
(
x
=>
x
.
GetPublicKey
(
It
.
IsAny
<
Guid
>())).
Returns
(()
=>
Task
.
FromResult
(
settings
.
PublicKeyEncryption
));
mock
.
Setup
(
x
=>
x
.
GetDestinationAsync
(
It
.
IsAny
<
Guid
>()).
Result
).
Returns
(()
=>
mock
.
Setup
(
x
=>
x
.
GetDestinationAsync
(
It
.
IsAny
<
Guid
>()).
Result
).
Returns
(()
=>
new
PublicDestinationDto
()
{
DestinationId
=
settings
.
DestinationId
,
Services
=
new
List
<
DestinationServiceDto
>()
{
new
DestinationServiceDto
()
{
new
()
{
Identifier
=
settings
.
ServiceIdentifier
,
SubmissionSchemas
=
new
List
<
SubmissionSchemaDto
>()
{
new
SubmissionSchemaDto
()
{
SchemaUri
=
new
Uri
(
JSON_SCHEMA_URI
)
new
()
{
SchemaUri
=
new
Uri
(
JSON_SCHEMA_URI
),
mimeType
=
System
.
Net
.
Mime
.
MediaTypeNames
.
Application
.
Json
},
new
()
{
SchemaUri
=
new
Uri
(
"https://git.fitko.de/fit-connect/sdk-dotnet/-/raw/issue/872-check-submission-data-schema/Examples/example.schema.json"
),
mimeType
=
System
.
Net
.
Mime
.
MediaTypeNames
.
Application
.
Json
},
new
()
{
SchemaUri
=
new
Uri
(
"https://git.fitko.de/fit-connect/sdk-dotnet/-/raw/issue/872-check-submission-data-schema/Examples/schema.xsd"
),
mimeType
=
System
.
Net
.
Mime
.
MediaTypeNames
.
Application
.
Xml
}
}
}
...
...
@@ -70,7 +83,6 @@ public static class Container {
});
return
mock
;
}
private
static
IFitConnectSettings
CreateEncryptionSettings
(
ContainerBuilder
builder
)
{
...
...
@@ -111,7 +123,8 @@ public static class Container {
@"{""offset"":0,""count"":3,""totalCount"":3,""submissions"":[{""destinationId"":""879ee109-a690-4db8-ab32-424284184d7d"",""submissionId"":""ce75a6b8-d72f-4b94-b09e-af6be35bc2ae""},{""destinationId"":""19c8489b-29b8-422f-b7db-919852cfb04b"",""submissionId"":""e364430f-5a3b-4284-ba9a-f2867ba421e6""},{""destinationId"":""80a0aac3-148d-42bb-9366-516ce6355348"",""submissionId"":""530ba588-2db9-4899-ab0d-0c0b57689271""}]}"
))
!
);
submissionService
.
Setup
(
s
=>
s
.
CreateSubmissionOnServerAsync
(
It
.
IsAny
<
CreateSubmissionDto
>()))
submissionService
.
Setup
(
s
=>
s
.
CreateSubmissionOnServerAsync
(
It
.
IsAny
<
CreateSubmissionDto
>()))
.
Returns
(
()
=>
Task
.
FromResult
(
new
SubmissionCreatedDto
{
DestinationId
=
Guid
.
NewGuid
(),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment