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
526642a5
Commit
526642a5
authored
2 years ago
by
Dariusz Rybicki
Browse files
Options
Downloads
Patches
Plain Diff
Add Progress model
parent
98585779
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!102
Release 1.0.0
,
!18
Update Bindings
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Sources/ElixxirDAppsSDK/Models/Progress.swift
+38
-0
38 additions, 0 deletions
Sources/ElixxirDAppsSDK/Models/Progress.swift
Tests/ElixxirDAppsSDKTests/Models/ProgressTests.swift
+32
-0
32 additions, 0 deletions
Tests/ElixxirDAppsSDKTests/Models/ProgressTests.swift
with
70 additions
and
0 deletions
Sources/ElixxirDAppsSDK/Models/Progress.swift
0 → 100644
+
38
−
0
View file @
526642a5
import
Foundation
public
struct
Progress
:
Equatable
{
public
init
(
completed
:
Bool
,
transmitted
:
Int
,
total
:
Int
)
{
self
.
completed
=
completed
self
.
transmitted
=
transmitted
self
.
total
=
total
}
public
var
completed
:
Bool
public
var
transmitted
:
Int
public
var
total
:
Int
// TODO: add error
// public var error: ???
}
import
Bindings
extension
Progress
:
Codable
{
enum
CodingKeys
:
String
,
CodingKey
{
case
completed
=
"Completed"
case
transmitted
=
"Transmitted"
case
total
=
"Total"
// TODO: add error
// case error = "Err"
}
public
static
func
decode
(
_
data
:
Data
)
throws
->
Self
{
try
JSONDecoder
()
.
decode
(
Self
.
self
,
from
:
data
)
}
public
func
encode
()
throws
->
Data
{
try
JSONEncoder
()
.
encode
(
self
)
}
}
This diff is collapsed.
Click to expand it.
Tests/ElixxirDAppsSDKTests/Models/ProgressTests.swift
0 → 100644
+
32
−
0
View file @
526642a5
import
CustomDump
import
XCTest
@testable
import
ElixxirDAppsSDK
final
class
ProgressTests
:
XCTestCase
{
func
testCoding
()
throws
{
let
completed
=
false
let
transmitted
:
Int
=
128
let
total
:
Int
=
2048
let
jsonString
=
"""
{
"
Completed
":
\(
completed
)
,
"
Transmitted
":
\(
transmitted
)
,
"
Total
":
\(
total
)
,
"
Err
": null
}
"""
let
jsonData
=
jsonString
.
data
(
using
:
.
utf8
)
!
let
progress
=
try
Progress
.
decode
(
jsonData
)
XCTAssertNoDifference
(
progress
,
Progress
(
completed
:
completed
,
transmitted
:
transmitted
,
total
:
total
))
let
encodedProgress
=
try
progress
.
encode
()
let
decodedProgress
=
try
Progress
.
decode
(
encodedProgress
)
XCTAssertNoDifference
(
decodedProgress
,
progress
)
}
}
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