Skip to content

Commit

Permalink
TestCore implements TestSpy pattern (#393)
Browse files Browse the repository at this point in the history
* make TestCore implement the Test Spy pattern and add a test

* refactor TestCore query methods

* revert 793dce5 but keep the refactored interface
  • Loading branch information
rsommerfeld authored Jun 13, 2021
1 parent b135684 commit 5bdd69b
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
testing
testPositionIsUpdatedAfterInitialChatLoading

| testChat newChatEvent updatePositionEvent |

testChat := self sharedCore chats first.
self assert: testChat positionKnown.

newChatEvent := (self sharedCore loggedEventsSatisfying:
[:anEvent | anEvent type = 'updateNewChat' and: [((anEvent at: 'chat') at: 'id') = testChat id]])
first.
updatePositionEvent := (self sharedCore loggedEventsSatisfying:
[:anEvent | anEvent type = 'updateChatPosition' and: [(anEvent at: 'chat_id') = testChat id]])
first.

self assert: (self sharedCore chronologicalPositionOf: newChatEvent) < (self sharedCore chronologicalPositionOf: updatePositionEvent).
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
},
"instance" : {
"testExtraAPIAttribute" : "RS 6/6/2021 10:50",
"testMessageSending" : "RS 6/6/2021 10:54" } }
"testMessageSending" : "RS 6/6/2021 10:54",
"testPositionIsUpdatedAfterInitialChatLoading" : "RS 6/13/2021 17:02" } }
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Creates a TestApp using Telegram TestDatabase Service
Creates a TestApp using Telegram TestDatabase Service and saves all received events in-order in a log.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
event log querying
chronologicalPositionOf: anEvent

| position |

position := self eventLog findFirst: [:anotherEvent | anotherEvent = anEvent].
self assert: (position = 0) not.

^ position
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
eventLog: anOrderedCollection

eventLog := anOrderedCollection
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
eventLog

^ eventLog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
events
handleEvent: anEvent

self eventLog add: anEvent.
^ super handleEvent: anEvent
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
initialization
initialize

self eventLog: OrderedCollection new.
super initialize.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
event log querying
loggedEventsSatisfying: aBlock

^ self eventLog select: aBlock
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,11 @@
"class" : {
},
"instance" : {
"chronologicalPositionOf:" : "RS 6/13/2021 17:05",
"eventLog" : "RS 6/13/2021 12:31",
"eventLog:" : "RS 6/13/2021 12:32",
"handleEvent:" : "RS 6/13/2021 12:34",
"initialize" : "RS 6/13/2021 12:47",
"initializeHandlers" : "JB 6/7/2021 09:27",
"loggedEventsSatisfying:" : "RS 6/13/2021 17:06",
"loginWithTestData" : "RS 5/26/2021 13:57" } }
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
],
"classvars" : [
],
"commentStamp" : "rs 6/14/2020 12:57",
"commentStamp" : "RS 6/13/2021 13:04",
"instvars" : [
],
"eventLog" ],
"name" : "TCTCTestCore",
"pools" : [
],
Expand Down

0 comments on commit 5bdd69b

Please sign in to comment.