Skip to content

Commit

Permalink
Updated unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Nov 12, 2024
1 parent 6216d28 commit f78154d
Showing 1 changed file with 78 additions and 1 deletion.
79 changes: 78 additions & 1 deletion Tests/BluetoothTests/GATTTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ final class GATTTests: XCTestCase {
log: { print("GATTServer:", $0) }
)

// request
Task { [weak client] in
while let client {
try await Task.sleep(nanoseconds: 10_000)
Expand Down Expand Up @@ -144,6 +143,19 @@ final class GATTTests: XCTestCase {
)
let server = try await serverAcceptTask.value

Task { [weak client] in
while let client {
try await Task.sleep(nanoseconds: 10_000)
try await client.run()
}
}
Task { [weak server] in
while let server {
try await Task.sleep(nanoseconds: 10_000)
try await server.run()
}
}

// request
let services = try await client.discoverAllPrimaryServices()
XCTAssertEqual(services.map { $0.uuid }, profile.map { $0.uuid })
Expand Down Expand Up @@ -459,6 +471,19 @@ final class GATTTests: XCTestCase {
)
let server = try await serverAcceptTask.value

Task { [weak client] in
while let client {
try await Task.sleep(nanoseconds: 10_000)
try await client.run()
}
}
Task { [weak server] in
while let server {
try await Task.sleep(nanoseconds: 10_000)
try await server.run()
}
}

// request
let services = try await client.discoverAllPrimaryServices()
XCTAssertEqual(services.map { $0.uuid }, ProximityProfile.services.map { $0.uuid })
Expand Down Expand Up @@ -593,6 +618,19 @@ final class GATTTests: XCTestCase {
)
let server = try await serverAcceptTask.value

Task { [weak client] in
while let client {
try await Task.sleep(nanoseconds: 10_000)
try await client.run()
}
}
Task { [weak server] in
while let server {
try await Task.sleep(nanoseconds: 10_000)
try await server.run()
}
}

// request
let services = try await client.discoverAllPrimaryServices()
XCTAssertEqual(services.map { $0.uuid }, [service].map { $0.uuid })
Expand Down Expand Up @@ -660,6 +698,19 @@ final class GATTTests: XCTestCase {
)
let server = try await serverAcceptTask.value

Task { [weak client] in
while let client {
try await Task.sleep(nanoseconds: 10_000)
try await client.run()
}
}
Task { [weak server] in
while let server {
try await Task.sleep(nanoseconds: 10_000)
try await server.run()
}
}

// discover service
let foundServices = try await client.discoverPrimaryServices(by: services[0].uuid)
guard foundServices.count == 1,
Expand Down Expand Up @@ -738,6 +789,19 @@ final class GATTTests: XCTestCase {
)
let server = try await serverAcceptTask.value

Task { [weak client] in
while let client {
try await Task.sleep(nanoseconds: 10_000)
try await client.run()
}
}
Task { [weak server] in
while let server {
try await Task.sleep(nanoseconds: 10_000)
try await server.run()
}
}

// discover service
let foundServices = try await client.discoverPrimaryServices(by: service.uuid)
guard foundServices.count == 1,
Expand Down Expand Up @@ -826,6 +890,19 @@ final class GATTTests: XCTestCase {
)
let server = try await serverAcceptTask.value

Task { [weak client] in
while let client {
try await Task.sleep(nanoseconds: 10_000)
try await client.run()
}
}
Task { [weak server] in
while let server {
try await Task.sleep(nanoseconds: 10_000)
try await server.run()
}
}

// discover service
let foundServices = try await client.discoverPrimaryServices(by: service.uuid)
guard foundServices.count == 1,
Expand Down

0 comments on commit f78154d

Please sign in to comment.