Skip to content

Commit aa9fb14

Browse files
authored
Merge pull request #31 from debugsquad/dev
Tests
2 parents 961e2dc + 3b152fb commit aa9fb14

17 files changed

+1033
-351
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
# nubecero
44
Cloud your pictures
55

6-
<img src="https://raw.githubusercontent.com/debugsquad/nubecero/master/logo.png" width="300" alt="nubecero" />
6+
<img src="https://raw.githubusercontent.com/debugsquad/nubecero/master/logo.png" alt="nubecero" />

logo.png

-31.5 KB
Loading

nubecero.xcodeproj/project.pbxproj

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
DA0586821DEC898200651619 /* MHomeUploadHeaderItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA0586811DEC898200651619 /* MHomeUploadHeaderItem.swift */; };
1919
DA0586841DEC8A2D00651619 /* MHomeUploadHeaderItemAlbum.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA0586831DEC8A2D00651619 /* MHomeUploadHeaderItemAlbum.swift */; };
2020
DA09B6621DE5151200654C2E /* VPhotosAlbumCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA09B6611DE5151200654C2E /* VPhotosAlbumCell.swift */; };
21+
DA14D6381DF1CDC4001E8022 /* TFDatabaseModelPhotoList.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA14D6371DF1CDC4001E8022 /* TFDatabaseModelPhotoList.swift */; };
22+
DA14D63A1DF1D353001E8022 /* TFDatabaseModelUserList.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA14D6391DF1D353001E8022 /* TFDatabaseModelUserList.swift */; };
23+
DA14D63C1DF1D856001E8022 /* TFDatabaseModelUserSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA14D63B1DF1D856001E8022 /* TFDatabaseModelUserSession.swift */; };
24+
DA14D63E1DF1FFAC001E8022 /* TFDatabaseModelAlbum.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA14D63D1DF1FFAC001E8022 /* TFDatabaseModelAlbum.swift */; };
25+
DA14D6401DF20E7D001E8022 /* TFDatabaseModelAlbumList.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA14D63F1DF20E7D001E8022 /* TFDatabaseModelAlbumList.swift */; };
2126
DA25F8E11DCD63A50048DFFE /* TFDatabaseModelUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA25F8E01DCD63A50048DFFE /* TFDatabaseModelUser.swift */; };
2227
DA2F668F1DC90AF50078B466 /* FDatabaseModelPhotoList.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA2F668E1DC90AF50078B466 /* FDatabaseModelPhotoList.swift */; };
2328
DA3411751DCB90D7006E6D71 /* VHomeCellDisk.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA3411741DCB90D7006E6D71 /* VHomeCellDisk.swift */; };
@@ -129,7 +134,6 @@
129134
DA4FA5B61DD7D80E00358ABE /* MAdminItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA4FA5B51DD7D80E00358ABE /* MAdminItem.swift */; };
130135
DA4FA5B81DD7DA1300358ABE /* MAdminItemServer.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA4FA5B71DD7DA1300358ABE /* MAdminItemServer.swift */; };
131136
DA4FA5BC1DD7DA7700358ABE /* MAdminItemUsers.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA4FA5BB1DD7DA7700358ABE /* MAdminItemUsers.swift */; };
132-
DA5768731DCEB12F00590B5F /* TFDatabaseModelUserStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA5768721DCEB12F00590B5F /* TFDatabaseModelUserStatus.swift */; };
133137
DA6757B21DEF28F6005222B2 /* CStoreAd.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA6757B11DEF28F6005222B2 /* CStoreAd.swift */; };
134138
DA6757B51DEF29C2005222B2 /* VStoreAd.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA6757B41DEF29C2005222B2 /* VStoreAd.swift */; };
135139
DA6757B81DEF39F1005222B2 /* MStoreAd.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA6757B71DEF39F1005222B2 /* MStoreAd.swift */; };
@@ -223,6 +227,7 @@
223227
DAC98D4B1DDBDDF40074E16A /* VStoreCellNew.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAC98D4A1DDBDDF40074E16A /* VStoreCellNew.swift */; };
224228
DAC98D4D1DDBDDFF0074E16A /* VStoreCellPurchasing.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAC98D4C1DDBDDFF0074E16A /* VStoreCellPurchasing.swift */; };
225229
DAC98D4F1DDBDE070074E16A /* VStoreCellPurchased.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAC98D4E1DDBDE070074E16A /* VStoreCellPurchased.swift */; };
230+
DAC99A071DF0F40D0031FEDF /* TFDatabaseModelPhoto.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAC99A061DF0F40D0031FEDF /* TFDatabaseModelPhoto.swift */; };
226231
DACD1F871DC3A0020067D26B /* CHome.swift in Sources */ = {isa = PBXBuildFile; fileRef = DACD1F861DC3A0020067D26B /* CHome.swift */; };
227232
DACD1F891DC3A09F0067D26B /* Generic.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DACD1F881DC3A09F0067D26B /* Generic.xcassets */; };
228233
DACD1F8C1DC3AD480067D26B /* CLogin.swift in Sources */ = {isa = PBXBuildFile; fileRef = DACD1F8B1DC3AD480067D26B /* CLogin.swift */; };
@@ -259,8 +264,6 @@
259264
DAD237571DDD1CAE00BF52C3 /* MAdminServerItemPlus.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAD237561DDD1CAE00BF52C3 /* MAdminServerItemPlus.swift */; };
260265
DAD237591DDD1D7F00BF52C3 /* VAdminServerCellPlus.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAD237581DDD1D7F00BF52C3 /* VAdminServerCellPlus.swift */; };
261266
DAD739591DD0E35700FC3297 /* TFDatabaseModelUserDiskUsed.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAD739581DD0E35700FC3297 /* TFDatabaseModelUserDiskUsed.swift */; };
262-
DAD7395B1DD0E47E00FC3297 /* TFDatabaseModelPicture.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAD7395A1DD0E47E00FC3297 /* TFDatabaseModelPicture.swift */; };
263-
DAD7395D1DD0EE9F00FC3297 /* TFDatabaseModelPictureList.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAD7395C1DD0EE9F00FC3297 /* TFDatabaseModelPictureList.swift */; };
264267
DAD7395F1DD0F70900FC3297 /* TFDatabaseModelServer.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAD7395E1DD0F70900FC3297 /* TFDatabaseModelServer.swift */; };
265268
DAD7398C1DD1571700FC3297 /* VSettingsCellAbout.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAD7398B1DD1571700FC3297 /* VSettingsCellAbout.swift */; };
266269
DAD7398E1DD1597B00FC3297 /* MSettingsItemAbout.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAD7398D1DD1597B00FC3297 /* MSettingsItemAbout.swift */; };
@@ -327,6 +330,11 @@
327330
DA0586811DEC898200651619 /* MHomeUploadHeaderItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MHomeUploadHeaderItem.swift; sourceTree = "<group>"; };
328331
DA0586831DEC8A2D00651619 /* MHomeUploadHeaderItemAlbum.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MHomeUploadHeaderItemAlbum.swift; sourceTree = "<group>"; };
329332
DA09B6611DE5151200654C2E /* VPhotosAlbumCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VPhotosAlbumCell.swift; sourceTree = "<group>"; };
333+
DA14D6371DF1CDC4001E8022 /* TFDatabaseModelPhotoList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TFDatabaseModelPhotoList.swift; sourceTree = "<group>"; };
334+
DA14D6391DF1D353001E8022 /* TFDatabaseModelUserList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TFDatabaseModelUserList.swift; sourceTree = "<group>"; };
335+
DA14D63B1DF1D856001E8022 /* TFDatabaseModelUserSession.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TFDatabaseModelUserSession.swift; sourceTree = "<group>"; };
336+
DA14D63D1DF1FFAC001E8022 /* TFDatabaseModelAlbum.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TFDatabaseModelAlbum.swift; sourceTree = "<group>"; };
337+
DA14D63F1DF20E7D001E8022 /* TFDatabaseModelAlbumList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TFDatabaseModelAlbumList.swift; sourceTree = "<group>"; };
330338
DA1F0E221DC2C6480003AAB8 /* nubecero.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = nubecero.app; sourceTree = BUILT_PRODUCTS_DIR; };
331339
DA1F0E361DC2C6480003AAB8 /* tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
332340
DA25F8E01DCD63A50048DFFE /* TFDatabaseModelUser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TFDatabaseModelUser.swift; sourceTree = "<group>"; };
@@ -443,7 +451,6 @@
443451
DA4FA5B51DD7D80E00358ABE /* MAdminItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MAdminItem.swift; sourceTree = "<group>"; };
444452
DA4FA5B71DD7DA1300358ABE /* MAdminItemServer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MAdminItemServer.swift; sourceTree = "<group>"; };
445453
DA4FA5BB1DD7DA7700358ABE /* MAdminItemUsers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MAdminItemUsers.swift; sourceTree = "<group>"; };
446-
DA5768721DCEB12F00590B5F /* TFDatabaseModelUserStatus.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TFDatabaseModelUserStatus.swift; sourceTree = "<group>"; };
447454
DA6757B11DEF28F6005222B2 /* CStoreAd.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CStoreAd.swift; sourceTree = "<group>"; };
448455
DA6757B41DEF29C2005222B2 /* VStoreAd.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VStoreAd.swift; sourceTree = "<group>"; };
449456
DA6757B71DEF39F1005222B2 /* MStoreAd.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MStoreAd.swift; sourceTree = "<group>"; };
@@ -537,6 +544,7 @@
537544
DAC98D4A1DDBDDF40074E16A /* VStoreCellNew.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VStoreCellNew.swift; sourceTree = "<group>"; };
538545
DAC98D4C1DDBDDFF0074E16A /* VStoreCellPurchasing.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VStoreCellPurchasing.swift; sourceTree = "<group>"; };
539546
DAC98D4E1DDBDE070074E16A /* VStoreCellPurchased.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VStoreCellPurchased.swift; sourceTree = "<group>"; };
547+
DAC99A061DF0F40D0031FEDF /* TFDatabaseModelPhoto.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TFDatabaseModelPhoto.swift; sourceTree = "<group>"; };
540548
DACD1F861DC3A0020067D26B /* CHome.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CHome.swift; sourceTree = "<group>"; };
541549
DACD1F881DC3A09F0067D26B /* Generic.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Generic.xcassets; sourceTree = "<group>"; };
542550
DACD1F8B1DC3AD480067D26B /* CLogin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CLogin.swift; sourceTree = "<group>"; };
@@ -573,8 +581,6 @@
573581
DAD237561DDD1CAE00BF52C3 /* MAdminServerItemPlus.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MAdminServerItemPlus.swift; sourceTree = "<group>"; };
574582
DAD237581DDD1D7F00BF52C3 /* VAdminServerCellPlus.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VAdminServerCellPlus.swift; sourceTree = "<group>"; };
575583
DAD739581DD0E35700FC3297 /* TFDatabaseModelUserDiskUsed.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TFDatabaseModelUserDiskUsed.swift; sourceTree = "<group>"; };
576-
DAD7395A1DD0E47E00FC3297 /* TFDatabaseModelPicture.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TFDatabaseModelPicture.swift; sourceTree = "<group>"; };
577-
DAD7395C1DD0EE9F00FC3297 /* TFDatabaseModelPictureList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TFDatabaseModelPictureList.swift; sourceTree = "<group>"; };
578584
DAD7395E1DD0F70900FC3297 /* TFDatabaseModelServer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TFDatabaseModelServer.swift; sourceTree = "<group>"; };
579585
DAD7398B1DD1571700FC3297 /* VSettingsCellAbout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VSettingsCellAbout.swift; sourceTree = "<group>"; };
580586
DAD7398D1DD1597B00FC3297 /* MSettingsItemAbout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MSettingsItemAbout.swift; sourceTree = "<group>"; };
@@ -811,11 +817,14 @@
811817
isa = PBXGroup;
812818
children = (
813819
DA25F8E01DCD63A50048DFFE /* TFDatabaseModelUser.swift */,
814-
DA5768721DCEB12F00590B5F /* TFDatabaseModelUserStatus.swift */,
820+
DA14D6391DF1D353001E8022 /* TFDatabaseModelUserList.swift */,
815821
DAD739581DD0E35700FC3297 /* TFDatabaseModelUserDiskUsed.swift */,
816-
DAD7395A1DD0E47E00FC3297 /* TFDatabaseModelPicture.swift */,
817-
DAD7395C1DD0EE9F00FC3297 /* TFDatabaseModelPictureList.swift */,
822+
DA14D63B1DF1D856001E8022 /* TFDatabaseModelUserSession.swift */,
818823
DAD7395E1DD0F70900FC3297 /* TFDatabaseModelServer.swift */,
824+
DAC99A061DF0F40D0031FEDF /* TFDatabaseModelPhoto.swift */,
825+
DA14D6371DF1CDC4001E8022 /* TFDatabaseModelPhotoList.swift */,
826+
DA14D63D1DF1FFAC001E8022 /* TFDatabaseModelAlbum.swift */,
827+
DA14D63F1DF20E7D001E8022 /* TFDatabaseModelAlbumList.swift */,
819828
);
820829
path = Model;
821830
sourceTree = "<group>";
@@ -2019,13 +2028,16 @@
20192028
isa = PBXSourcesBuildPhase;
20202029
buildActionMask = 2147483647;
20212030
files = (
2022-
DAD7395B1DD0E47E00FC3297 /* TFDatabaseModelPicture.swift in Sources */,
2031+
DAC99A071DF0F40D0031FEDF /* TFDatabaseModelPhoto.swift in Sources */,
20232032
DAD739591DD0E35700FC3297 /* TFDatabaseModelUserDiskUsed.swift in Sources */,
20242033
DA4FA58A1DD7A4CE00358ABE /* TOnboardFormItemPassGenerator.swift in Sources */,
2025-
DA5768731DCEB12F00590B5F /* TFDatabaseModelUserStatus.swift in Sources */,
2026-
DAD7395D1DD0EE9F00FC3297 /* TFDatabaseModelPictureList.swift in Sources */,
20272034
DAD7395F1DD0F70900FC3297 /* TFDatabaseModelServer.swift in Sources */,
2035+
DA14D63C1DF1D856001E8022 /* TFDatabaseModelUserSession.swift in Sources */,
2036+
DA14D63A1DF1D353001E8022 /* TFDatabaseModelUserList.swift in Sources */,
2037+
DA14D6401DF20E7D001E8022 /* TFDatabaseModelAlbumList.swift in Sources */,
20282038
DA25F8E11DCD63A50048DFFE /* TFDatabaseModelUser.swift in Sources */,
2039+
DA14D63E1DF1FFAC001E8022 /* TFDatabaseModelAlbum.swift in Sources */,
2040+
DA14D6381DF1CDC4001E8022 /* TFDatabaseModelPhotoList.swift in Sources */,
20292041
);
20302042
runOnlyForDeploymentPostprocessing = 0;
20312043
};

