From ec857c35c10ae5200f44d9877967db5d1076f31a Mon Sep 17 00:00:00 2001 From: Abhishek Date: Fri, 9 Oct 2020 16:49:29 -0500 Subject: [PATCH] Add some equality tests. --- Clocker/Clocker.xcodeproj/project.pbxproj | 2 + .../TimezoneDataEqualityTests.swift | 54 ++++++++++++++++--- 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/Clocker/Clocker.xcodeproj/project.pbxproj b/Clocker/Clocker.xcodeproj/project.pbxproj index 81e371d..0e5b080 100755 --- a/Clocker/Clocker.xcodeproj/project.pbxproj +++ b/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; diff --git a/Clocker/ClockerUnitTests/TimezoneDataEqualityTests.swift b/Clocker/ClockerUnitTests/TimezoneDataEqualityTests.swift index 5059ec7..e7773d5 100644 --- a/Clocker/ClockerUnitTests/TimezoneDataEqualityTests.swift +++ b/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) } }