Skip to content

Commit

Permalink
Add NodeManagementUseCaseDataType tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DerAndereAndi committed Jan 8, 2024
1 parent 79271ff commit d64f096
Showing 1 changed file with 123 additions and 0 deletions.
123 changes: 123 additions & 0 deletions spine/model/nodemanagement_additions_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
package model

import (
"testing"

"github.com/enbility/eebus-go/util"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)

func TestNodeManagementUseCaseDataTypeSuite(t *testing.T) {
suite.Run(t, new(NodeManagementUseCaseDataTypeSuite))
}

type NodeManagementUseCaseDataTypeSuite struct {
suite.Suite
}

func (s *NodeManagementUseCaseDataTypeSuite) SetupSuite() {}
func (s *NodeManagementUseCaseDataTypeSuite) TearDownTest() {}

func (s *NodeManagementUseCaseDataTypeSuite) BeforeTest(suiteName, testName string) {}

func (s *NodeManagementUseCaseDataTypeSuite) Test_AdditionsAndRemovals() {
ucs := &NodeManagementUseCaseDataType{}
assert.NotNil(s.T(), ucs)
assert.Equal(s.T(), 0, len(ucs.UseCaseInformation))

address := FeatureAddressType{
Device: util.Ptr(AddressDeviceType("test")),
Entity: []AddressEntityType{1},
}
ucs.AddUseCaseSupport(
address,
UseCaseActorTypeCEM,
UseCaseNameTypeControlOfBattery,
SpecificationVersionType(""),
"",
true,
[]UseCaseScenarioSupportType{},
)
assert.Equal(s.T(), 1, len(ucs.UseCaseInformation))
assert.Equal(s.T(), 1, len(ucs.UseCaseInformation[0].UseCaseSupport))

ucs.AddUseCaseSupport(
address,
UseCaseActorTypeCEM,
UseCaseNameTypeEVSECommissioningAndConfiguration,
SpecificationVersionType(""),
"",
true,
[]UseCaseScenarioSupportType{},
)
assert.Equal(s.T(), 1, len(ucs.UseCaseInformation))
assert.Equal(s.T(), 2, len(ucs.UseCaseInformation[0].UseCaseSupport))

ucs.AddUseCaseSupport(
address,
UseCaseActorTypeCEM,
UseCaseNameTypeEVSECommissioningAndConfiguration,
SpecificationVersionType(""),
"",
true,
[]UseCaseScenarioSupportType{},
)
assert.Equal(s.T(), 1, len(ucs.UseCaseInformation))
assert.Equal(s.T(), 2, len(ucs.UseCaseInformation[0].UseCaseSupport))

ucs.AddUseCaseSupport(
address,
UseCaseActorTypeEnergyGuard,
UseCaseNameTypeLimitationOfPowerConsumption,
SpecificationVersionType(""),
"",
true,
[]UseCaseScenarioSupportType{},
)
assert.Equal(s.T(), 2, len(ucs.UseCaseInformation))
assert.Equal(s.T(), 2, len(ucs.UseCaseInformation[0].UseCaseSupport))
assert.Equal(s.T(), 1, len(ucs.UseCaseInformation[1].UseCaseSupport))

ucs.RemoveUseCaseSupport(
address,
UseCaseActorTypeCEM,
UseCaseNameTypeEVChargingSummary,
)
assert.Equal(s.T(), 2, len(ucs.UseCaseInformation))
assert.Equal(s.T(), 2, len(ucs.UseCaseInformation[0].UseCaseSupport))

ucs.RemoveUseCaseSupport(
address,
UseCaseActorTypeCEM,
UseCaseNameTypeControlOfBattery,
)
assert.Equal(s.T(), 2, len(ucs.UseCaseInformation))
assert.Equal(s.T(), 1, len(ucs.UseCaseInformation[0].UseCaseSupport))

ucs.RemoveUseCaseSupport(
address,
UseCaseActorTypeCEM,
UseCaseNameTypeEVSECommissioningAndConfiguration,
)
assert.Equal(s.T(), 1, len(ucs.UseCaseInformation))

ucs.RemoveUseCaseSupport(
address,
"",
"",
)
assert.Equal(s.T(), 1, len(ucs.UseCaseInformation))

invalidAddress := FeatureAddressType{
Device: util.Ptr(AddressDeviceType("test")),
Entity: []AddressEntityType{2},
}
ucs.RemoveUseCaseSupport(
invalidAddress,
UseCaseActorTypeCEM,
UseCaseNameTypeEVSECommissioningAndConfiguration,
)
assert.Equal(s.T(), 1, len(ucs.UseCaseInformation))

}

0 comments on commit d64f096

Please sign in to comment.