Skip to content

Commit

Permalink
Merge pull request #5 from LucoMoro/DDNode-test
Browse files Browse the repository at this point in the history
Add tests for DDNode + subclasses
  • Loading branch information
DG266 authored Mar 9, 2024
2 parents 9f19943 + 5cc88e5 commit 05abb31
Show file tree
Hide file tree
Showing 10 changed files with 1,310 additions and 5 deletions.
255 changes: 255 additions & 0 deletions src/DiscOrDance-Model-Tests/DDAuthorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,81 @@ DDAuthorTest >> testActiveChannels2 [
self assert: aDDAuthor activeChannels equals: aSet.
]

{ #category : #test }
DDAuthorTest >> testActivitySorted [
"This method checks if activitySorted works properly given two Authors without sent messages"

| aFirstDDAuthor aSecondDDAuthor anOrderedCollection aCollectionOfDDAuthor |
aFirstDDAuthor := DDAuthor new.
aSecondDDAuthor := DDAuthor new.
anOrderedCollection := OrderedCollection new.
aCollectionOfDDAuthor := OrderedCollection new.

aFirstDDAuthor name: 'First'.
aSecondDDAuthor name: 'Second'.

anOrderedCollection add: aFirstDDAuthor.
anOrderedCollection add: aSecondDDAuthor.

aCollectionOfDDAuthor add: aSecondDDAuthor.
aCollectionOfDDAuthor add: aFirstDDAuthor.

self assert: (DDAuthor activitySorted: aCollectionOfDDAuthor) equals: anOrderedCollection.

]

{ #category : #test }
DDAuthorTest >> testActivitySorted2 [
"This method checks if activitySorted works properly given two Authors and a message sent only by one of them"

| aFirstDDAuthor aSecondDDAuthor aDDMessage anOrderedCollection aCollectionOfDDAuthor |
aFirstDDAuthor := DDAuthor new.
aSecondDDAuthor := DDAuthor new.
aDDMessage := DDMessage new.
anOrderedCollection := OrderedCollection new.
aCollectionOfDDAuthor := OrderedCollection new.

aFirstDDAuthor name: 'First'.
aSecondDDAuthor name: 'Second'.
aDDMessage author: aFirstDDAuthor.

anOrderedCollection add: aFirstDDAuthor.
anOrderedCollection add: aSecondDDAuthor.

aCollectionOfDDAuthor add: aSecondDDAuthor.
aCollectionOfDDAuthor add: aFirstDDAuthor.

self assert: (DDAuthor activitySorted: aCollectionOfDDAuthor) equals: anOrderedCollection.
]

{ #category : #test }
DDAuthorTest >> testActivitySorted3 [
"This method checks if activitySorted works properly given two Authors and messages sent by both of them"

| aFirstDDAuthor aSecondDDAuthor aFirstDDMessage aSecondDDMessage aThirdDDMessage anOrderedCollection aCollectionOfDDAuthor |
aFirstDDAuthor := DDAuthor new.
aSecondDDAuthor := DDAuthor new.
aFirstDDMessage := DDMessage new.
aSecondDDMessage := DDMessage new.
aThirdDDMessage := DDMessage new.
anOrderedCollection := OrderedCollection new.
aCollectionOfDDAuthor := OrderedCollection new.

aFirstDDAuthor name: 'First'.
aSecondDDAuthor name: 'Second'.
aFirstDDMessage author: aFirstDDAuthor.
aSecondDDMessage author: aSecondDDAuthor.
aThirdDDMessage author: aSecondDDAuthor.

anOrderedCollection add: aFirstDDAuthor.
anOrderedCollection add: aSecondDDAuthor.

aCollectionOfDDAuthor add: aSecondDDAuthor.
aCollectionOfDDAuthor add: aFirstDDAuthor.

self assert: (DDAuthor activitySorted: aCollectionOfDDAuthor) equals: anOrderedCollection.
]

{ #category : #test }
DDAuthorTest >> testAddActiveCategory [
"this method checks if addActiveCategory works initializing the array with a DDcategory"
Expand Down Expand Up @@ -102,6 +177,28 @@ DDAuthorTest >> testAddSentMessage [
self assert: aDDAuthor hasMessages equals: true.
]

{ #category : #test }
DDAuthorTest >> testAlphaSorted [
"This method checks if activitySorted works properly given two Authors and a message sent by both of them"

| aFirstDDAuthor aSecondDDAuthor anOrderedCollection aCollectionOfDDAuthor |
aFirstDDAuthor := DDAuthor new.
aSecondDDAuthor := DDAuthor new.
anOrderedCollection := OrderedCollection new.
aCollectionOfDDAuthor := OrderedCollection new.

aFirstDDAuthor name: 'first'.
aSecondDDAuthor name: 'second'.

anOrderedCollection add: aFirstDDAuthor.
anOrderedCollection add: aSecondDDAuthor.

aCollectionOfDDAuthor add: aSecondDDAuthor.
aCollectionOfDDAuthor add: aFirstDDAuthor.

self assert: (DDAuthor alphaSorted: aCollectionOfDDAuthor) equals: anOrderedCollection.
]

{ #category : #test }
DDAuthorTest >> testAvatar [
"This method checks if DDAuthor can be created without an avatar"
Expand Down Expand Up @@ -211,6 +308,51 @@ DDAuthorTest >> testFirstMessage [
self assert: aDDAuthor firstMessage equals: aDDMessageMock.
]

{ #category : #test }
DDAuthorTest >> testFirstMessage2 [
"This method checks if firstMessage returns the only message that aDDAuthor has without mocking the DDMessage class"

| aDDAuthor aDDMessage aSecondDDMessage |
aDDAuthor := DDAuthor new.
aDDMessage := DDMessage new.
aSecondDDMessage := DDMessage new.

aDDMessage createdAt: '05-06-23'.
aSecondDDMessage createdAt: '02-06-23'.

aDDAuthor addSentMessage: aDDMessage.
aDDAuthor addSentMessage: aSecondDDMessage.

self assert: aDDAuthor firstMessage equals: aSecondDDMessage.
]

{ #category : #test }
DDAuthorTest >> testFirstMessageSorted [
"This method checks if firstMessageSorted returns the DDAuthors in a correct oreder basaed on their sent messages"

| aFirstDDAuthor aSecondDDAuthor aFirstDDMessage aSecondDDMessage anOrderedCollection aCollectionOfDDAuthor |
aFirstDDAuthor := DDAuthor new.
aSecondDDAuthor := DDAuthor new.
aFirstDDMessage := DDMessage new.
aSecondDDMessage := DDMessage new.
anOrderedCollection := OrderedCollection new.
aCollectionOfDDAuthor := OrderedCollection new.

aFirstDDAuthor addSentMessage: aFirstDDMessage.
aFirstDDMessage createdAt: '01-03-21'.
aSecondDDAuthor addSentMessage: aSecondDDMessage.
aSecondDDMessage createdAt: '01-04-22'.

anOrderedCollection add: aFirstDDAuthor.
anOrderedCollection add: aSecondDDAuthor.

aCollectionOfDDAuthor add: aSecondDDAuthor.
aCollectionOfDDAuthor add: aFirstDDAuthor.


self assert: (DDAuthor firstMessageSorted: aCollectionOfDDAuthor ) equals: anOrderedCollection.
]

{ #category : #test }
DDAuthorTest >> testHasAvatar [
"Thsi method checks if hasAvatar works properly"
Expand Down Expand Up @@ -324,6 +466,23 @@ DDAuthorTest >> testIsMember2 [
self assert: aDDAuthor isMember equals: true.
]

{ #category : #test }
DDAuthorTest >> testIsMember3 [
"this method checks if isMember's getter and setter works initializing the server array, without mocking the Server class "

| aDDAuthor aSet aDDServer |
aDDAuthor := DDAuthor new.
aSet := Set new.
aDDServer := DDServer new.

aSet add: aDDAuthor.
aDDAuthor server: aDDServer.

aDDServer members: aSet.

self assert: aDDAuthor isMember equals: true.
]

{ #category : #test }
DDAuthorTest >> testLastMessage [
"This method checks if lastMessage returns the only message that aDDAuthor has"
Expand All @@ -338,6 +497,50 @@ DDAuthorTest >> testLastMessage [
self assert: aDDAuthor lastMessage equals: aDDMessageMock.
]

{ #category : #test }
DDAuthorTest >> testLastMessage2 [
"This method checks if lastMessage returns the only message that aDDAuthor has without moking the DDMessage class"

| aDDAuthor aDDMessage aSecondDDMessage |
aDDAuthor := DDAuthor new.
aDDMessage := DDMessage new.
aSecondDDMessage := DDMessage new.

aDDMessage createdAt: '05-06-23'.
aSecondDDMessage createdAt: '04-06-23'.

aDDAuthor addSentMessage: aDDMessage.
aDDAuthor addSentMessage: aSecondDDMessage.

self assert: aDDAuthor lastMessage equals: aDDMessage.
]

{ #category : #test }
DDAuthorTest >> testLastMessageSorted [
"This method checks if firstMessageSorted returns the DDAuthors in a correct oreder basaed on their sent messages"

| aFirstDDAuthor aSecondDDAuthor aFirstDDMessage aSecondDDMessage anOrderedCollection aCollectionOfDDAuthor |
aFirstDDAuthor := DDAuthor new.
aSecondDDAuthor := DDAuthor new.
aFirstDDMessage := DDMessage new.
aSecondDDMessage := DDMessage new.
anOrderedCollection := OrderedCollection new.
aCollectionOfDDAuthor := OrderedCollection new.

aFirstDDAuthor addSentMessage: aFirstDDMessage.
aFirstDDMessage createdAt: '01-04-22'.
aSecondDDAuthor addSentMessage: aSecondDDMessage.
aSecondDDMessage createdAt: '01-02-21'.

anOrderedCollection add: aFirstDDAuthor.
anOrderedCollection add: aSecondDDAuthor.

aCollectionOfDDAuthor add: aSecondDDAuthor.
aCollectionOfDDAuthor add: aFirstDDAuthor.

self assert: (DDAuthor firstMessageSorted: aCollectionOfDDAuthor ) equals: anOrderedCollection.
]

{ #category : #test }
DDAuthorTest >> testMergedInto [
"This method checks mergedInto getter and setter works given an input"
Expand Down Expand Up @@ -384,6 +587,26 @@ DDAuthorTest >> testMessageCreationDates2 [
self assert: aDDAuthor sentMessages equals: anOrderedCollection.


]

{ #category : #test }
DDAuthorTest >> testMessageCreationDates3 [
"This method checks if messageCreationDates' works initializing the sentMessages array and without mocking the DDMessage class"

| aDDAuthor aDDMessage anOrderedCollection |
aDDAuthor := DDAuthor new.
aDDMessage := DDMessage new.
anOrderedCollection := OrderedCollection new.

aDDMessage author: aDDAuthor.
aDDMessage createdAt: '05/02/23'.
aDDAuthor addSentMessage: aDDMessage.
aDDAuthor messageCreationDates.
anOrderedCollection add: aDDMessage.

self assert: aDDAuthor sentMessages equals: anOrderedCollection.


]

{ #category : #test }
Expand Down Expand Up @@ -417,6 +640,26 @@ DDAuthorTest >> testMessagesByDay2 [
self assert: aDDAuthor sentMessages equals: anOrderedCollection.


]

{ #category : #test }
DDAuthorTest >> testMessagesByDay3 [
"This method checks if messagesByDay's method works if sentMessages is initialized without mocking the DDMessage class"

| aDDAuthor aDDMessage anOrderedCollection |
aDDAuthor := DDAuthor new.
aDDMessage := DDMessage new.
anOrderedCollection := OrderedCollection new.

aDDMessage author: aDDAuthor.
aDDMessage createdAt: '05/02/23'.
aDDAuthor messagesByDay.
aDDAuthor addSentMessage: aDDMessage.
anOrderedCollection add: aDDMessage.

self assert: aDDAuthor sentMessages equals: anOrderedCollection.


]

{ #category : #test }
Expand All @@ -441,6 +684,18 @@ DDAuthorTest >> testNickname2 [
self assert: aDDAuthor nickname equals: 'user-nickname'.
]

{ #category : #test }
DDAuthorTest >> testNormalizedName [
"This method checks if normalizedName correctly modify a DDAuthor's name"

| aDDAuthor |
aDDAuthor := DDAuthor new.

aDDAuthor name: 'IaMaFuLlNaMe'.

self assert: (DDAuthor normalizedName: 'IaMaFuLlNaMe') equals: 'iamafullname'.
]

{ #category : #test }
DDAuthorTest >> testNumberOfSentMessages [
"This method checks if the numerOfMessages works if aDDAuthor does not send messages"
Expand Down
Loading

0 comments on commit 05abb31

Please sign in to comment.