From 78b0182b555f913f8f4796d666e5effadeaff6a1 Mon Sep 17 00:00:00 2001 From: Dave Gallagher Date: Thu, 29 Mar 2018 13:11:53 -0700 Subject: [PATCH 1/3] - Migrated from flatMap to compactMap. - Fixed a failing test in CustomFieldsContainerTests. --- QuizTrain/Network/API.swift | 2 +- QuizTrain/Network/Filters/Filter.Value.swift | 2 +- QuizTrain/Network/ObjectAPI.swift | 8 ++++---- .../Containers/CustomFieldsContainerTests.swift | 8 ++++---- QuizTrainTests/Network/ObjectAPITests.swift | 10 +++++----- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/QuizTrain/Network/API.swift b/QuizTrain/Network/API.swift index c4a608e..4d23ca3 100644 --- a/QuizTrain/Network/API.swift +++ b/QuizTrain/Network/API.swift @@ -202,7 +202,7 @@ final public class API { } if let filters = filters { - _ = filters.flatMap { queryItems.append($0.queryItem) } + _ = filters.compactMap { queryItems.append($0.queryItem) } } return get("get_cases/\(projectId)", queryItems: queryItems, completionHandler: completionHandler) diff --git a/QuizTrain/Network/Filters/Filter.Value.swift b/QuizTrain/Network/Filters/Filter.Value.swift index 77a2ae4..403a86d 100644 --- a/QuizTrain/Network/Filters/Filter.Value.swift +++ b/QuizTrain/Network/Filters/Filter.Value.swift @@ -50,7 +50,7 @@ extension Filter.Value { case .int(let int): return String(int) case .intList(let intList): - return intList.flatMap({String($0)}).joined(separator: ",") // [38, 208, 21, 324] ---> "38,208,21,324" + return intList.compactMap({String($0)}).joined(separator: ",") // [38, 208, 21, 324] ---> "38,208,21,324" case .timestamp(let date): return String(date.secondsSince1970) // Unix Timestamp as a whole number } diff --git a/QuizTrain/Network/ObjectAPI.swift b/QuizTrain/Network/ObjectAPI.swift index c26de74..eb6fcfb 100644 --- a/QuizTrain/Network/ObjectAPI.swift +++ b/QuizTrain/Network/ObjectAPI.swift @@ -1032,10 +1032,10 @@ extension ObjectAPI { completionHandler(.failed(ErrorContainer(error))) case .succeeded(let projects): - let projectIds = Set(projects.flatMap({ $0.id })) + let projectIds = Set(projects.compactMap({ $0.id })) self?.getConfigurationGroups(inProjectsWithIds: projectIds) { (configurationGroupsOutcomes) in - let outcomes = configurationGroupsOutcomes.flatMap { $1 } // Discard projectId keys. + let outcomes = configurationGroupsOutcomes.compactMap { $1 } // Discard projectId keys. var allConfigurationGroups = [ConfigurationGroup]() var allErrors = [GetError]() @@ -2234,10 +2234,10 @@ extension ObjectAPI { completionHandler(.failed(ErrorContainer(error))) case .succeeded(let projects): - let projectIds = Set(projects.flatMap({ $0.id })) + let projectIds = Set(projects.compactMap({ $0.id })) self?.getTemplates(inProjectsWithIds: projectIds) { (templatesOutcomes) in - let outcomes = templatesOutcomes.flatMap { $1 } // Discard projectId keys. + let outcomes = templatesOutcomes.compactMap { $1 } // Discard projectId keys. var allTemplates = [Template]() var allErrors = [GetError]() diff --git a/QuizTrainTests/Misc/Containment/Containers/CustomFieldsContainerTests.swift b/QuizTrainTests/Misc/Containment/Containers/CustomFieldsContainerTests.swift index 557c7aa..267e909 100644 --- a/QuizTrainTests/Misc/Containment/Containers/CustomFieldsContainerTests.swift +++ b/QuizTrainTests/Misc/Containment/Containers/CustomFieldsContainerTests.swift @@ -120,7 +120,7 @@ class CustomFieldsContainerTests: XCTestCase { objectB.customFields.removeValue(forKey: "custom_addingANewCustomField") XCTAssertEqual(objectA, objectB) - let key = customFieldsKeys.first! + let key = customFieldsKeys.sorted().first! objectB.customFields[key] = "New Value" XCTAssertNotEqual(objectA, objectB) objectB.customFields[key] = customFields[key] @@ -149,7 +149,7 @@ class CustomFieldsContainerTests: XCTestCase { // Overwrite var objectC = Object(json: customFields) - let key = customFieldsKeys.first! + let key = customFieldsKeys.sorted().first! objectC.customFields[key] = "New Value" XCTAssertEqual(objectC.customFields.count, customFields.count) @@ -183,7 +183,7 @@ class CustomFieldsContainerTests: XCTestCase { func testRemovingCustomFields() { var object = Object(json: customFields) - let key = customFieldsKeys.first! + let key = customFieldsKeys.sorted().first! object.customFields.removeValue(forKey: key) @@ -194,7 +194,7 @@ class CustomFieldsContainerTests: XCTestCase { func testRemovingAndAddingCustomFields() { var object = Object(json: customFields) - let key = customFieldsKeys.first! + let key = customFieldsKeys.sorted().first! let value = object.customFields[key]! object.customFields.removeValue(forKey: key) diff --git a/QuizTrainTests/Network/ObjectAPITests.swift b/QuizTrainTests/Network/ObjectAPITests.swift index f5f1504..f5c9506 100644 --- a/QuizTrainTests/Network/ObjectAPITests.swift +++ b/QuizTrainTests/Network/ObjectAPITests.swift @@ -428,7 +428,7 @@ extension ObjectAPITests { let suiteCaseIds = testProject.cases.filter { $0.suiteId == suite.id } newPlanEntry.assignedtoId = testProject.user.id - newPlanEntry.caseIds = suiteCaseIds.flatMap { $0.id } + newPlanEntry.caseIds = suiteCaseIds.compactMap { $0.id } newPlanEntry.description = "Test Add: Plan Entry Description" newPlanEntry.includeAll = false newPlanEntry.name = "Test Add: Plan Entry Name" @@ -437,7 +437,7 @@ extension ObjectAPITests { var groupedConfigIds = [Int: [Int]]() for i in 0.. Date: Thu, 29 Mar 2018 15:01:53 -0700 Subject: [PATCH 2/3] - Migrated Equatable on models to use Swift 4.1 Conditional Conformance. - Removed Array+ContentComparison and related tests. - Removed Equatable+OptionalArray and related tests. --- QuizTrain.xcodeproj/project.pbxproj | 48 +++---------------- .../Containers/CustomFieldsContainer.swift | 10 +--- .../Extensions/Array+ContentComparison.swift | 47 ------------------ .../Extensions/Equatable+OptionalArray.swift | 13 ----- QuizTrain/Models/Case.swift | 27 +---------- QuizTrain/Models/CaseField.swift | 22 +-------- QuizTrain/Models/CaseType.swift | 14 +----- QuizTrain/Models/Config/Config.Context.swift | 13 +---- QuizTrain/Models/Config/Config.swift | 14 +----- QuizTrain/Models/Configuration.swift | 14 +----- QuizTrain/Models/ConfigurationGroup.swift | 15 +----- QuizTrain/Models/Milestone.swift | 24 +--------- QuizTrain/Models/Plan.Entry.swift | 15 +----- QuizTrain/Models/Plan.swift | 35 +------------- QuizTrain/Models/Priority.swift | 16 +------ QuizTrain/Models/Project.swift | 19 +------- QuizTrain/Models/Result.swift | 22 +-------- QuizTrain/Models/ResultField.swift | 22 +-------- QuizTrain/Models/Run.swift | 39 +-------------- QuizTrain/Models/Section.swift | 18 +------ QuizTrain/Models/Status.swift | 20 +------- QuizTrain/Models/Suite.swift | 20 +------- QuizTrain/Models/Template.swift | 14 +----- QuizTrain/Models/Test.swift | 25 +--------- QuizTrain/Models/Types/CustomFieldType.swift | 2 +- .../Models/Types/Project.SuiteMode.swift | 2 +- QuizTrain/Models/User.swift | 15 +----- QuizTrain/Network/Filters/Filter.Value.swift | 31 +----------- QuizTrain/Network/Filters/Filter.swift | 11 +---- QuizTrain/Network/Models/Add/NewCase.swift | 19 +------- .../Models/Add/NewCaseResults.Result.swift | 19 +------- .../Network/Models/Add/NewCaseResults.swift | 12 +---- .../Network/Models/Add/NewConfiguration.swift | 12 +---- .../Models/Add/NewConfigurationGroup.swift | 12 +---- .../Network/Models/Add/NewMilestone.swift | 16 +------ .../Models/Add/NewPlan.Entry.Run.swift | 19 +------- .../Network/Models/Add/NewPlan.Entry.swift | 19 +------- QuizTrain/Network/Models/Add/NewPlan.swift | 15 +----- QuizTrain/Network/Models/Add/NewProject.swift | 15 +----- QuizTrain/Network/Models/Add/NewResult.swift | 18 +------ QuizTrain/Network/Models/Add/NewRun.swift | 18 +------ QuizTrain/Network/Models/Add/NewSection.swift | 15 +----- QuizTrain/Network/Models/Add/NewSuite.swift | 13 +---- .../Models/Add/NewTestResults.Result.swift | 19 +------- .../Network/Models/Add/NewTestResults.swift | 12 +---- .../Models/Update/UpdatePlanEntryRuns.swift | 15 +----- .../Array+ContentComparisonTests.swift | 42 ---------------- .../Equatable+OptionalArrayTests.swift | 25 ---------- 48 files changed, 49 insertions(+), 873 deletions(-) delete mode 100644 QuizTrain/Misc/Extensions/Array+ContentComparison.swift delete mode 100644 QuizTrain/Misc/Extensions/Equatable+OptionalArray.swift delete mode 100644 QuizTrainTests/Misc/Extensions/Array+ContentComparisonTests.swift delete mode 100644 QuizTrainTests/Misc/Extensions/Equatable+OptionalArrayTests.swift diff --git a/QuizTrain.xcodeproj/project.pbxproj b/QuizTrain.xcodeproj/project.pbxproj index d87fe29..c2608c9 100644 --- a/QuizTrain.xcodeproj/project.pbxproj +++ b/QuizTrain.xcodeproj/project.pbxproj @@ -8,11 +8,7 @@ /* Begin PBXBuildFile section */ FE018DC71F85708C001A2FEF /* ModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE018DC61F85708C001A2FEF /* ModelTests.swift */; }; - FE0B15471FED689F0009B570 /* ObjectAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE6A6D4F1F75956C00DF1039 /* ObjectAPITests.swift */; }; - FE0B15481FED68A00009B570 /* ObjectAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE6A6D4F1F75956C00DF1039 /* ObjectAPITests.swift */; }; - FE0B15491FED68A00009B570 /* ObjectAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE6A6D4F1F75956C00DF1039 /* ObjectAPITests.swift */; }; FE11181C1F6C3A4B00D24A5F /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE11181B1F6C3A4B00D24A5F /* Config.swift */; }; - FE1474D61FAA475A0049DA84 /* Equatable+OptionalArrayTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE1474D51FAA475A0049DA84 /* Equatable+OptionalArrayTests.swift */; }; FE1474DA1FAA698F0049DA84 /* ObjectAPI.RequestErrorDebug.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE1474D91FAA698F0049DA84 /* ObjectAPI.RequestErrorDebug.swift */; }; FE1474DC1FAA69AA0049DA84 /* ObjectAPI.DataRequestErrorDebug.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE1474DB1FAA69AA0049DA84 /* ObjectAPI.DataRequestErrorDebug.swift */; }; FE1474DE1FAA69B70049DA84 /* ObjectAPI.UpdateRequestErrorDebug.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE1474DD1FAA69B70049DA84 /* ObjectAPI.UpdateRequestErrorDebug.swift */; }; @@ -39,6 +35,9 @@ FE23A96F1F59F4D9007E946D /* Template.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE23A96E1F59F4D9007E946D /* Template.swift */; }; FE23A9711F59F4E2007E946D /* Test.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE23A9701F59F4E2007E946D /* Test.swift */; }; FE23A9731F59F4EB007E946D /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE23A9721F59F4EB007E946D /* User.swift */; }; + FE246D79206D9A310003E6C0 /* ObjectAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE6A6D4F1F75956C00DF1039 /* ObjectAPITests.swift */; }; + FE246D7A206D9A310003E6C0 /* ObjectAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE6A6D4F1F75956C00DF1039 /* ObjectAPITests.swift */; }; + FE246D7B206D9A320003E6C0 /* ObjectAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE6A6D4F1F75956C00DF1039 /* ObjectAPITests.swift */; }; FE2877EC1FBB979C004503FB /* ValidatableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE2877EB1FBB979C004503FB /* ValidatableTests.swift */; }; FE2877EE1FBB9803004503FB /* AssertValidatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE2877ED1FBB9803004503FB /* AssertValidatable.swift */; }; FE2877F01FBB9A80004503FB /* ValidatableObjectProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE2877EF1FBB9A80004503FB /* ValidatableObjectProvider.swift */; }; @@ -87,7 +86,6 @@ FE549C421FBE5147008CDFCE /* NewPlanTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE3795B71FA799520030C395 /* NewPlanTests.swift */; }; FE549C431FBE514A008CDFCE /* NewPlan.EntryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE3795B91FA7996F0030C395 /* NewPlan.EntryTests.swift */; }; FE549C441FBE514C008CDFCE /* NewPlan.Entry.RunTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE64D1571FBD0C3700ABA133 /* NewPlan.Entry.RunTests.swift */; }; - FE549C461FBE60F3008CDFCE /* Array+ContentComparisonTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE549C451FBE60F3008CDFCE /* Array+ContentComparisonTests.swift */; }; FE5869D71F7478D600BE5C5C /* CustomFields.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE5869D61F7478D600BE5C5C /* CustomFields.swift */; }; FE58F5481F7EBF04009A1B4E /* AssertProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE58F5471F7EBF04009A1B4E /* AssertProperties.swift */; }; FE58F54A1F7EBF12009A1B4E /* AssertCustomFields.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE58F5491F7EBF12009A1B4E /* AssertCustomFields.swift */; }; @@ -120,7 +118,6 @@ FE75B2E01F83078A00DF367A /* CustomFieldsContainerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE22458B1F75BECC009F2B2B /* CustomFieldsContainerTests.swift */; }; FE77BB761FA9132800E23865 /* NewRunTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE3795C31FA799D10030C395 /* NewRunTests.swift */; }; FE791A251F7D9FFA00D7E870 /* Project.SuiteModeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE791A241F7D9FFA00D7E870 /* Project.SuiteModeTests.swift */; }; - FE7B53931FBF5BB1003C26BD /* Array+ContentComparison.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE7B53921FBF5BB1003C26BD /* Array+ContentComparison.swift */; }; FE7CD3E41F9ABDC300C6108E /* NewPlan.Entry.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE7CD3E31F9ABDC300C6108E /* NewPlan.Entry.swift */; }; FE813A181F73126F00265569 /* JSONDictionary.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE813A171F73126F00265569 /* JSONDictionary.swift */; }; FE8C2D5A1FBA391F005A4150 /* Date+Seconds.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE8C2D591FBA391F005A4150 /* Date+Seconds.swift */; }; @@ -167,16 +164,9 @@ FEAE99B31FEC42EC00B52CA9 /* MultipleMatchError.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEDFF2761FE1B0A000AEB3D6 /* MultipleMatchError.swift */; }; FEAE99B41FEC42ED00B52CA9 /* MultipleMatchError.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEDFF2761FE1B0A000AEB3D6 /* MultipleMatchError.swift */; }; FEAE99B61FEC42EE00B52CA9 /* MultipleMatchError.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEDFF2761FE1B0A000AEB3D6 /* MultipleMatchError.swift */; }; - FEAE99B71FEC42F100B52CA9 /* Array+ContentComparison.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE7B53921FBF5BB1003C26BD /* Array+ContentComparison.swift */; }; - FEAE99B81FEC42F200B52CA9 /* Array+ContentComparison.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE7B53921FBF5BB1003C26BD /* Array+ContentComparison.swift */; }; - FEAE99BA1FEC42F300B52CA9 /* Array+ContentComparison.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE7B53921FBF5BB1003C26BD /* Array+ContentComparison.swift */; }; FEAE99BB1FEC42F500B52CA9 /* Date+Seconds.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE8C2D591FBA391F005A4150 /* Date+Seconds.swift */; }; FEAE99BC1FEC42F600B52CA9 /* Date+Seconds.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE8C2D591FBA391F005A4150 /* Date+Seconds.swift */; }; FEAE99BD1FEC42F700B52CA9 /* Date+Seconds.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE8C2D591FBA391F005A4150 /* Date+Seconds.swift */; }; - FEAE99BE1FEC42FA00B52CA9 /* Equatable+OptionalArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE2E774A1F85923F00EF5E54 /* Equatable+OptionalArray.swift */; }; - FEAE99BF1FEC42FA00B52CA9 /* Equatable+OptionalArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE2E774A1F85923F00EF5E54 /* Equatable+OptionalArray.swift */; }; - FEAE99C01FEC42FB00B52CA9 /* Equatable+OptionalArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE2E774A1F85923F00EF5E54 /* Equatable+OptionalArray.swift */; }; - FEAE99C11FEC42FC00B52CA9 /* Equatable+OptionalArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE2E774A1F85923F00EF5E54 /* Equatable+OptionalArray.swift */; }; FEAE99C21FEC42FE00B52CA9 /* Identifiable.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE20D03E1FD876820057A45C /* Identifiable.swift */; }; FEAE99C31FEC42FF00B52CA9 /* Identifiable.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE20D03E1FD876820057A45C /* Identifiable.swift */; }; FEAE99C41FEC430000B52CA9 /* Identifiable.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE20D03E1FD876820057A45C /* Identifiable.swift */; }; @@ -449,12 +439,8 @@ FEAE9AD01FEC500200B52CA9 /* CustomFieldsContainerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE22458B1F75BECC009F2B2B /* CustomFieldsContainerTests.swift */; }; FEAE9AD11FEC500200B52CA9 /* ErrorContainerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEC2140A1FD7533000036B17 /* ErrorContainerTests.swift */; }; FEAE9AD21FEC500200B52CA9 /* JSONDictionaryContainerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE51EFA11F882454007012E0 /* JSONDictionaryContainerTests.swift */; }; - FEAE9AD31FEC500600B52CA9 /* Array+ContentComparisonTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE549C451FBE60F3008CDFCE /* Array+ContentComparisonTests.swift */; }; FEAE9AD41FEC500600B52CA9 /* Array+RandomTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FECFE7FE1FD9E1AE00968EA3 /* Array+RandomTests.swift */; }; - FEAE9AD51FEC500600B52CA9 /* Equatable+OptionalArrayTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE1474D51FAA475A0049DA84 /* Equatable+OptionalArrayTests.swift */; }; - FEAE9AD61FEC500700B52CA9 /* Array+ContentComparisonTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE549C451FBE60F3008CDFCE /* Array+ContentComparisonTests.swift */; }; FEAE9AD71FEC500700B52CA9 /* Array+RandomTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FECFE7FE1FD9E1AE00968EA3 /* Array+RandomTests.swift */; }; - FEAE9AD81FEC500700B52CA9 /* Equatable+OptionalArrayTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE1474D51FAA475A0049DA84 /* Equatable+OptionalArrayTests.swift */; }; FEAE9AD91FEC500900B52CA9 /* AsyncOperationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEC2140D1FD7537800036B17 /* AsyncOperationTests.swift */; }; FEAE9ADA1FEC500A00B52CA9 /* AsyncOperationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEC2140D1FD7537800036B17 /* AsyncOperationTests.swift */; }; FEAE9ADB1FEC500D00B52CA9 /* ModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE018DC61F85708C001A2FEF /* ModelTests.swift */; }; @@ -619,7 +605,6 @@ FE09FFB31FE320CA0009FB2F /* .swiftlint.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = .swiftlint.yml; sourceTree = ""; }; FE09FFCF1FE325CE0009FB2F /* .gitignore */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitignore; sourceTree = ""; }; FE11181B1F6C3A4B00D24A5F /* Config.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Config.swift; sourceTree = ""; }; - FE1474D51FAA475A0049DA84 /* Equatable+OptionalArrayTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Equatable+OptionalArrayTests.swift"; sourceTree = ""; }; FE1474D91FAA698F0049DA84 /* ObjectAPI.RequestErrorDebug.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjectAPI.RequestErrorDebug.swift; sourceTree = ""; }; FE1474DB1FAA69AA0049DA84 /* ObjectAPI.DataRequestErrorDebug.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjectAPI.DataRequestErrorDebug.swift; sourceTree = ""; }; FE1474DD1FAA69B70049DA84 /* ObjectAPI.UpdateRequestErrorDebug.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjectAPI.UpdateRequestErrorDebug.swift; sourceTree = ""; }; @@ -666,7 +651,6 @@ FE2877EF1FBB9A80004503FB /* ValidatableObjectProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ValidatableObjectProvider.swift; sourceTree = ""; }; FE2877F91FBBC47B004503FB /* FilterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FilterTests.swift; sourceTree = ""; }; FE2D018A1FBCE70B00473B84 /* NewPlan.Entry.Run.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewPlan.Entry.Run.swift; sourceTree = ""; }; - FE2E774A1F85923F00EF5E54 /* Equatable+OptionalArray.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Equatable+OptionalArray.swift"; sourceTree = ""; }; FE2F1AD61F844FCD00FF9E0C /* JSONSerializable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONSerializable.swift; sourceTree = ""; }; FE30A6521F7C261400CE7D6B /* Plan.EntryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Plan.EntryTests.swift; sourceTree = ""; }; FE331C1B1F6B406300F9A653 /* CustomFieldType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomFieldType.swift; sourceTree = ""; }; @@ -703,7 +687,6 @@ FE4F8F3A1F8437DE00447F9E /* JSONDeserializable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONDeserializable.swift; sourceTree = ""; }; FE51EFA11F882454007012E0 /* JSONDictionaryContainerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONDictionaryContainerTests.swift; sourceTree = ""; }; FE5259111F82D1AD00E0DDB7 /* JSONKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONKey.swift; sourceTree = ""; }; - FE549C451FBE60F3008CDFCE /* Array+ContentComparisonTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Array+ContentComparisonTests.swift"; sourceTree = ""; }; FE5869D61F7478D600BE5C5C /* CustomFields.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomFields.swift; sourceTree = ""; }; FE58F5471F7EBF04009A1B4E /* AssertProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AssertProperties.swift; sourceTree = ""; }; FE58F5491F7EBF12009A1B4E /* AssertCustomFields.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AssertCustomFields.swift; sourceTree = ""; }; @@ -738,7 +721,6 @@ FE6A6D4F1F75956C00DF1039 /* ObjectAPITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjectAPITests.swift; sourceTree = ""; }; FE6C8AE11F8BEA2E00F45642 /* MutableCustomFields.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MutableCustomFields.swift; sourceTree = ""; }; FE791A241F7D9FFA00D7E870 /* Project.SuiteModeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Project.SuiteModeTests.swift; sourceTree = ""; }; - FE7B53921FBF5BB1003C26BD /* Array+ContentComparison.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Array+ContentComparison.swift"; sourceTree = ""; }; FE7CD3E31F9ABDC300C6108E /* NewPlan.Entry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewPlan.Entry.swift; sourceTree = ""; }; FE813A171F73126F00265569 /* JSONDictionary.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONDictionary.swift; sourceTree = ""; }; FE8464621FE307B1006CB58F /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; @@ -884,9 +866,7 @@ FE1474D71FAA484D0049DA84 /* Extensions */ = { isa = PBXGroup; children = ( - FE7B53921FBF5BB1003C26BD /* Array+ContentComparison.swift */, FE8C2D591FBA391F005A4150 /* Date+Seconds.swift */, - FE2E774A1F85923F00EF5E54 /* Equatable+OptionalArray.swift */, ); path = Extensions; sourceTree = ""; @@ -894,9 +874,7 @@ FE1474D81FAA48900049DA84 /* Extensions */ = { isa = PBXGroup; children = ( - FE549C451FBE60F3008CDFCE /* Array+ContentComparisonTests.swift */, FECFE7FE1FD9E1AE00968EA3 /* Array+RandomTests.swift */, - FE1474D51FAA475A0049DA84 /* Equatable+OptionalArrayTests.swift */, ); path = Extensions; sourceTree = ""; @@ -1815,7 +1793,6 @@ FE20D03F1FD876820057A45C /* Identifiable.swift in Sources */, FECF66701FDF05DB00015CC4 /* GetProjectOperation.swift in Sources */, FEDCBEFF1F96BF730083AD46 /* NewSuite.swift in Sources */, - FE7B53931FBF5BB1003C26BD /* Array+ContentComparison.swift in Sources */, FEAE7F921F7C5ABE00906FE1 /* Config.Context.swift in Sources */, FED295471FA10E9300746DAB /* Status.swift in Sources */, FE3899171FCF2BDE0032E265 /* GetTemplatesOperation.swift in Sources */, @@ -1849,7 +1826,6 @@ FE6989211FA39B99006CC783 /* UpdatePlanEntryRuns.swift in Sources */, FE23A96B1F59F4C3007E946D /* Section.swift in Sources */, FE978CED1F9532BA0005D181 /* URLRequestDebug.swift in Sources */, - FEAE99C01FEC42FB00B52CA9 /* Equatable+OptionalArray.swift in Sources */, FE331C1A1F6B3C0200F9A653 /* Case.swift in Sources */, FEB546881F9170A900AA6DA5 /* Outcome.swift in Sources */, FE208DEB1FBB69B80065BE88 /* NewTestResults.Result.swift in Sources */, @@ -1886,7 +1862,6 @@ FECFE7FF1FD9E1AE00968EA3 /* Array+RandomTests.swift in Sources */, FE3795B21FA799270030C395 /* NewConfigurationTests.swift in Sources */, FE3795AA1FA7915C0030C395 /* AssertUpdateRequestJSON.swift in Sources */, - FE1474D61FAA475A0049DA84 /* Equatable+OptionalArrayTests.swift in Sources */, FE3795C21FA799B70030C395 /* NewTestResults.ResultTests.swift in Sources */, FE3795E41FA7E1770030C395 /* NewCaseTests.swift in Sources */, FEF172631F857F53004FFFFF /* AssertJSONSerializing.swift in Sources */, @@ -1901,6 +1876,7 @@ FE549C431FBE514A008CDFCE /* NewPlan.EntryTests.swift in Sources */, FE3795D61FA7C7B60030C395 /* JSONSerializingTests.swift in Sources */, FE6A6D271F75908100DF1039 /* CaseTests.swift in Sources */, + FE246D79206D9A310003E6C0 /* ObjectAPITests.swift in Sources */, FE5A24F41FE099BD00198848 /* Array+Random.swift in Sources */, FEC2140E1FD7537800036B17 /* AsyncOperationTests.swift in Sources */, FE2877FA1FBBC47B004503FB /* FilterTests.swift in Sources */, @@ -1927,7 +1903,6 @@ FE3795BE1FA7999C0030C395 /* NewResultTests.swift in Sources */, FE549C421FBE5147008CDFCE /* NewPlanTests.swift in Sources */, FE6A6D371F7590E500DF1039 /* ResultTests.swift in Sources */, - FE549C461FBE60F3008CDFCE /* Array+ContentComparisonTests.swift in Sources */, FE77BB761FA9132800E23865 /* NewRunTests.swift in Sources */, FE58F5481F7EBF04009A1B4E /* AssertProperties.swift in Sources */, FE3795D81FA7C7D00030C395 /* JSONTwoWaySerializationTests.swift in Sources */, @@ -1937,7 +1912,6 @@ FE6A6D3F1F75910E00DF1039 /* TemplateTests.swift in Sources */, FEF172661F858880004FFFFF /* AssertJSONTwoWaySerialization.swift in Sources */, FE496B5F1F7D9BCF00AE9454 /* ResultFieldTests.swift in Sources */, - FE0B15471FED689F0009B570 /* ObjectAPITests.swift in Sources */, FE3795C81FA799F50030C395 /* NewSuiteTests.swift in Sources */, FE2877F41FBBBC50004503FB /* NewCaseResultsTests.swift in Sources */, FECF66761FDF593600015CC4 /* UniqueSelectionTests.swift in Sources */, @@ -1964,7 +1938,6 @@ FEAE9A5A1FEC4F1400B52CA9 /* NewMilestone.swift in Sources */, FEAE9A151FEC4EFA00B52CA9 /* ResultField.swift in Sources */, FEAE9A871FEC4F1800B52CA9 /* UpdatePlanEntryRuns.swift in Sources */, - FEAE99BA1FEC42F300B52CA9 /* Array+ContentComparison.swift in Sources */, FEAE99D71FEC431900B52CA9 /* UpdateRequestJSONKeys.swift in Sources */, FEAE9A3B1FEC4F0A00B52CA9 /* ObjectAPI.UpdateRequestErrorDebug.swift in Sources */, FEAE9A8B1FEC4F1D00B52CA9 /* GetProjectOperation.swift in Sources */, @@ -2007,7 +1980,6 @@ FEAE9A5E1FEC4F1400B52CA9 /* NewProject.swift in Sources */, FEAE9A601FEC4F1400B52CA9 /* NewCaseResults.swift in Sources */, FEAE9A181FEC4EFF00B52CA9 /* Run.swift in Sources */, - FEAE99BE1FEC42FA00B52CA9 /* Equatable+OptionalArray.swift in Sources */, FEAE99CE1FEC430E00B52CA9 /* JSONSerializable.swift in Sources */, FEAE99EA1FEC433100B52CA9 /* Project.SuiteMode.swift in Sources */, FEAE99C51FEC430200B52CA9 /* JSONKey.swift in Sources */, @@ -2056,7 +2028,6 @@ FEAE9A6A1FEC4F1500B52CA9 /* NewMilestone.swift in Sources */, FEAE9A161FEC4EFB00B52CA9 /* ResultField.swift in Sources */, FEAE9A881FEC4F1900B52CA9 /* UpdatePlanEntryRuns.swift in Sources */, - FEAE99B81FEC42F200B52CA9 /* Array+ContentComparison.swift in Sources */, FEAE99D81FEC431900B52CA9 /* UpdateRequestJSONKeys.swift in Sources */, FEAE9A451FEC4F0B00B52CA9 /* ObjectAPI.UpdateRequestErrorDebug.swift in Sources */, FEAE9A901FEC4F1E00B52CA9 /* GetProjectOperation.swift in Sources */, @@ -2099,7 +2070,6 @@ FEAE9A6E1FEC4F1500B52CA9 /* NewProject.swift in Sources */, FEAE9A701FEC4F1500B52CA9 /* NewCaseResults.swift in Sources */, FEAE9A1F1FEC4F0000B52CA9 /* Run.swift in Sources */, - FEAE99BF1FEC42FA00B52CA9 /* Equatable+OptionalArray.swift in Sources */, FEAE99CF1FEC430F00B52CA9 /* JSONSerializable.swift in Sources */, FEAE99EB1FEC433200B52CA9 /* Project.SuiteMode.swift in Sources */, FEAE99C61FEC430300B52CA9 /* JSONKey.swift in Sources */, @@ -2140,7 +2110,6 @@ FEAE9B161FEC501F00B52CA9 /* NewMilestoneTests.swift in Sources */, FEAE9ADA1FEC500A00B52CA9 /* AsyncOperationTests.swift in Sources */, FEAE9B151FEC501F00B52CA9 /* NewConfigurationTests.swift in Sources */, - FEAE9AD31FEC500600B52CA9 /* Array+ContentComparisonTests.swift in Sources */, FEAE9AB81FEC4FF900B52CA9 /* JSONDataProvider.swift in Sources */, FEAE9B1D1FEC501F00B52CA9 /* NewCaseResults.ResultTests.swift in Sources */, FEAE9AEB1FEC501400B52CA9 /* PlanTests.swift in Sources */, @@ -2169,6 +2138,7 @@ FEAE9ACE1FEC500200B52CA9 /* ErrorContainerTests.swift in Sources */, FEAE9B181FEC501F00B52CA9 /* NewPlan.EntryTests.swift in Sources */, FEAE9AB01FEC4FF500B52CA9 /* AssertProperties.swift in Sources */, + FE246D7B206D9A320003E6C0 /* ObjectAPITests.swift in Sources */, FEAE9B201FEC501F00B52CA9 /* NewRunTests.swift in Sources */, FEAE9B131FEC501F00B52CA9 /* NewCaseTests.swift in Sources */, FEAE9ABD1FEC4FFE00B52CA9 /* InitTests.swift in Sources */, @@ -2198,14 +2168,12 @@ FEAE9AF31FEC501400B52CA9 /* StatusTests.swift in Sources */, FEAE9AE91FEC501400B52CA9 /* ConfigurationGroupTests.swift in Sources */, FEAE9B171FEC501F00B52CA9 /* NewPlanTests.swift in Sources */, - FEAE9AD51FEC500600B52CA9 /* Equatable+OptionalArrayTests.swift in Sources */, FEAE9AE81FEC501400B52CA9 /* ConfigurationTests.swift in Sources */, FEAE9ACD1FEC500200B52CA9 /* CustomFieldsContainerTests.swift in Sources */, FEAE9AC31FEC4FFE00B52CA9 /* VariablePropertyTests.swift in Sources */, FEAE9B351FEC502300B52CA9 /* UpdatePlanEntryRunsTests.swift in Sources */, FEAE9AF41FEC501400B52CA9 /* SuiteTests.swift in Sources */, FEAE9AAB1FEC4FF500B52CA9 /* AssertCustomFields.swift in Sources */, - FE0B15491FED68A00009B570 /* ObjectAPITests.swift in Sources */, FEAE9AF71FEC501400B52CA9 /* UserTests.swift in Sources */, FEAE9AF51FEC501400B52CA9 /* TemplateTests.swift in Sources */, FEAE9AB91FEC4FF900B52CA9 /* ObjectProvider.swift in Sources */, @@ -2232,7 +2200,6 @@ FEAE9A7A1FEC4F1500B52CA9 /* NewMilestone.swift in Sources */, FEAE9A171FEC4EFB00B52CA9 /* ResultField.swift in Sources */, FEAE9A891FEC4F1A00B52CA9 /* UpdatePlanEntryRuns.swift in Sources */, - FEAE99B71FEC42F100B52CA9 /* Array+ContentComparison.swift in Sources */, FEAE99DA1FEC431B00B52CA9 /* UpdateRequestJSONKeys.swift in Sources */, FEAE9A4F1FEC4F0B00B52CA9 /* ObjectAPI.UpdateRequestErrorDebug.swift in Sources */, FEAE9A951FEC4F1E00B52CA9 /* GetProjectOperation.swift in Sources */, @@ -2275,7 +2242,6 @@ FEAE9A7E1FEC4F1500B52CA9 /* NewProject.swift in Sources */, FEAE9A801FEC4F1500B52CA9 /* NewCaseResults.swift in Sources */, FEAE9A261FEC4F0000B52CA9 /* Run.swift in Sources */, - FEAE99C11FEC42FC00B52CA9 /* Equatable+OptionalArray.swift in Sources */, FEAE99D01FEC430F00B52CA9 /* JSONSerializable.swift in Sources */, FEAE99EC1FEC433200B52CA9 /* Project.SuiteMode.swift in Sources */, FEAE99C71FEC430300B52CA9 /* JSONKey.swift in Sources */, @@ -2316,7 +2282,6 @@ FEAE9B261FEC502000B52CA9 /* NewMilestoneTests.swift in Sources */, FEAE9AD91FEC500900B52CA9 /* AsyncOperationTests.swift in Sources */, FEAE9B251FEC502000B52CA9 /* NewConfigurationTests.swift in Sources */, - FEAE9AD61FEC500700B52CA9 /* Array+ContentComparisonTests.swift in Sources */, FEAE9AB41FEC4FF800B52CA9 /* JSONDataProvider.swift in Sources */, FEAE9B2D1FEC502000B52CA9 /* NewCaseResults.ResultTests.swift in Sources */, FEAE9B001FEC501400B52CA9 /* PlanTests.swift in Sources */, @@ -2345,6 +2310,7 @@ FEAE9AD11FEC500200B52CA9 /* ErrorContainerTests.swift in Sources */, FEAE9B281FEC502000B52CA9 /* NewPlan.EntryTests.swift in Sources */, FEAE9AA71FEC4FF500B52CA9 /* AssertProperties.swift in Sources */, + FE246D7A206D9A310003E6C0 /* ObjectAPITests.swift in Sources */, FEAE9B301FEC502000B52CA9 /* NewRunTests.swift in Sources */, FEAE9B231FEC502000B52CA9 /* NewCaseTests.swift in Sources */, FEAE9AC61FEC4FFF00B52CA9 /* InitTests.swift in Sources */, @@ -2374,14 +2340,12 @@ FEAE9B081FEC501400B52CA9 /* StatusTests.swift in Sources */, FEAE9AFE1FEC501400B52CA9 /* ConfigurationGroupTests.swift in Sources */, FEAE9B271FEC502000B52CA9 /* NewPlanTests.swift in Sources */, - FEAE9AD81FEC500700B52CA9 /* Equatable+OptionalArrayTests.swift in Sources */, FEAE9AFD1FEC501400B52CA9 /* ConfigurationTests.swift in Sources */, FEAE9AD01FEC500200B52CA9 /* CustomFieldsContainerTests.swift in Sources */, FEAE9ACC1FEC4FFF00B52CA9 /* VariablePropertyTests.swift in Sources */, FEAE9B331FEC502300B52CA9 /* UpdatePlanEntryRunsTests.swift in Sources */, FEAE9B091FEC501400B52CA9 /* SuiteTests.swift in Sources */, FEAE9AA21FEC4FF500B52CA9 /* AssertCustomFields.swift in Sources */, - FE0B15481FED68A00009B570 /* ObjectAPITests.swift in Sources */, FEAE9B0C1FEC501400B52CA9 /* UserTests.swift in Sources */, FEAE9B0A1FEC501400B52CA9 /* TemplateTests.swift in Sources */, FEAE9AB51FEC4FF800B52CA9 /* ObjectProvider.swift in Sources */, diff --git a/QuizTrain/Misc/Containment/Containers/CustomFieldsContainer.swift b/QuizTrain/Misc/Containment/Containers/CustomFieldsContainer.swift index 1c9976c..6cd661f 100644 --- a/QuizTrain/Misc/Containment/Containers/CustomFieldsContainer.swift +++ b/QuizTrain/Misc/Containment/Containers/CustomFieldsContainer.swift @@ -5,7 +5,7 @@ omittedKeys. Any keys violating those rules will be silently omitted from being added to customFields. */ -struct CustomFieldsContainer: JSONDeserializable, JSONSerializable { +struct CustomFieldsContainer: JSONDeserializable, JSONSerializable, Equatable { // MARK: - Properties @@ -50,14 +50,6 @@ struct CustomFieldsContainer: JSONDeserializable, JSONSerializable { } -extension CustomFieldsContainer: Equatable { - - static func==(lhs: CustomFieldsContainer, rhs: CustomFieldsContainer) -> Bool { - return lhs.container == rhs.container - } - -} - extension CustomFieldsContainer { public static func empty() -> CustomFieldsContainer { diff --git a/QuizTrain/Misc/Extensions/Array+ContentComparison.swift b/QuizTrain/Misc/Extensions/Array+ContentComparison.swift deleted file mode 100644 index 8fd4ab8..0000000 --- a/QuizTrain/Misc/Extensions/Array+ContentComparison.swift +++ /dev/null @@ -1,47 +0,0 @@ -extension Array where Array.Element: Equatable { - - /* - For an array of Equatable elements, determines if both contain the same - contents regardless of their ordering. - - let a1 = [1, 2, 2] - let a2 = [2, 2, 1] - let a3 = [1, 1, 2] - - a1 == a2 // false - Array.contentsAreEqual(a1, a2) // true - Array.contentsAreEqual(a1, a3) // false - */ - static func contentsAreEqual(_ lhs: [Array.Element]?, _ rhs: [Array.Element]?) -> Bool { - switch (lhs, rhs) { - case (.some(let l), .some(let r)): - return Array.contentsAreEqual(l, r) - case (.none, .none): - return true - default: - return false - } - } - - private static func contentsAreEqual(_ lhs: [Array.Element], _ rhs: [Array.Element]) -> Bool { - - guard lhs.count == rhs.count else { - return false - } - - var rhsCopy = rhs - for item in lhs { - guard let index = rhsCopy.index(of: item) else { - return false - } - rhsCopy.remove(at: index) - } - - return true - } - - func contentsAreEqual(to array: [Array.Element]?) -> Bool { - return Array.contentsAreEqual(self, array) - } - -} diff --git a/QuizTrain/Misc/Extensions/Equatable+OptionalArray.swift b/QuizTrain/Misc/Extensions/Equatable+OptionalArray.swift deleted file mode 100644 index 5d81b9a..0000000 --- a/QuizTrain/Misc/Extensions/Equatable+OptionalArray.swift +++ /dev/null @@ -1,13 +0,0 @@ -/* - Adds == comparison to optional arrays containing an Equatable type. - */ -func ==(lhs: [Type]?, rhs: [Type]?) -> Bool { - switch (lhs, rhs) { - case (.some(let l), .some(let r)): - return l == r - case (.none, .none): - return true - default: - return false - } -} diff --git a/QuizTrain/Models/Case.swift b/QuizTrain/Models/Case.swift index 040f319..408179b 100644 --- a/QuizTrain/Models/Case.swift +++ b/QuizTrain/Models/Case.swift @@ -1,4 +1,4 @@ -public struct Case: Identifiable, MutableCustomFields { +public struct Case: Identifiable, MutableCustomFields, Equatable { public typealias Id = Int public let createdBy: User.Id public let createdOn: Date @@ -56,31 +56,6 @@ extension Case { } -// MARK: - Equatable - -extension Case: Equatable { - - public static func==(lhs: Case, rhs: Case) -> Bool { - return (lhs.createdBy == rhs.createdBy && - lhs.createdOn.secondsSince1970 == rhs.createdOn.secondsSince1970 && - lhs.estimate == rhs.estimate && - lhs.estimateForecast == rhs.estimateForecast && - lhs.id == rhs.id && - lhs.milestoneId == rhs.milestoneId && - lhs.priorityId == rhs.priorityId && - lhs.refs == rhs.refs && - lhs.sectionId == rhs.sectionId && - lhs.suiteId == rhs.suiteId && - lhs.templateId == rhs.templateId && - lhs.title == rhs.title && - lhs.typeId == rhs.typeId && - lhs.updatedBy == rhs.updatedBy && - lhs.updatedOn.secondsSince1970 == rhs.updatedOn.secondsSince1970 && - lhs.customFieldsContainer == rhs.customFieldsContainer) - } - -} - // MARK: - JSON Keys extension Case { diff --git a/QuizTrain/Models/CaseField.swift b/QuizTrain/Models/CaseField.swift index 871e26c..53062f2 100644 --- a/QuizTrain/Models/CaseField.swift +++ b/QuizTrain/Models/CaseField.swift @@ -1,4 +1,4 @@ -public struct CaseField: Identifiable { +public struct CaseField: Identifiable, Equatable { public typealias Id = Int public let configs: [Config] public let description: String? @@ -23,26 +23,6 @@ extension CaseField { } -// MARK: - Equatable - -extension CaseField: Equatable { - - public static func==(lhs: CaseField, rhs: CaseField) -> Bool { - return (lhs.configs.contentsAreEqual(to: rhs.configs) && - lhs.description == rhs.description && - lhs.displayOrder == rhs.displayOrder && - lhs.id == rhs.id && - lhs.includeAll == rhs.includeAll && - lhs.isActive == rhs.isActive && - lhs.label == rhs.label && - lhs.name == rhs.name && - lhs.systemName == rhs.systemName && - lhs.templateIds.sorted() == rhs.templateIds.sorted() && - lhs.typeId == rhs.typeId) - } - -} - // MARK: - JSON Keys extension CaseField { diff --git a/QuizTrain/Models/CaseType.swift b/QuizTrain/Models/CaseType.swift index 572080b..e635994 100644 --- a/QuizTrain/Models/CaseType.swift +++ b/QuizTrain/Models/CaseType.swift @@ -1,22 +1,10 @@ -public struct CaseType: Identifiable { +public struct CaseType: Identifiable, Equatable { public typealias Id = Int public let id: Id public let isDefault: Bool public let name: String } -// MARK: - Equatable - -extension CaseType: Equatable { - - public static func==(lhs: CaseType, rhs: CaseType) -> Bool { - return (lhs.id == rhs.id && - lhs.isDefault == rhs.isDefault && - lhs.name == rhs.name) - } - -} - // MARK: - JSON Keys extension CaseType { diff --git a/QuizTrain/Models/Config/Config.Context.swift b/QuizTrain/Models/Config/Config.Context.swift index 89a7e3e..69c1c60 100644 --- a/QuizTrain/Models/Config/Config.Context.swift +++ b/QuizTrain/Models/Config/Config.Context.swift @@ -1,23 +1,12 @@ extension Config { - public struct Context { + public struct Context: Equatable { public let isGlobal: Bool // True indicates all projects. public let projectIds: [Project.Id]? // Applies only if isGlobal is false. Can include projectIds for projects you do not have at least Read-only access to. } } -// MARK: - Equatable - -extension Config.Context: Equatable { - - public static func==(lhs: Config.Context, rhs: Config.Context) -> Bool { - return (lhs.isGlobal == rhs.isGlobal && - lhs.projectIds?.sorted() == rhs.projectIds?.sorted()) - } - -} - // MARK: - JSON Keys extension Config.Context { diff --git a/QuizTrain/Models/Config/Config.swift b/QuizTrain/Models/Config/Config.swift index 06f46d3..dcd0c56 100644 --- a/QuizTrain/Models/Config/Config.swift +++ b/QuizTrain/Models/Config/Config.swift @@ -1,4 +1,4 @@ -public struct Config: Identifiable { +public struct Config: Identifiable, Equatable { public typealias Id = String typealias OptionsContainer = JSONDictionaryContainer public let context: Config.Context @@ -21,18 +21,6 @@ extension Config { } -// MARK: - Equatable - -extension Config: Equatable { - - public static func==(lhs: Config, rhs: Config) -> Bool { - return (lhs.context == rhs.context && - lhs.id == rhs.id && - lhs.optionsContainer == rhs.optionsContainer) - } - -} - // MARK: - JSON Keys extension Config { diff --git a/QuizTrain/Models/Configuration.swift b/QuizTrain/Models/Configuration.swift index 3a10505..2d9d8e0 100644 --- a/QuizTrain/Models/Configuration.swift +++ b/QuizTrain/Models/Configuration.swift @@ -1,4 +1,4 @@ -public struct Configuration: Identifiable { +public struct Configuration: Identifiable, Equatable { public typealias Id = Int public let id: Id public let groupId: ConfigurationGroup.Id @@ -15,18 +15,6 @@ extension Configuration { } -// MARK: - Equatable - -extension Configuration: Equatable { - - public static func==(lhs: Configuration, rhs: Configuration) -> Bool { - return (lhs.id == rhs.id && - lhs.groupId == rhs.groupId && - lhs.name == rhs.name) - } - -} - // MARK: - JSON Keys extension Configuration { diff --git a/QuizTrain/Models/ConfigurationGroup.swift b/QuizTrain/Models/ConfigurationGroup.swift index 2e146fa..c3e5a48 100644 --- a/QuizTrain/Models/ConfigurationGroup.swift +++ b/QuizTrain/Models/ConfigurationGroup.swift @@ -1,4 +1,4 @@ -public struct ConfigurationGroup: Identifiable { +public struct ConfigurationGroup: Identifiable, Equatable { public typealias Id = Int public let configs: [Configuration] public let id: Id @@ -16,19 +16,6 @@ extension ConfigurationGroup { } -// MARK: - Equatable - -extension ConfigurationGroup: Equatable { - - public static func==(lhs: ConfigurationGroup, rhs: ConfigurationGroup) -> Bool { - return (lhs.configs.contentsAreEqual(to: rhs.configs) && - lhs.id == rhs.id && - lhs.name == rhs.name && - lhs.projectId == rhs.projectId) - } - -} - // MARK: - JSON Keys extension ConfigurationGroup { diff --git a/QuizTrain/Models/Milestone.swift b/QuizTrain/Models/Milestone.swift index f28b025..d2db34b 100644 --- a/QuizTrain/Models/Milestone.swift +++ b/QuizTrain/Models/Milestone.swift @@ -1,4 +1,4 @@ -public struct Milestone: Identifiable { +public struct Milestone: Identifiable, Equatable { public typealias Id = Int public let completedOn: Date? public var description: String? @@ -29,28 +29,6 @@ extension Milestone { } -// MARK: - Equatable - -extension Milestone: Equatable { - - public static func==(lhs: Milestone, rhs: Milestone) -> Bool { - return (lhs.completedOn?.secondsSince1970 == rhs.completedOn?.secondsSince1970 && - lhs.description == rhs.description && - lhs.dueOn?.secondsSince1970 == rhs.dueOn?.secondsSince1970 && - lhs.id == rhs.id && - lhs.isCompleted == rhs.isCompleted && - lhs.isStarted == rhs.isStarted && - Array.contentsAreEqual(lhs.milestones, rhs.milestones) && - lhs.name == rhs.name && - lhs.parentId == rhs.parentId && - lhs.projectId == rhs.projectId && - lhs.startOn?.secondsSince1970 == rhs.startOn?.secondsSince1970 && - lhs.startedOn?.secondsSince1970 == rhs.startedOn?.secondsSince1970 && - lhs.url == rhs.url) - } - -} - // MARK: - JSON Keys extension Milestone { diff --git a/QuizTrain/Models/Plan.Entry.swift b/QuizTrain/Models/Plan.Entry.swift index 8c8a86c..cb7d8ce 100644 --- a/QuizTrain/Models/Plan.Entry.swift +++ b/QuizTrain/Models/Plan.Entry.swift @@ -1,6 +1,6 @@ extension Plan { - public struct Entry: Identifiable { + public struct Entry: Identifiable, Equatable { public typealias Id = String public let id: Id public var name: String @@ -20,19 +20,6 @@ extension Plan.Entry { } -// MARK: - Equatable - -extension Plan.Entry: Equatable { - - public static func==(lhs: Plan.Entry, rhs: Plan.Entry) -> Bool { - return (lhs.id == rhs.id && - lhs.name == rhs.name && - lhs.runs.contentsAreEqual(to: rhs.runs) && - lhs.suiteId == rhs.suiteId) - } - -} - // MARK: - JSON Keys extension Plan.Entry { diff --git a/QuizTrain/Models/Plan.swift b/QuizTrain/Models/Plan.swift index 7299a02..4efddab 100644 --- a/QuizTrain/Models/Plan.swift +++ b/QuizTrain/Models/Plan.swift @@ -1,4 +1,4 @@ -public struct Plan: Identifiable { +public struct Plan: Identifiable, Equatable { public typealias Id = Int public let assignedtoId: User.Id? public let blockedCount: Int @@ -48,39 +48,6 @@ extension Plan { } -// MARK: - Equatable - -extension Plan: Equatable { - - public static func==(lhs: Plan, rhs: Plan) -> Bool { - return (lhs.assignedtoId == rhs.assignedtoId && - lhs.blockedCount == rhs.blockedCount && - lhs.completedOn?.secondsSince1970 == rhs.completedOn?.secondsSince1970 && - lhs.createdBy == rhs.createdBy && - lhs.createdOn.secondsSince1970 == rhs.createdOn.secondsSince1970 && - lhs.customStatus1Count == rhs.customStatus1Count && - lhs.customStatus2Count == rhs.customStatus2Count && - lhs.customStatus3Count == rhs.customStatus3Count && - lhs.customStatus4Count == rhs.customStatus4Count && - lhs.customStatus5Count == rhs.customStatus5Count && - lhs.customStatus6Count == rhs.customStatus6Count && - lhs.customStatus7Count == rhs.customStatus7Count && - lhs.description == rhs.description && - Array.contentsAreEqual(lhs.entries, rhs.entries) && - lhs.failedCount == rhs.failedCount && - lhs.id == rhs.id && - lhs.isCompleted == rhs.isCompleted && - lhs.milestoneId == rhs.milestoneId && - lhs.name == rhs.name && - lhs.passedCount == rhs.passedCount && - lhs.projectId == rhs.projectId && - lhs.retestCount == rhs.retestCount && - lhs.untestedCount == rhs.untestedCount && - lhs.url == rhs.url) - } - -} - // MARK: - JSON Keys extension Plan { diff --git a/QuizTrain/Models/Priority.swift b/QuizTrain/Models/Priority.swift index a720740..bf5e6dc 100644 --- a/QuizTrain/Models/Priority.swift +++ b/QuizTrain/Models/Priority.swift @@ -1,4 +1,4 @@ -public struct Priority: Identifiable { +public struct Priority: Identifiable, Equatable { public typealias Id = Int public let id: Id public let isDefault: Bool @@ -7,20 +7,6 @@ public struct Priority: Identifiable { public let shortName: String } -// MARK: - Equatable - -extension Priority: Equatable { - - public static func==(lhs: Priority, rhs: Priority) -> Bool { - return (lhs.id == rhs.id && - lhs.isDefault == rhs.isDefault && - lhs.name == rhs.name && - lhs.priority == rhs.priority && - lhs.shortName == rhs.shortName) - } - -} - // MARK: - JSON Keys extension Priority { diff --git a/QuizTrain/Models/Project.swift b/QuizTrain/Models/Project.swift index 039678d..7efcb78 100644 --- a/QuizTrain/Models/Project.swift +++ b/QuizTrain/Models/Project.swift @@ -1,4 +1,4 @@ -public struct Project: Identifiable { +public struct Project: Identifiable, Equatable { public typealias Id = Int public var announcement: String? public let completedOn: Date? @@ -10,23 +10,6 @@ public struct Project: Identifiable { public let url: URL } -// MARK: - Equatable - -extension Project: Equatable { - - public static func==(lhs: Project, rhs: Project) -> Bool { - return (lhs.announcement == rhs.announcement && - lhs.completedOn?.secondsSince1970 == rhs.completedOn?.secondsSince1970 && - lhs.id == rhs.id && - lhs.isCompleted == rhs.isCompleted && - lhs.name == rhs.name && - lhs.showAnnouncement == rhs.showAnnouncement && - lhs.suiteMode == rhs.suiteMode && - lhs.url == rhs.url) - } - -} - // MARK: - JSON Keys extension Project { diff --git a/QuizTrain/Models/Result.swift b/QuizTrain/Models/Result.swift index c634835..d1e8734 100644 --- a/QuizTrain/Models/Result.swift +++ b/QuizTrain/Models/Result.swift @@ -1,4 +1,4 @@ -public struct Result: CustomFields, Identifiable { +public struct Result: CustomFields, Identifiable, Equatable { public typealias Id = Int public let assignedtoId: User.Id? public let comment: String? @@ -35,26 +35,6 @@ extension Result { } -// MARK: - Equatable - -extension Result: Equatable { - - public static func==(lhs: Result, rhs: Result) -> Bool { - return (lhs.assignedtoId == rhs.assignedtoId && - lhs.comment == rhs.comment && - lhs.createdBy == rhs.createdBy && - lhs.createdOn.secondsSince1970 == rhs.createdOn.secondsSince1970 && - lhs.defects == rhs.defects && - lhs.elapsed == rhs.elapsed && - lhs.id == rhs.id && - lhs.statusId == rhs.statusId && - lhs.testId == rhs.testId && - lhs.version == rhs.version && - lhs.customFieldsContainer == rhs.customFieldsContainer) - } - -} - // MARK: - JSON Keys extension Result { diff --git a/QuizTrain/Models/ResultField.swift b/QuizTrain/Models/ResultField.swift index 22b5e48..8ea95c1 100644 --- a/QuizTrain/Models/ResultField.swift +++ b/QuizTrain/Models/ResultField.swift @@ -1,4 +1,4 @@ -public struct ResultField: Identifiable { +public struct ResultField: Identifiable, Equatable { public typealias Id = Int public let configs: [Config] public let description: String? @@ -23,26 +23,6 @@ extension ResultField { } -// MARK: - Equatable - -extension ResultField: Equatable { - - public static func==(lhs: ResultField, rhs: ResultField) -> Bool { - return (lhs.configs.contentsAreEqual(to: rhs.configs) && - lhs.description == rhs.description && - lhs.displayOrder == rhs.displayOrder && - lhs.id == rhs.id && - lhs.includeAll == rhs.includeAll && - lhs.isActive == rhs.isActive && - lhs.label == rhs.label && - lhs.name == rhs.name && - lhs.systemName == rhs.systemName && - lhs.templateIds.sorted() == rhs.templateIds.sorted() && - lhs.typeId == rhs.typeId) - } - -} - // MARK: - JSON Keys extension ResultField { diff --git a/QuizTrain/Models/Run.swift b/QuizTrain/Models/Run.swift index 8c7e99b..8f9763a 100644 --- a/QuizTrain/Models/Run.swift +++ b/QuizTrain/Models/Run.swift @@ -1,4 +1,4 @@ -public struct Run: Identifiable { +public struct Run: Identifiable, Equatable { public typealias Id = Int public let assignedtoId: User.Id? public let blockedCount: Int @@ -64,43 +64,6 @@ extension Run { } -// MARK: - Equatable - -extension Run: Equatable { - - public static func==(lhs: Run, rhs: Run) -> Bool { - return (lhs.assignedtoId == rhs.assignedtoId && - lhs.blockedCount == rhs.blockedCount && - lhs.completedOn?.secondsSince1970 == rhs.completedOn?.secondsSince1970 && - lhs.config == rhs.config && - lhs.configIds?.sorted() == rhs.configIds?.sorted() && - lhs.createdBy == rhs.createdBy && - lhs.createdOn.secondsSince1970 == rhs.createdOn.secondsSince1970 && - lhs.customStatus1Count == rhs.customStatus1Count && - lhs.customStatus2Count == rhs.customStatus2Count && - lhs.customStatus3Count == rhs.customStatus3Count && - lhs.customStatus4Count == rhs.customStatus4Count && - lhs.customStatus5Count == rhs.customStatus5Count && - lhs.customStatus6Count == rhs.customStatus6Count && - lhs.customStatus7Count == rhs.customStatus7Count && - lhs.description == rhs.description && - lhs.failedCount == rhs.failedCount && - lhs.id == rhs.id && - lhs.includeAll == rhs.includeAll && - lhs.isCompleted == rhs.isCompleted && - lhs.milestoneId == rhs.milestoneId && - lhs.name == rhs.name && - lhs.planId == rhs.planId && - lhs.passedCount == rhs.passedCount && - lhs.projectId == rhs.projectId && - lhs.retestCount == rhs.retestCount && - lhs.suiteId == rhs.suiteId && - lhs.untestedCount == rhs.untestedCount && - lhs.url == rhs.url) - } - -} - // MARK: - JSON Keys extension Run { diff --git a/QuizTrain/Models/Section.swift b/QuizTrain/Models/Section.swift index 6f78abd..df9d162 100644 --- a/QuizTrain/Models/Section.swift +++ b/QuizTrain/Models/Section.swift @@ -1,4 +1,4 @@ -public struct Section: Identifiable { +public struct Section: Identifiable, Equatable { public typealias Id = Int public let depth: Int public var description: String? @@ -23,22 +23,6 @@ extension Section { } -// MARK: - Equatable - -extension Section: Equatable { - - public static func==(lhs: Section, rhs: Section) -> Bool { - return (lhs.depth == rhs.depth && - lhs.description == rhs.description && - lhs.displayOrder == rhs.displayOrder && - lhs.id == rhs.id && - lhs.name == rhs.name && - lhs.parentId == rhs.parentId && - lhs.suiteId == rhs.suiteId) - } - -} - // MARK: - JSON Keys extension Section { diff --git a/QuizTrain/Models/Status.swift b/QuizTrain/Models/Status.swift index 52a9f55..090cdf5 100644 --- a/QuizTrain/Models/Status.swift +++ b/QuizTrain/Models/Status.swift @@ -1,4 +1,4 @@ -public struct Status: Identifiable { +public struct Status: Identifiable, Equatable { public typealias Id = Int public let colorBright: Int public let colorDark: Int @@ -11,24 +11,6 @@ public struct Status: Identifiable { public let name: String } -// MARK: - Equatable - -extension Status: Equatable { - - public static func==(lhs: Status, rhs: Status) -> Bool { - return (lhs.colorBright == rhs.colorBright && - lhs.colorDark == rhs.colorDark && - lhs.colorMedium == rhs.colorMedium && - lhs.id == rhs.id && - lhs.isFinal == rhs.isFinal && - lhs.isSystem == rhs.isSystem && - lhs.isUntested == rhs.isUntested && - lhs.label == rhs.label && - lhs.name == rhs.name) - } - -} - // MARK: - JSON Keys extension Status { diff --git a/QuizTrain/Models/Suite.swift b/QuizTrain/Models/Suite.swift index da28e31..002d968 100644 --- a/QuizTrain/Models/Suite.swift +++ b/QuizTrain/Models/Suite.swift @@ -1,4 +1,4 @@ -public struct Suite: Identifiable { +public struct Suite: Identifiable, Equatable { public typealias Id = Int public let completedOn: Date? public var description: String? @@ -21,24 +21,6 @@ extension Suite { } -// MARK: - Equatable - -extension Suite: Equatable { - - public static func==(lhs: Suite, rhs: Suite) -> Bool { - return (lhs.completedOn?.secondsSince1970 == rhs.completedOn?.secondsSince1970 && - lhs.description == rhs.description && - lhs.id == rhs.id && - lhs.isBaseline == rhs.isBaseline && - lhs.isCompleted == rhs.isCompleted && - lhs.isMaster == rhs.isMaster && - lhs.name == rhs.name && - lhs.projectId == rhs.projectId && - lhs.url == rhs.url) - } - -} - // MARK: - JSON Keys extension Suite { diff --git a/QuizTrain/Models/Template.swift b/QuizTrain/Models/Template.swift index 402b124..3e7002b 100644 --- a/QuizTrain/Models/Template.swift +++ b/QuizTrain/Models/Template.swift @@ -1,22 +1,10 @@ -public struct Template: Identifiable { +public struct Template: Identifiable, Equatable { public typealias Id = Int public let isDefault: Bool public let id: Id public let name: String } -// MARK: - Equatable - -extension Template: Equatable { - - public static func==(lhs: Template, rhs: Template) -> Bool { - return (lhs.isDefault == rhs.isDefault && - lhs.id == rhs.id && - lhs.name == rhs.name) - } - -} - // MARK: - JSON Keys extension Template { diff --git a/QuizTrain/Models/Test.swift b/QuizTrain/Models/Test.swift index 6922d77..2587505 100644 --- a/QuizTrain/Models/Test.swift +++ b/QuizTrain/Models/Test.swift @@ -1,4 +1,4 @@ -public struct Test: CustomFields, Identifiable { +public struct Test: CustomFields, Identifiable, Equatable { public typealias Id = Int public let assignedtoId: User.Id? public let caseId: Case.Id @@ -54,29 +54,6 @@ extension Test { } -// MARK: - Equatable - -extension Test: Equatable { - - public static func==(lhs: Test, rhs: Test) -> Bool { - return (lhs.assignedtoId == rhs.assignedtoId && - lhs.caseId == rhs.caseId && - lhs.estimate == rhs.estimate && - lhs.estimateForecast == rhs.estimateForecast && - lhs.id == rhs.id && - lhs.milestoneId == rhs.milestoneId && - lhs.priorityId == rhs.priorityId && - lhs.refs == rhs.refs && - lhs.runId == rhs.runId && - lhs.statusId == rhs.statusId && - lhs.templateId == rhs.templateId && - lhs.title == rhs.title && - lhs.typeId == rhs.typeId && - lhs.customFieldsContainer == rhs.customFieldsContainer) - } - -} - // MARK: - JSON Keys extension Test { diff --git a/QuizTrain/Models/Types/CustomFieldType.swift b/QuizTrain/Models/Types/CustomFieldType.swift index bd23d85..d78990f 100644 --- a/QuizTrain/Models/Types/CustomFieldType.swift +++ b/QuizTrain/Models/Types/CustomFieldType.swift @@ -1,4 +1,4 @@ -public enum CustomFieldType: Int { +public enum CustomFieldType: Int, Equatable { case string = 1 case integer = 2 case text = 3 diff --git a/QuizTrain/Models/Types/Project.SuiteMode.swift b/QuizTrain/Models/Types/Project.SuiteMode.swift index 584b000..6c65493 100644 --- a/QuizTrain/Models/Types/Project.SuiteMode.swift +++ b/QuizTrain/Models/Types/Project.SuiteMode.swift @@ -1,5 +1,5 @@ extension Project { - public enum SuiteMode: Int { + public enum SuiteMode: Int, Equatable { case singleSuite = 1 case singleSuitePlusBaselines = 2 case multipleSuites = 3 diff --git a/QuizTrain/Models/User.swift b/QuizTrain/Models/User.swift index 1096a77..3c352c4 100644 --- a/QuizTrain/Models/User.swift +++ b/QuizTrain/Models/User.swift @@ -1,4 +1,4 @@ -public struct User: Identifiable { +public struct User: Identifiable, Equatable { public typealias Id = Int public let email: String public let id: Id @@ -6,19 +6,6 @@ public struct User: Identifiable { public let name: String } -// MARK: - Equatable - -extension User: Equatable { - - public static func==(lhs: User, rhs: User) -> Bool { - return (lhs.email == rhs.email && - lhs.id == rhs.id && - lhs.isActive == rhs.isActive && - lhs.name == rhs.name) - } - -} - // MARK: - JSON Keys extension User { diff --git a/QuizTrain/Network/Filters/Filter.Value.swift b/QuizTrain/Network/Filters/Filter.Value.swift index 403a86d..99166d8 100644 --- a/QuizTrain/Network/Filters/Filter.Value.swift +++ b/QuizTrain/Network/Filters/Filter.Value.swift @@ -3,7 +3,7 @@ extension Filter { /* Value types accepted by the TestRail API used in filters. */ - public enum Value { + public enum Value: Equatable { case bool(Bool) case int(Int) case intList([Int]) @@ -12,35 +12,6 @@ extension Filter { } -extension Filter.Value: Equatable { - - public static func==(lhs: Filter.Value, rhs: Filter.Value) -> Bool { - switch lhs { - case .bool(let lhsBool): - guard case let .bool(rhsBool) = rhs else { - return false - } - return lhsBool == rhsBool - case .int(let lhsInt): - guard case let .int(rhsInt) = rhs else { - return false - } - return lhsInt == rhsInt - case .intList(let lhsIntList): - guard case let .intList(rhsIntList) = rhs else { - return false - } - return lhsIntList == rhsIntList - case .timestamp(let lhsDate): - guard case let .timestamp(rhsDate) = rhs else { - return false - } - return lhsDate.secondsSince1970 == rhsDate.secondsSince1970 - } - } - -} - extension Filter.Value { public var string: String { diff --git a/QuizTrain/Network/Filters/Filter.swift b/QuizTrain/Network/Filters/Filter.swift index ac37bb7..55de713 100644 --- a/QuizTrain/Network/Filters/Filter.swift +++ b/QuizTrain/Network/Filters/Filter.swift @@ -4,7 +4,7 @@ See TestRail's API documentation for allowed name/value pairs, chaining of filters, and general usage: http://docs.gurock.com/testrail-api2/start */ -public struct Filter { +public struct Filter: Equatable { public var name: String public var value: Filter.Value @@ -36,15 +36,6 @@ extension Filter { } -extension Filter: Equatable { - - public static func==(lhs: Filter, rhs: Filter) -> Bool { - return (lhs.name == rhs.name && - lhs.value == rhs.value) - } - -} - extension Filter: QueryItemProvider { public var queryItem: URLQueryItem { diff --git a/QuizTrain/Network/Models/Add/NewCase.swift b/QuizTrain/Network/Models/Add/NewCase.swift index 24d1f1b..c982d11 100644 --- a/QuizTrain/Network/Models/Add/NewCase.swift +++ b/QuizTrain/Network/Models/Add/NewCase.swift @@ -1,4 +1,4 @@ -public struct NewCase: MutableCustomFields { +public struct NewCase: MutableCustomFields, Equatable { // MARK: Properties @@ -28,23 +28,6 @@ public struct NewCase: MutableCustomFields { } -// MARK: - Equatable - -extension NewCase: Equatable { - - public static func==(lhs: NewCase, rhs: NewCase) -> Bool { - return (lhs.estimate == rhs.estimate && - lhs.milestoneId == rhs.milestoneId && - lhs.priorityId == rhs.priorityId && - lhs.refs == rhs.refs && - lhs.templateId == rhs.templateId && - lhs.title == rhs.title && - lhs.typeId == rhs.typeId && - lhs.customFieldsContainer == rhs.customFieldsContainer) - } - -} - // MARK: - JSON Keys extension NewCase { diff --git a/QuizTrain/Network/Models/Add/NewCaseResults.Result.swift b/QuizTrain/Network/Models/Add/NewCaseResults.Result.swift index 566e9b0..001b99f 100644 --- a/QuizTrain/Network/Models/Add/NewCaseResults.Result.swift +++ b/QuizTrain/Network/Models/Add/NewCaseResults.Result.swift @@ -1,6 +1,6 @@ extension NewCaseResults { - public struct Result: MutableCustomFields { + public struct Result: MutableCustomFields, Equatable { // MARK: Properties @@ -32,23 +32,6 @@ extension NewCaseResults { } -// MARK: - Equatable - -extension NewCaseResults.Result: Equatable { - - public static func==(lhs: NewCaseResults.Result, rhs: NewCaseResults.Result) -> Bool { - return (lhs.assignedtoId == rhs.assignedtoId && - lhs.caseId == rhs.caseId && - lhs.comment == rhs.comment && - lhs.defects == rhs.defects && - lhs.elapsed == rhs.elapsed && - lhs.statusId == rhs.statusId && - lhs.version == rhs.version && - lhs.customFieldsContainer == rhs.customFieldsContainer) - } - -} - // MARK: - Validatable extension NewCaseResults.Result: Validatable { diff --git a/QuizTrain/Network/Models/Add/NewCaseResults.swift b/QuizTrain/Network/Models/Add/NewCaseResults.swift index d297949..25cfeb2 100644 --- a/QuizTrain/Network/Models/Add/NewCaseResults.swift +++ b/QuizTrain/Network/Models/Add/NewCaseResults.swift @@ -1,7 +1,7 @@ /* Use to bulk-add multiple results associated with Cases. */ -public struct NewCaseResults { +public struct NewCaseResults: Equatable { public var results: [NewCaseResults.Result] @@ -11,16 +11,6 @@ public struct NewCaseResults { } -// MARK: - Equatable - -extension NewCaseResults: Equatable { - - public static func==(lhs: NewCaseResults, rhs: NewCaseResults) -> Bool { - return (lhs.results.contentsAreEqual(to: rhs.results)) - } - -} - // MARK: - Validatable extension NewCaseResults: Validatable { diff --git a/QuizTrain/Network/Models/Add/NewConfiguration.swift b/QuizTrain/Network/Models/Add/NewConfiguration.swift index 86b9c58..40d1629 100644 --- a/QuizTrain/Network/Models/Add/NewConfiguration.swift +++ b/QuizTrain/Network/Models/Add/NewConfiguration.swift @@ -1,4 +1,4 @@ -public struct NewConfiguration { +public struct NewConfiguration: Equatable { public var name: String @@ -8,16 +8,6 @@ public struct NewConfiguration { } -// MARK: - Equatable - -extension NewConfiguration: Equatable { - - public static func==(lhs: NewConfiguration, rhs: NewConfiguration) -> Bool { - return (lhs.name == rhs.name) - } - -} - // MARK: - JSON Keys extension NewConfiguration { diff --git a/QuizTrain/Network/Models/Add/NewConfigurationGroup.swift b/QuizTrain/Network/Models/Add/NewConfigurationGroup.swift index bfbd401..b3577b3 100644 --- a/QuizTrain/Network/Models/Add/NewConfigurationGroup.swift +++ b/QuizTrain/Network/Models/Add/NewConfigurationGroup.swift @@ -1,4 +1,4 @@ -public struct NewConfigurationGroup { +public struct NewConfigurationGroup: Equatable { public var name: String @@ -8,16 +8,6 @@ public struct NewConfigurationGroup { } -// MARK: - Equatable - -extension NewConfigurationGroup: Equatable { - - public static func==(lhs: NewConfigurationGroup, rhs: NewConfigurationGroup) -> Bool { - return (lhs.name == rhs.name) - } - -} - // MARK: - JSON Keys extension NewConfigurationGroup { diff --git a/QuizTrain/Network/Models/Add/NewMilestone.swift b/QuizTrain/Network/Models/Add/NewMilestone.swift index 0face03..5cb35ba 100644 --- a/QuizTrain/Network/Models/Add/NewMilestone.swift +++ b/QuizTrain/Network/Models/Add/NewMilestone.swift @@ -1,4 +1,4 @@ -public struct NewMilestone { +public struct NewMilestone: Equatable { public var description: String? public var dueOn: Date? @@ -16,20 +16,6 @@ public struct NewMilestone { } -// MARK: - Equatable - -extension NewMilestone: Equatable { - - public static func==(lhs: NewMilestone, rhs: NewMilestone) -> Bool { - return (lhs.description == rhs.description && - lhs.dueOn?.secondsSince1970 == rhs.dueOn?.secondsSince1970 && - lhs.name == rhs.name && - lhs.parentId == rhs.parentId && - lhs.startOn?.secondsSince1970 == rhs.startOn?.secondsSince1970) - } - -} - // MARK: - JSON Keys extension NewMilestone { diff --git a/QuizTrain/Network/Models/Add/NewPlan.Entry.Run.swift b/QuizTrain/Network/Models/Add/NewPlan.Entry.Run.swift index 8802f3a..9ec8447 100644 --- a/QuizTrain/Network/Models/Add/NewPlan.Entry.Run.swift +++ b/QuizTrain/Network/Models/Add/NewPlan.Entry.Run.swift @@ -25,7 +25,7 @@ */ extension NewPlan.Entry { - public struct Run { + public struct Run: Equatable { public var assignedtoId: User.Id? // Overrides NewPlan.Entry.assignedtoId. public var caseIds: [Case.Id]? // Overrides NewPlan.Entry.caseIds. @@ -51,23 +51,6 @@ extension NewPlan.Entry { } -// MARK: - Equatable - -extension NewPlan.Entry.Run: Equatable { - - public static func==(lhs: NewPlan.Entry.Run, rhs: NewPlan.Entry.Run) -> Bool { - return (lhs.assignedtoId == rhs.assignedtoId && - lhs.caseIds?.sorted() == rhs.caseIds?.sorted() && - lhs.configIds?.sorted() == rhs.configIds?.sorted() && - lhs.description == rhs.description && - lhs.includeAll == rhs.includeAll && - lhs.milestoneId == rhs.milestoneId && - lhs.name == rhs.name && - lhs.suiteId == rhs.suiteId) - } - -} - // MARK: - JSON Keys extension NewPlan.Entry.Run { diff --git a/QuizTrain/Network/Models/Add/NewPlan.Entry.swift b/QuizTrain/Network/Models/Add/NewPlan.Entry.swift index bc1def4..5b521ca 100644 --- a/QuizTrain/Network/Models/Add/NewPlan.Entry.swift +++ b/QuizTrain/Network/Models/Add/NewPlan.Entry.swift @@ -1,6 +1,6 @@ extension NewPlan { - public struct Entry { + public struct Entry: Equatable { public var assignedtoId: User.Id? // Default for all runs with a nil assignedtoId. public var caseIds: [Case.Id]? // Default for all runs with a nil or empty caseIds. @@ -54,23 +54,6 @@ extension NewPlan { } -// MARK: - Equatable - -extension NewPlan.Entry: Equatable { - - public static func==(lhs: NewPlan.Entry, rhs: NewPlan.Entry) -> Bool { - return (lhs.assignedtoId == rhs.assignedtoId && - lhs.caseIds?.sorted() == rhs.caseIds?.sorted() && - lhs.configIds?.sorted() == rhs.configIds?.sorted() && - lhs.description == rhs.description && - lhs.includeAll == rhs.includeAll && - lhs.name == rhs.name && - Array.contentsAreEqual(lhs.runs, rhs.runs) && - lhs.suiteId == rhs.suiteId) - } - -} - // MARK: - JSON Keys extension NewPlan.Entry { diff --git a/QuizTrain/Network/Models/Add/NewPlan.swift b/QuizTrain/Network/Models/Add/NewPlan.swift index 44fe95c..c3b5107 100644 --- a/QuizTrain/Network/Models/Add/NewPlan.swift +++ b/QuizTrain/Network/Models/Add/NewPlan.swift @@ -1,4 +1,4 @@ -public struct NewPlan { +public struct NewPlan: Equatable { public var description: String? public var entries: [NewPlan.Entry]? @@ -14,19 +14,6 @@ public struct NewPlan { } -// MARK: - Equatable - -extension NewPlan: Equatable { - - public static func==(lhs: NewPlan, rhs: NewPlan) -> Bool { - return (lhs.description == rhs.description && - Array.contentsAreEqual(lhs.entries, rhs.entries) && - lhs.milestoneId == rhs.milestoneId && - lhs.name == rhs.name) - } - -} - // MARK: - JSON Keys extension NewPlan { diff --git a/QuizTrain/Network/Models/Add/NewProject.swift b/QuizTrain/Network/Models/Add/NewProject.swift index 8588ab3..bebd249 100644 --- a/QuizTrain/Network/Models/Add/NewProject.swift +++ b/QuizTrain/Network/Models/Add/NewProject.swift @@ -1,4 +1,4 @@ -public struct NewProject { +public struct NewProject: Equatable { public var announcement: String? public var name: String @@ -14,19 +14,6 @@ public struct NewProject { } -// MARK: - Equatable - -extension NewProject: Equatable { - - public static func==(lhs: NewProject, rhs: NewProject) -> Bool { - return (lhs.announcement == rhs.announcement && - lhs.name == rhs.name && - lhs.showAnnouncement == rhs.showAnnouncement && - lhs.suiteMode == rhs.suiteMode) - } - -} - // MARK: - JSON Keys extension NewProject { diff --git a/QuizTrain/Network/Models/Add/NewResult.swift b/QuizTrain/Network/Models/Add/NewResult.swift index 24c741c..8770364 100644 --- a/QuizTrain/Network/Models/Add/NewResult.swift +++ b/QuizTrain/Network/Models/Add/NewResult.swift @@ -1,7 +1,7 @@ /* Used to add a single result. */ -public struct NewResult: MutableCustomFields { +public struct NewResult: MutableCustomFields, Equatable { // MARK: Properties @@ -29,22 +29,6 @@ public struct NewResult: MutableCustomFields { } -// MARK: - Equatable - -extension NewResult: Equatable { - - public static func==(lhs: NewResult, rhs: NewResult) -> Bool { - return (lhs.assignedtoId == rhs.assignedtoId && - lhs.comment == rhs.comment && - lhs.defects == rhs.defects && - lhs.elapsed == rhs.elapsed && - lhs.statusId == rhs.statusId && - lhs.version == rhs.version && - lhs.customFieldsContainer == rhs.customFieldsContainer) - } - -} - // MARK: - Validatable extension NewResult: Validatable { diff --git a/QuizTrain/Network/Models/Add/NewRun.swift b/QuizTrain/Network/Models/Add/NewRun.swift index ea08a23..15f6e81 100644 --- a/QuizTrain/Network/Models/Add/NewRun.swift +++ b/QuizTrain/Network/Models/Add/NewRun.swift @@ -1,4 +1,4 @@ -public struct NewRun { +public struct NewRun: Equatable { public var assignedtoId: User.Id? public var caseIds: [Case.Id]? @@ -20,22 +20,6 @@ public struct NewRun { } -// MARK: - Equatable - -extension NewRun: Equatable { - - public static func==(lhs: NewRun, rhs: NewRun) -> Bool { - return (lhs.assignedtoId == rhs.assignedtoId && - lhs.caseIds?.sorted() == rhs.caseIds?.sorted() && - lhs.description == rhs.description && - lhs.includeAll == rhs.includeAll && - lhs.milestoneId == rhs.milestoneId && - lhs.name == rhs.name && - lhs.suiteId == rhs.suiteId) - } - -} - // MARK: - JSON Keys extension NewRun { diff --git a/QuizTrain/Network/Models/Add/NewSection.swift b/QuizTrain/Network/Models/Add/NewSection.swift index e094ed2..96d1ffe 100644 --- a/QuizTrain/Network/Models/Add/NewSection.swift +++ b/QuizTrain/Network/Models/Add/NewSection.swift @@ -1,4 +1,4 @@ -public struct NewSection { +public struct NewSection: Equatable { public var description: String? public var name: String @@ -14,19 +14,6 @@ public struct NewSection { } -// MARK: - Equatable - -extension NewSection: Equatable { - - public static func==(lhs: NewSection, rhs: NewSection) -> Bool { - return (lhs.description == rhs.description && - lhs.name == rhs.name && - lhs.parentId == rhs.parentId && - lhs.suiteId == rhs.suiteId) - } - -} - // MARK: - JSON Keys extension NewSection { diff --git a/QuizTrain/Network/Models/Add/NewSuite.swift b/QuizTrain/Network/Models/Add/NewSuite.swift index 3d04d0b..bd88569 100644 --- a/QuizTrain/Network/Models/Add/NewSuite.swift +++ b/QuizTrain/Network/Models/Add/NewSuite.swift @@ -1,4 +1,4 @@ -public struct NewSuite { +public struct NewSuite: Equatable { public var description: String? public var name: String @@ -10,17 +10,6 @@ public struct NewSuite { } -// MARK: - Equatable - -extension NewSuite: Equatable { - - public static func==(lhs: NewSuite, rhs: NewSuite) -> Bool { - return (lhs.description == rhs.description && - lhs.name == rhs.name) - } - -} - // MARK: - JSON Keys extension NewSuite { diff --git a/QuizTrain/Network/Models/Add/NewTestResults.Result.swift b/QuizTrain/Network/Models/Add/NewTestResults.Result.swift index 6f38e65..8ee553f 100644 --- a/QuizTrain/Network/Models/Add/NewTestResults.Result.swift +++ b/QuizTrain/Network/Models/Add/NewTestResults.Result.swift @@ -1,6 +1,6 @@ extension NewTestResults { - public struct Result: MutableCustomFields { + public struct Result: MutableCustomFields, Equatable { // MARK: Properties @@ -32,23 +32,6 @@ extension NewTestResults { } -// MARK: - Equatable - -extension NewTestResults.Result: Equatable { - - public static func==(lhs: NewTestResults.Result, rhs: NewTestResults.Result) -> Bool { - return (lhs.assignedtoId == rhs.assignedtoId && - lhs.comment == rhs.comment && - lhs.defects == rhs.defects && - lhs.elapsed == rhs.elapsed && - lhs.statusId == rhs.statusId && - lhs.testId == rhs.testId && - lhs.version == rhs.version && - lhs.customFieldsContainer == rhs.customFieldsContainer) - } - -} - // MARK: - Validatable extension NewTestResults.Result: Validatable { diff --git a/QuizTrain/Network/Models/Add/NewTestResults.swift b/QuizTrain/Network/Models/Add/NewTestResults.swift index b38271a..1561303 100644 --- a/QuizTrain/Network/Models/Add/NewTestResults.swift +++ b/QuizTrain/Network/Models/Add/NewTestResults.swift @@ -1,7 +1,7 @@ /* Use to bulk-add multiple results associated with Tests. */ -public struct NewTestResults { +public struct NewTestResults: Equatable { public var results: [NewTestResults.Result] @@ -11,16 +11,6 @@ public struct NewTestResults { } -// MARK: - Equatable - -extension NewTestResults: Equatable { - - public static func==(lhs: NewTestResults, rhs: NewTestResults) -> Bool { - return (lhs.results.contentsAreEqual(to: rhs.results)) - } - -} - // MARK: - Validatable extension NewTestResults: Validatable { diff --git a/QuizTrain/Network/Models/Update/UpdatePlanEntryRuns.swift b/QuizTrain/Network/Models/Update/UpdatePlanEntryRuns.swift index 55e45d8..51d8e38 100644 --- a/QuizTrain/Network/Models/Update/UpdatePlanEntryRuns.swift +++ b/QuizTrain/Network/Models/Update/UpdatePlanEntryRuns.swift @@ -1,7 +1,7 @@ /* Applies to all Run's within Plan.Entry.runs. */ -public struct UpdatePlanEntryRuns { +public struct UpdatePlanEntryRuns: Equatable { public var assignedtoId: User.Id? public var caseIds: [Case.Id]? @@ -17,19 +17,6 @@ public struct UpdatePlanEntryRuns { } -// MARK: - Equatable - -extension UpdatePlanEntryRuns: Equatable { - - public static func==(lhs: UpdatePlanEntryRuns, rhs: UpdatePlanEntryRuns) -> Bool { - return (lhs.assignedtoId == rhs.assignedtoId && - lhs.caseIds == rhs.caseIds && - lhs.description == rhs.description && - lhs.includeAll == rhs.includeAll) - } - -} - // MARK: - JSON Keys extension UpdatePlanEntryRuns { diff --git a/QuizTrainTests/Misc/Extensions/Array+ContentComparisonTests.swift b/QuizTrainTests/Misc/Extensions/Array+ContentComparisonTests.swift deleted file mode 100644 index ae38d20..0000000 --- a/QuizTrainTests/Misc/Extensions/Array+ContentComparisonTests.swift +++ /dev/null @@ -1,42 +0,0 @@ -import XCTest -@testable import QuizTrain - -// MARK: - Tests - -class Array_ContentComparisonTests: XCTestCase { - - func testContentsOfArrayAreEqualToArray() { - - let arrayA = [1, 2, 3] - - XCTAssertTrue(arrayA.contentsAreEqual(to: arrayA)) - - let arrayB = [1, 2, 3] - - XCTAssertTrue(arrayA.contentsAreEqual(to: arrayB)) - - let arrayC = [3, 2, 1] - - XCTAssertNotEqual(arrayA, arrayC) - XCTAssertTrue(arrayA.contentsAreEqual(to: arrayC)) - - let arrayD = [1, 2] - - XCTAssertFalse(arrayA.contentsAreEqual(to: arrayD)) - - let arrayE = [1, 2, 3, 4] - - XCTAssertFalse(arrayA.contentsAreEqual(to: arrayE)) - - let arrayF: [Int]? = nil - - XCTAssertFalse(arrayA.contentsAreEqual(to: arrayF)) - XCTAssertTrue(Array.contentsAreEqual(arrayF, arrayF)) - - let arrayG = [1, 1, 2] - let arrayH = [1, 2, 2] - - XCTAssertFalse(arrayG.contentsAreEqual(to: arrayH)) - } - -} diff --git a/QuizTrainTests/Misc/Extensions/Equatable+OptionalArrayTests.swift b/QuizTrainTests/Misc/Extensions/Equatable+OptionalArrayTests.swift deleted file mode 100644 index f42dea9..0000000 --- a/QuizTrainTests/Misc/Extensions/Equatable+OptionalArrayTests.swift +++ /dev/null @@ -1,25 +0,0 @@ -import XCTest -@testable import QuizTrain - -// MARK: - Tests - -class Equatable_OptionalArrayTests: XCTestCase { - - func testEquatableWithOptionalArrays() { - - let arrayA = [1, 2, 3] - let arrayB = [1, 2, 3] - let arrayC = [4, 5, 6] - let arrayD: [Int]? = nil - let arrayE: [Int]? = nil - let arrayF: [Int]? = [1, 2, 3] - - XCTAssertTrue(arrayA == arrayA) - XCTAssertTrue(arrayA == arrayB) - XCTAssertFalse(arrayA == arrayC) - XCTAssertFalse(arrayA == arrayD) - XCTAssertTrue(arrayD == arrayE) - XCTAssertTrue(arrayA == arrayF) - } - -} From 7b6dffd1389f43f21530b3ca03b09b3420a657fb Mon Sep 17 00:00:00 2001 From: Dave Gallagher Date: Thu, 29 Mar 2018 15:18:32 -0700 Subject: [PATCH 3/3] - Updated version for Carthage in README. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 542adaf..b92d5a2 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ QuizTrain is open source software released under the MIT License. See the [LICEN [Carthage](https://github.com/Carthage/Carthage) is the recommended way to install QuizTrain. Add the following to your `Cartfile` or `Cartfile.private` file: - github "venmo/QuizTrain" ~> 1.0.0 + github "venmo/QuizTrain" ~> 1.1.0 See [Adding frameworks to an application](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application) for further instructions. Once complete `import QuizTrain` in any Swift files you wish to use QuizTrain in.