-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathUUIDValidationRuleTests.swift
More file actions
79 lines (57 loc) · 1.47 KB
/
UUIDValidationRuleTests.swift
File metadata and controls
79 lines (57 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//
// Validator
// Copyright © 2026 Space Code. All rights reserved.
//
import ValidatorCore
import XCTest
// MARK: - UUIDValidationRuleTests
final class UUIDValidationRuleTests: XCTestCase {
// MARK: - Properties
private var sut: UUIDValidationRule!
// MARK: - Setup
override func setUp() {
super.setUp()
sut = UUIDValidationRule(error: String.error)
}
override func tearDown() {
sut = nil
super.tearDown()
}
// MARK: Tests
func test_validate_validUUID_shouldReturnTrue() {
// given
let uuid = "550e8400-e29b-41d4-a716-446655440000"
// when
let result = sut.validate(input: uuid)
// then
XCTAssertTrue(result)
}
func test_validate_emptyString_shouldReturnFalse() {
// given
let uuid = ""
// when
let result = sut.validate(input: uuid)
// then
XCTAssertFalse(result)
}
func test_validate_whitespaceString_shouldReturnFalse() {
// given
let uuid = " "
// when
let result = sut.validate(input: uuid)
// then
XCTAssertFalse(result)
}
func test_validate_invalidUUID_shouldReturnFalse() {
// given
let uuid = "not-a-uuid"
// when
let result = sut.validate(input: uuid)
// then
XCTAssertFalse(result)
}
}
// MARK: Constants
private extension String {
static let error = "UUID is invalid"
}