Browse Source

Add some equality tests.

pull/92/head
Abhishek 4 years ago
parent
commit
ec857c35c1
  1. 2
      Clocker/Clocker.xcodeproj/project.pbxproj
  2. 54
      Clocker/ClockerUnitTests/TimezoneDataEqualityTests.swift

2
Clocker/Clocker.xcodeproj/project.pbxproj

@ -83,6 +83,7 @@
35C36FA12259ED6D002FA5C6 /* EventCenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35C36F9E2259ED6D002FA5C6 /* EventCenter.swift */; };
35C36FA22259ED6D002FA5C6 /* RemindersHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35C36F9F2259ED6D002FA5C6 /* RemindersHandler.swift */; };
35C36FA42259EEC2002FA5C6 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35C36FA32259EEC2002FA5C6 /* AppDelegate.swift */; };
35EB537325310FD200311068 /* TimezoneDataEqualityTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3545C52A22612BCC00121E25 /* TimezoneDataEqualityTests.swift */; };
35F14BDE25073E4C0052B240 /* Keys.plist in Resources */ = {isa = PBXBuildFile; fileRef = 35F14BDD25073E4C0052B240 /* Keys.plist */; };
9A0A1C8C20903DBD0012003B /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A9E87651C1FEDC500A7A2DF /* CoreLocation.framework */; };
9A13BAD61CA87F08007C6CBE /* Panel.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9A13BAD81CA87F08007C6CBE /* Panel.xib */; };
@ -1178,6 +1179,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
35EB537325310FD200311068 /* TimezoneDataEqualityTests.swift in Sources */,
C20839CA21515C1E00C86589 /* ClockerUnitTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;

54
Clocker/ClockerUnitTests/TimezoneDataEqualityTests.swift

@ -15,13 +15,55 @@ class TimezoneDataEqualityTests: XCTestCase {
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
func testEqualityWhenTimezones() {
func testEqualityWhenTimezoneIdentifiersDiffer() {
let timezone1 = TimezoneData()
timezone1.setLabel(CLEmptyString)
timezone1.timezoneID = metaInfo.0.name
timezone1.formattedAddress = TimeZone.system.identifer
timezone1.selectionType = .timezone
timezone1.timezoneID = TimeZone.autoupdatingCurrent.identifier
timezone1.formattedAddress = "SameLabel"
XCTAssert(timezone1 != nil)
let timezone2 = TimezoneData()
timezone2.timezoneID = "Africa/Banjul"
timezone2.formattedAddress = "SameLabel"
XCTAssertNotEqual(timezone1, timezone2)
}
func testEqualityWhenTimezonesLabelsDiffer() {
let timezone1 = TimezoneData()
timezone1.timezoneID = TimeZone.autoupdatingCurrent.identifier
timezone1.formattedAddress = "SameLabel"
let timezone2 = TimezoneData()
timezone2.timezoneID = TimeZone.autoupdatingCurrent.identifier
timezone2.formattedAddress = "DifferentLabel"
XCTAssertNotEqual(timezone1, timezone2)
}
func testEqualityWhenTimezonesPlaceIDsAreSame() {
let timezone1 = TimezoneData()
timezone1.timezoneID = TimeZone.autoupdatingCurrent.identifier
timezone1.placeID = "SamplePlaceID"
timezone1.formattedAddress = "SameLabel"
let timezone2 = TimezoneData()
timezone2.placeID = "SamplePlaceID"
timezone2.timezoneID = TimeZone.autoupdatingCurrent.identifier
timezone2.formattedAddress = "DifferentLabel"
XCTAssertEqual(timezone1, timezone2)
}
func testEqualityWhenTimezonesPlaceIDsDiffer() {
let timezone1 = TimezoneData()
timezone1.timezoneID = TimeZone.autoupdatingCurrent.identifier
timezone1.placeID = "SamplePlaceID1"
timezone1.formattedAddress = "SameLabel"
let timezone2 = TimezoneData()
timezone2.placeID = "SamplePlaceID2"
timezone2.timezoneID = TimeZone.autoupdatingCurrent.identifier
timezone2.formattedAddress = "DifferentLabel"
XCTAssertNotEqual(timezone1, timezone2)
}
}

Loading…
Cancel
Save