forked from AllenMattson/VBA_personal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TDD_example.vb
138 lines (95 loc) · 3.63 KB
/
TDD_example.vb
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
Public Sub Tdd_CA2()
On Error Resume Next
Dim specs As New SpecSuite
Dim myArr As Variant
Dim lngSize As Long: lngSize = 46
myArr = fnArr_CA0_002
For lngCounter = 0 To UBound(myArr)
lngRow = lngCounter \ lngSize
lngCol = lngCounter Mod lngSize
specs.It("CA0_002_F86_Row" & lngRow + 1 & "_Col" & lngCol + 1).Expect(myArr(lngCounter + 1)).ToEqual tbl_calendar.[f86].Offset(lngRow, lngCol).value
specs.It("MUST_FAIL_CA0_002_F86_Row" & lngRow + 1 & "_Col" & lngCol + 1).Expect(myArr(lngCounter + 1)).ToNotEqual tbl_calendar.[f86].Offset(lngRow, lngCol).value & "1"
specs.It("MUST_FAIL_CA0_002_F86_Row" & lngRow + 1 & "_Col" & lngCol + 1).Expect(myArr(lngCounter + 1)).ToNotEqual tbl_calendar.[f86].Offset(lngRow, lngCol).value & "2"
Next lngCounter
InlineRunner.RunSuite specs
Call specs.TotalTests
On Error GoTo 0
End Sub
Public Function fnArr_CA0_002()
Dim my_arr As Variant
ReDim my_arr(414)
my_arr(1) = 1
my_arr(2) = 2
my_arr(413) = 8059.23
my_arr(414) = 0
fnArr_CA0_002 = my_arr
End Function
Public Sub MakeAllValues()
Dim my_cell As Range
Dim l_counter As Long
Dim str As String
Dim str_result As String
STR_ERROR_REPORT = ""
For Each my_cell In Selection
Call Increment(l_counter)
str = vbTab & "my_arr(" & l_counter & ")= "
If Len(my_cell) > 0 Then
If IsDate(my_cell) Then
str = str & "CDate(""" & my_cell & """)"
Else
If Not IsNumeric(my_cell) Then
str = str & """" & my_cell & """"
Else
str = str & change_commas(my_cell.value)
End If
End If
Else
If my_cell.HasFormula Then
str = str & """"""
Else
str = str & 0
End If
End If
If Len(str_result) = 0 Then
str_result = str
Else
str_result = str_result & vbCrLf & str
End If
Next my_cell
Debug.Print str_result
Call CreateLogFile(str_result)
End Sub
Public Sub MakeColorsAllValues()
Dim myCell As Range
Dim lngCounter As Long
Dim str As String
Dim strResult As String
STR_ERROR_REPORT = ""
For Each myCell In Selection
Call Increment(lngCounter)
str = vbTab & "my_arr(" & lngCounter & ")= "
str = str & myCell.Interior.Color
If Len(strResult) = 0 Then
strResult = str
Else
strResult = strResult & vbCrLf & str
End If
Next myCell
Debug.Print strResult
Call CreateLogFile(strResult)
End Sub
Public Function codify_time(Optional b_make_str As Boolean = False) As String
If [set_in_production] Then On Error GoTo codify_Error
Dim dbl_01 As Variant
Dim dbl_02 As Variant
Dim dbl_now As Double
dbl_now = Round(Now(), 8)
dbl_01 = Split(CStr(dbl_now), ",")(0)
dbl_02 = Split(CStr(dbl_now), ",")(1)
codify_time = Hex(dbl_01) & "_" & Hex(dbl_02)
If b_make_str Then codify_time = "\" & codify_time & ".txt"
On Error GoTo 0
Exit Function
codify_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure codify of Function TDD_Export"
End Function