Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Elixxir dApps SDK Swift
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
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile
iOS
Elixxir dApps SDK Swift
Commits
bb00851c
Commit
bb00851c
authored
2 years ago
by
Dariusz Rybicki
Browse files
Options
Downloads
Patches
Plain Diff
Add ContactFact codable model
parent
00ad3639
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!3
Bindings models wrapper
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Sources/ElixxirDAppsSDK/ContactFact.swift
+19
-0
19 additions, 0 deletions
Sources/ElixxirDAppsSDK/ContactFact.swift
Tests/ElixxirDAppsSDKTests/ContactFactTests.swift
+30
-0
30 additions, 0 deletions
Tests/ElixxirDAppsSDKTests/ContactFactTests.swift
with
49 additions
and
0 deletions
Sources/ElixxirDAppsSDK/ContactFact.swift
0 → 100644
+
19
−
0
View file @
bb00851c
public
struct
ContactFact
:
Equatable
{
public
init
(
fact
:
String
,
type
:
Int
)
{
self
.
fact
=
fact
self
.
type
=
type
}
public
var
fact
:
String
public
var
type
:
Int
}
extension
ContactFact
:
Codable
{
enum
CodingKeys
:
String
,
CodingKey
{
case
fact
=
"Fact"
case
type
=
"Type"
}
}
This diff is collapsed.
Click to expand it.
Tests/ElixxirDAppsSDKTests/ContactFactTests.swift
0 → 100644
+
30
−
0
View file @
bb00851c
import
CustomDump
import
XCTest
@testable
import
ElixxirDAppsSDK
final
class
ContactFactTests
:
XCTestCase
{
func
testCoding
()
throws
{
let
jsonString
=
"""
{
"
Fact
": "
Zezima
",
"
Type
": 0
}
"""
let
jsonData
=
jsonString
.
data
(
using
:
.
utf8
)
!
let
decoder
=
JSONDecoder
()
decoder
.
dataDecodingStrategy
=
.
base64
let
fact
=
try
decoder
.
decode
(
ContactFact
.
self
,
from
:
jsonData
)
XCTAssertNoDifference
(
fact
,
ContactFact
(
fact
:
"Zezima"
,
type
:
0
))
let
encoder
=
JSONEncoder
()
encoder
.
dataEncodingStrategy
=
.
base64
let
encodedFact
=
try
encoder
.
encode
(
fact
)
let
decodedFact
=
try
decoder
.
decode
(
ContactFact
.
self
,
from
:
encodedFact
)
XCTAssertNoDifference
(
decodedFact
,
fact
)
}
}
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