Skip to content

Commit

Permalink
further tests for extended base agent
Browse files Browse the repository at this point in the history
  • Loading branch information
MattSScott committed Sep 24, 2023
1 parent d805f8f commit 373be98
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pkg/testing/testAgents/baseExtendedAgent/baseExtendedAgent.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ func (ag *BaseExtendedAgent) GetPhrase() string {

func (ag *BaseExtendedAgent) HandleGreetingMessage(GreetingMessage) {}

func GetBaseAgent(phrase string) *BaseExtendedAgent {
func GetBaseExtendedAgent(phrase string) *BaseExtendedAgent {
return &BaseExtendedAgent{
BaseAgent: baseAgent.NewBaseAgent[IExtendedAgent](),
phrase: phrase,
}

}

//returns a default implementation of IExtendedAgent
// returns a default implementation of IExtendedAgent
func GetNewIExtendedAgent(phrase string) IExtendedAgent {
return &BaseExtendedAgent{
BaseAgent: baseAgent.NewBaseAgent[IExtendedAgent](),
Expand Down
20 changes: 16 additions & 4 deletions pkg/testing/testAgents/baseExtendedAgent/baseExtendedAgent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,32 @@ import (

baseExtendedAgent "github.com/MattSScott/basePlatformSOMAS/pkg/testing/testAgents/baseExtendedAgent"
"github.com/google/uuid"


)

func TestGetNewIExtendedAgent(t *testing.T) {
iagent := baseExtendedAgent.GetNewIExtendedAgent("teststring")
phrase := iagent.GetPhrase()
id := iagent.GetID()

if phrase != "teststring"{
if phrase != "teststring" {
t.Error("Unsuccessful default implementation of IExtendedAgent due to string mismatch")
}

if id == uuid.Nil {
t.Error("Unsuccessful default implementation of IExtendedAgent due to Nil ID")
}
}
}

func TestGetBaseExtendedAgent(t *testing.T) {
iagent := baseExtendedAgent.GetBaseExtendedAgent("teststring")
phrase := iagent.GetPhrase()
id := iagent.GetID()

if phrase != "teststring" {
t.Error("Unsuccessful default implementation of IExtendedAgent due to string mismatch")
}

if id == uuid.Nil {
t.Error("Unsuccessful default implementation of IExtendedAgent due to Nil ID")
}
}
2 changes: 1 addition & 1 deletion pkg/testing/testAgents/helloAgent/helloAgent.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ func (ha *HelloAgent) HandleGreetingMessage(msg baseExtendedAgent.GreetingMessag

func GetHelloAgent() baseExtendedAgent.IExtendedAgent {
return &HelloAgent{
BaseExtendedAgent: baseExtendedAgent.GetBaseAgent("hello"),
BaseExtendedAgent: baseExtendedAgent.GetBaseExtendedAgent("hello"),
}
}
2 changes: 1 addition & 1 deletion pkg/testing/testAgents/worldAgent/worldAgent.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ func (wa *WorldAgent) HandleGreetingMessage(msg baseExtendedAgent.GreetingMessag

func GetWorldAgent() baseExtendedAgent.IExtendedAgent {
return &WorldAgent{
BaseExtendedAgent: baseExtendedAgent.GetBaseAgent("wello"),
BaseExtendedAgent: baseExtendedAgent.GetBaseExtendedAgent("wello"),
}
}

0 comments on commit 373be98

Please sign in to comment.