-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from VBA-tools/v2
V2: Evented Approach
- Loading branch information
Showing
23 changed files
with
843 additions
and
2,318 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
VERSION 1.0 CLASS | ||
BEGIN | ||
MultiUse = -1 'True | ||
END | ||
Attribute VB_Name = "Specs_Fixture" | ||
Attribute VB_GlobalNameSpace = False | ||
Attribute VB_Creatable = False | ||
Attribute VB_PredeclaredId = False | ||
Attribute VB_Exposed = True | ||
Private WithEvents pSuite As SpecSuite | ||
Attribute pSuite.VB_VarHelpID = -1 | ||
|
||
Public BeforeEachCallCount As Long | ||
Public ResultCalls As Collection | ||
Public AfterEachCallCount As Long | ||
|
||
Public Sub ListenTo(Suite As SpecSuite) | ||
Set pSuite = Suite | ||
End Sub | ||
|
||
Private Sub pSuite_BeforeEach() | ||
BeforeEachCallCount = BeforeEachCallCount + 1 | ||
End Sub | ||
|
||
Private Sub pSuite_Result(Spec As SpecDefinition) | ||
Me.ResultCalls.Add Spec | ||
End Sub | ||
|
||
Private Sub pSuite_AfterEach() | ||
AfterEachCallCount = AfterEachCallCount + 1 | ||
End Sub | ||
|
||
Private Sub Class_Initialize() | ||
Set Me.ResultCalls = New Collection | ||
End Sub | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
Attribute VB_Name = "Specs_SpecSuite" | ||
Public Function Specs() As SpecSuite | ||
Dim Suite As SpecSuite | ||
|
||
Set Specs = New SpecSuite | ||
Specs.Description = "SpecSuite" | ||
|
||
Dim Reporter As New ImmediateReporter | ||
Reporter.ListenTo Specs | ||
|
||
Dim Fixture As New Specs_Fixture | ||
Fixture.ListenTo Specs | ||
|
||
With Specs.It("should fire BeforeEach event", "id") | ||
.Expect(Fixture.BeforeEachCallCount).ToEqual 1 | ||
.Expect(1 + 1).ToEqual 2 | ||
End With | ||
|
||
With Specs.It("should fire Result event") | ||
.Expect(Fixture.ResultCalls(1).Description).ToEqual "should fire BeforeEach event" | ||
.Expect(Fixture.ResultCalls(1).Result).ToEqual SpecResultType.Pass | ||
.Expect(Fixture.ResultCalls(1).Expectations.Count).ToEqual 2 | ||
.Expect(Fixture.ResultCalls(1).Id).ToEqual "id" | ||
End With | ||
|
||
With Specs.It("should fire AfterEach event") | ||
.Expect(Fixture.AfterEachCallCount).ToEqual 2 | ||
End With | ||
|
||
With Specs.It("should store specs") | ||
Set Suite = New SpecSuite | ||
With Suite.It("(pass)", "(1)") | ||
.Expect(4).ToEqual 4 | ||
End With | ||
With Suite.It("(fail)", "(2)") | ||
.Expect(4).ToEqual 3 | ||
End With | ||
With Suite.It("(pending)", "(3)") | ||
End With | ||
|
||
.Expect(Suite.Specs.Count).ToEqual 3 | ||
.Expect(Suite.PassedSpecs.Count).ToEqual 1 | ||
.Expect(Suite.FailedSpecs.Count).ToEqual 1 | ||
.Expect(Suite.PendingSpecs.Count).ToEqual 1 | ||
|
||
.Expect(Suite.PassedSpecs(1).Description).ToEqual "(pass)" | ||
.Expect(Suite.FailedSpecs(1).Description).ToEqual "(fail)" | ||
.Expect(Suite.PendingSpecs(1).Description).ToEqual "(pending)" | ||
End With | ||
|
||
With Specs.It("should have overall result") | ||
Set Suite = New SpecSuite | ||
|
||
.Expect(Suite.Result).ToEqual SpecResultType.Pending | ||
|
||
With Suite.It("(pending)", "(1)") | ||
End With | ||
|
||
.Expect(Suite.Result).ToEqual SpecResultType.Pending | ||
|
||
With Suite.It("(pass)", "(2)") | ||
.Expect(4).ToEqual 4 | ||
End With | ||
|
||
.Expect(Suite.Result).ToEqual SpecResultType.Pass | ||
|
||
With Suite.It("(fail)", "(3)") | ||
.Expect(4).ToEqual 3 | ||
End With | ||
|
||
.Expect(Suite.Result).ToEqual SpecResultType.Fail | ||
|
||
With Suite.It("(pass)", "(4)") | ||
.Expect(4).ToEqual 4 | ||
End With | ||
|
||
.Expect(Suite.Result).ToEqual SpecResultType.Fail | ||
End With | ||
End Function |
Oops, something went wrong.