nubecero/Firebase/Database/Model/FDatabaseModelAlbum.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ class FDatabaseModelAlbum:FDatabaseModel
2121
super.init()
2222
}
2323

24-
override init()
25-
{
26-
fatalError()
27-
}
28-
2924
required init(snapshot:Any)
3025
{
3126
let snapshotDict:[String:Any]? = snapshot as? [String:Any]
@@ -51,6 +46,11 @@ class FDatabaseModelAlbum:FDatabaseModel
5146
super.init()
5247
}
5348

49+
override init()
50+
{
51+
fatalError()
52+
}
53+
5454
override func modelJson() -> Any
5555
{
5656
let json:[String:Any] = [

nubecero/Model/Session/MSessionUser.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ class MSessionUser
3838

3939
let userJson:Any = modelUser.modelJson()
4040

41-
print(userJson)
42-
4341
FMain.sharedInstance.database.updateChild(
4442
path:userPath,
4543
json:userJson)
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import XCTest
2+
@testable import nubecero
3+
4+
class TFDatabaseModelAlbum:XCTestCase
5+
{
6+
private let kName:String = "a super cool nubecero album"
7+
private let kCreated:TimeInterval = 154423
8+
private let kEmpty:String = ""
9+
private let kNoTime:TimeInterval = 0
10+
11+
func testInitName()
12+
{
13+
let currentTime:TimeInterval = NSDate().timeIntervalSince1970
14+
15+
let keyName:String = FDatabaseModelAlbum.Property.name.rawValue
16+
let keyCreated:String = FDatabaseModelAlbum.Property.created.rawValue
17+
let model:FDatabaseModelAlbum = FDatabaseModelAlbum(
18+
name:kName)
19+
20+
XCTAssertEqual(
21+
model.name,
22+
kName,
23+
"Error storing name")
24+
25+
XCTAssertGreaterThanOrEqual(
26+
model.created,
27+
currentTime,
28+
"Error created should be higher than current time")
29+
30+
let modelJson:[String:Any]? = model.modelJson() as? [String:Any]
31+
32+
XCTAssertNotNil(
33+
modelJson,
34+
"Error json is nil")
35+
36+
let jsonCreated:TimeInterval? = modelJson?[keyCreated] as? TimeInterval
37+
let jsonName:String? = modelJson?[keyName] as? String
38+
39+
XCTAssertGreaterThanOrEqual(
40+
jsonCreated!,
41+
currentTime,
42+
"Error json created")
43+
44+
XCTAssertEqual(
45+
jsonName,
46+
kName,
47+
"Error json name")
48+
}
49+
50+
func testInitSnapshot()
51+
{
52+
let keyName:String = FDatabaseModelAlbum.Property.name.rawValue
53+
let keyCreated:String = FDatabaseModelAlbum.Property.created.rawValue
54+
55+
let snapshot:[String:Any] = [
56+
keyName:kName,
57+
keyCreated:kCreated
58+
]
59+
60+
let model:FDatabaseModelAlbum = FDatabaseModelAlbum(
61+
snapshot:snapshot)
62+
63+
XCTAssertEqual(
64+
model.name,
65+
kName,
66+
"Error storing name")
67+
68+
XCTAssertGreaterThanOrEqual(
69+
model.created,
70+
kCreated,
71+
"Error storing created")
72+
}
73+
74+
func testInitNil()
75+
{
76+
let snapshot:Any? = nil
77+
78+
let model:FDatabaseModelAlbum = FDatabaseModelAlbum(
79+
snapshot:snapshot)
80+
81+
XCTAssertEqual(
82+
model.name,
83+
kEmpty,
84+
"Error empty name")
85+
86+
XCTAssertGreaterThanOrEqual(
87+
model.created,
88+
kNoTime,
89+
"Error no created")
90+
}
91+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import XCTest
2+
@testable import nubecero
3+
4+
class TFDatabaseModelAlbumList:XCTestCase
5+
{
6+
private let kAlbumIdA:MPhotos.AlbumId = "album a"
7+
private let kAlbumIdB:MPhotos.AlbumId = "album b"
8+
private let kAlbumIdC:MPhotos.AlbumId = "album c"
9+
private let kEmpty:Any = ""
10+
private let kCreated:TimeInterval = 123456
11+
private let kNoAlbums:Int = 0
12+
13+
func testInitSnapshot()
14+
{
15+
let keyCreated:String = FDatabaseModelAlbum.Property.created.rawValue
16+
17+
let snapshot:[MSession.UserId:Any] = [
18+
kAlbumIdA:[
19+
keyCreated:kCreated
20+
]
21+
]
22+
23+
let model:FDatabaseModelAlbumList = FDatabaseModelAlbumList(
24+
snapshot:snapshot)
25+
26+
XCTAssertNotNil(
27+
model.items.first,
28+
"Error parsing first item")
29+
30+
XCTAssertNotNil(
31+
model.items[kAlbumIdA],
32+
"Error parsing first item")
33+
34+
XCTAssertEqual(
35+
model.items[kAlbumIdA]!.created,
36+
kCreated,
37+
"Error parsing album properties")
38+
}
39+
40+
func testInitSnapshotEmpty()
41+
{
42+
let snapshot:[MSession.UserId:Any] = [
43+
kAlbumIdA:kEmpty,
44+
kAlbumIdB:kEmpty,
45+
kAlbumIdC:kEmpty
46+
]
47+
48+
let model:FDatabaseModelAlbumList = FDatabaseModelAlbumList(
49+
snapshot:snapshot)
50+
51+
let snapshotKeys:[MSession.UserId] = Array(snapshot.keys)
52+
let countAlbums:Int = model.items.count
53+
let countSnapshotKeys:Int = snapshotKeys.count
54+
55+
XCTAssertEqual(
56+
countSnapshotKeys,
57+
countAlbums,
58+
"Not the same amount of items parsed")
59+
}
60+
61+
func testInitSnapshotNil()
62+
{
63+
let snapshot:Any = kEmpty
64+
65+
let model:FDatabaseModelUserList = FDatabaseModelUserList(
66+
snapshot:snapshot)
67+
68+
let countAlbums:Int = model.items.count
69+
70+
XCTAssertEqual(
71+
countAlbums,
72+
kNoAlbums,
73+
"albums should be empty")
74+
}
75+
}

0 commit comments

Comments
 (0)