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
593d5f10
Commit
593d5f10
authored
2 years ago
by
Dariusz Rybicki
Browse files
Options
Downloads
Patches
Plain Diff
Add convenient fact getter and setter to Contact
parent
f538f821
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!102
Release 1.0.0
,
!71
Fact improvements & helpers
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Sources/XXClient/Models/Contact.swift
+12
-0
12 additions, 0 deletions
Sources/XXClient/Models/Contact.swift
Tests/XXClientTests/Models/ContactTests.swift
+61
-0
61 additions, 0 deletions
Tests/XXClientTests/Models/ContactTests.swift
with
73 additions
and
0 deletions
Sources/XXClient/Models/Contact.swift
+
12
−
0
View file @
593d5f10
...
@@ -44,6 +44,18 @@ extension Contact: Equatable {
...
@@ -44,6 +44,18 @@ extension Contact: Equatable {
}
}
}
}
extension
Contact
{
public
func
getFact
(
_
type
:
FactType
)
throws
->
Fact
?
{
try
getFacts
()
.
get
(
type
)
}
public
mutating
func
setFact
(
_
type
:
FactType
,
_
value
:
String
?)
throws
{
var
facts
=
try
getFacts
()
facts
.
set
(
type
,
value
)
try
setFacts
(
facts
)
}
}
extension
Contact
{
extension
Contact
{
public
static
func
live
(
public
static
func
live
(
_
data
:
Data
,
_
data
:
Data
,
...
...
This diff is collapsed.
Click to expand it.
Tests/XXClientTests/Models/ContactTests.swift
0 → 100644
+
61
−
0
View file @
593d5f10
import
CustomDump
import
XCTest
@testable
import
XXClient
final
class
ContactTests
:
XCTestCase
{
func
testGetFact
()
throws
{
var
contact
=
Contact
.
unimplemented
(
"contact-data"
.
data
(
using
:
.
utf8
)
!
)
contact
.
getFactsFromContact
.
run
=
{
_
in
[
Fact
(
fact
:
"username"
,
type
:
0
),
Fact
(
fact
:
"email"
,
type
:
1
),
Fact
(
fact
:
"phone"
,
type
:
2
),
Fact
(
fact
:
"other"
,
type
:
3
),
]
}
XCTAssertNoDifference
(
[
try
contact
.
getFact
(
.
username
),
try
contact
.
getFact
(
.
email
),
try
contact
.
getFact
(
.
phone
),
try
contact
.
getFact
(
.
other
(
3
)),
try
contact
.
getFact
(
.
other
(
4
)),
],
[
Fact
(
fact
:
"username"
,
type
:
0
),
Fact
(
fact
:
"email"
,
type
:
1
),
Fact
(
fact
:
"phone"
,
type
:
2
),
Fact
(
fact
:
"other"
,
type
:
3
),
nil
]
)
}
func
testSetFact
()
throws
{
var
contact
=
Contact
.
unimplemented
(
"contact-data"
.
data
(
using
:
.
utf8
)
!
)
var
facts
:
[
Fact
]
=
[
Fact
(
fact
:
"username"
,
type
:
0
),
Fact
(
fact
:
"email"
,
type
:
1
),
Fact
(
fact
:
"phone"
,
type
:
2
),
Fact
(
fact
:
"other-3"
,
type
:
3
),
]
contact
.
getFactsFromContact
.
run
=
{
_
in
facts
}
contact
.
setFactsOnContact
.
run
=
{
data
,
newFacts
in
facts
=
newFacts
return
data
}
try
contact
.
setFact
(
.
username
,
"new-username"
)
try
contact
.
setFact
(
.
other
(
4
),
"new-other-4"
)
try
contact
.
setFact
(
.
other
(
3
),
"new-other-3"
)
try
contact
.
setFact
(
.
email
,
nil
)
XCTAssertNoDifference
(
facts
,
[
Fact
(
fact
:
"new-username"
,
type
:
0
),
Fact
(
fact
:
"phone"
,
type
:
2
),
Fact
(
fact
:
"new-other-3"
,
type
:
3
),
Fact
(
fact
:
"new-other-4"
,
type
:
4
),
])
}
}
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