8000 Remove unnecessary explicit conformance to Equatable by sergeysmagleev · Pull Request #30 · Clean-Swift/CleanStore · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Remove unnecessary explicit conformance to Equatable #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 3 additions & 39 deletions CleanStore/Models/Order.swift
10000
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,9 @@ struct Order: Equatable
var total: NSDecimalNumber
}

func ==(lhs: Order, rhs: Order) -> Bool
{
return lhs.firstName == rhs.firstName
&& lhs.lastName == rhs.lastName
&& lhs.phone == rhs.phone
&& lhs.email == rhs.email
&& lhs.billingAddress == rhs.billingAddress
&& lhs.paymentMethod == rhs.paymentMethod
&& lhs.shipmentAddress == rhs.shipmentAddress
&& lhs.shipmentMethod == rhs.shipmentMethod
&& lhs.id == rhs.id
&& lhs.date.timeIntervalSince(rhs.date) < 1.0
&& lhs.total == rhs.total
}

// MARK: - Supporting models

struct Address
struct Address: Equatable
{
var street1: String
var street2: String?
Expand All @@ -56,16 +41,7 @@ struct Address
var zip: String
}

func ==(lhs: Address, rhs: Address) -> Bool
{
return lhs.street1 == rhs.street1
&& lhs.street2 == rhs.street2
&& lhs.city == rhs.city
&& lhs.state == rhs.state
&& lhs.zip == rhs.zip
}

struct ShipmentMethod
struct ShipmentMethod: Equatable
{
enum ShippingSpeed: Int {
case Standard = 0 // "Standard Shipping"
Expand All @@ -87,21 +63,9 @@ struct ShipmentMethod
}
}

func ==(lhs: ShipmentMethod, rhs: ShipmentMethod) -> Bool
{
return lhs.speed == rhs.speed
}

struct PaymentMethod
struct PaymentMethod: Equatable
{
var creditCardNumber: String
var expirationDate: Date
var cvv: String
}

func ==(lhs: PaymentMethod, rhs: PaymentMethod) -> Bool
{
return lhs.creditCardNumber == rhs.creditCardNumber
&& lhs.expirationDate.timeIntervalSince(rhs.expirationDate) < 1.0
&& lhs.cvv == rhs.cvv
}
11 changes: 0 additions & 11 deletions CleanStore/Workers/OrdersWorker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,3 @@ enum OrdersStoreError: Equatable, Error
case CannotUpdate(String)
case CannotDelete(String)
}

func ==(lhs: OrdersStoreError, rhs: OrdersStoreError) -> Bool
{
switch (lhs, rhs) {
case (.CannotFetch(let a), .CannotFetch(let b)) where a == b: return true
case (.CannotCreate(let a), .CannotCreate(let b)) where a == b: return true
case (.CannotUpdate(let a), .CannotUpdate(let b)) where a == b: return true
case (.CannotDelete(let a), .CannotDelete(let b)) where a == b: return true
default: return false
}
}
4 changes: 2 additions & 2 deletions CleanStoreTests/Workers/OrdersWorkerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class OrdersWorkerTests: XCTestCase
createOrderCalled = true
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1)) {
completionHandler { () -> Order in
return OrdersWorkerTests.testOrders.first!
return orderToCreate
}
}
}
Expand All @@ -67,7 +67,7 @@ class OrdersWorkerTests: XCTestCase
updateOrderCalled = true
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1)) {
completionHandler { () -> Order in
return OrdersWorkerTests.testOrders.first!
return orderToUpdate
}
}
}
Expand Down
0