Skip to content

Commit 98583dd

Browse files
committed
Add some basic unit tests
1 parent ec00921 commit 98583dd

1 file changed

Lines changed: 24 additions & 5 deletions

File tree

Tests/SwiftShellUtilitiesTests/SystemActionTests.swift

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,29 @@ import XCTest
22
@testable import SwiftShellUtilities
33

44
final class SystemActionTests: XCTestCase {
5-
func testExample() throws {
6-
// This is an example of a functional test case.
7-
// Use XCTAssert and related functions to verify your tests produce the correct
8-
// results.
9-
// XCTAssertEqual(SystemAction().text, "Hello, World!")
5+
6+
func testThat_Real_CanExecuteCommand() throws {
7+
let action = SystemActionReal()
8+
9+
try action.runAndPrint(command: "date")
10+
}
11+
12+
func testThat_Real_WillThrow_GivenInvalidCommand() throws {
13+
let action = SystemActionReal()
14+
15+
XCTAssertThrowsError(try action.runAndPrint(command: "_this_command-does_not_exist"))
16+
}
17+
18+
func testThat_Composite_CanExecuteCommand() throws {
19+
let action = SystemActionComposite( [SystemActionPrint(), SystemActionReal()] )
20+
21+
try action.runAndPrint(command: "date")
22+
}
23+
24+
func testThat_Composite_WillThrow_GivenInvalidCommand() throws {
25+
let action = SystemActionComposite( [SystemActionPrint(), SystemActionReal()] )
26+
27+
XCTAssertThrowsError(try action.runAndPrint(command: "_this_command-does_not_exist"))
1028
}
29+
1130
}

0 commit comments

Comments
 (0)