diff --git a/usecases/cs/lpc/usecase_test.go b/usecases/cs/lpc/usecase_test.go index 75eda834..89d91461 100644 --- a/usecases/cs/lpc/usecase_test.go +++ b/usecases/cs/lpc/usecase_test.go @@ -27,12 +27,12 @@ func (s *CsLPCSuite) Test_loadControlServerAndLimitId() { } func (s *CsLPCSuite) Test_loadControlWriteCB() { - msg := spineapi.Message{} + msg0 := &spineapi.Message{} - s.sut.loadControlWriteCB(&msg) + s.sut.loadControlWriteCB(msg0) assert.False(s.T(), s.eventCalled) - msg = spineapi.Message{ + msg1 := &spineapi.Message{ RequestHeader: &model.HeaderType{ MsgCounter: util.Ptr(model.MsgCounterType(500)), }, @@ -43,75 +43,96 @@ func (s *CsLPCSuite) Test_loadControlWriteCB() { EntityRemote: s.monitoredEntity, } - msg0 := msg - s.sut.loadControlWriteCB(&msg0) + s.sut.loadControlWriteCB(msg1) + assert.False(s.T(), s.eventCalled) - msg1 := msg - msg1.RequestHeader.MsgCounter = util.Ptr(model.MsgCounterType(501)) - msg1.Cmd = model.CmdType{ - LoadControlLimitListData: &model.LoadControlLimitListDataType{ - LoadControlLimitData: []model.LoadControlLimitDataType{}, + msg2 := &spineapi.Message{ + RequestHeader: &model.HeaderType{ + MsgCounter: util.Ptr(model.MsgCounterType(501)), }, + Cmd: model.CmdType{ + LoadControlLimitListData: &model.LoadControlLimitListDataType{ + LoadControlLimitData: []model.LoadControlLimitDataType{}, + }, + }, + DeviceRemote: s.remoteDevice, + EntityRemote: s.monitoredEntity, } - s.sut.loadControlWriteCB(&msg1) + s.sut.loadControlWriteCB(msg2) assert.False(s.T(), s.eventCalled) - msg2 := msg - msg2.RequestHeader.MsgCounter = util.Ptr(model.MsgCounterType(502)) - msg2.Cmd = model.CmdType{ - LoadControlLimitListData: &model.LoadControlLimitListDataType{ - LoadControlLimitData: []model.LoadControlLimitDataType{ - {}, + msg3 := &spineapi.Message{ + RequestHeader: &model.HeaderType{ + MsgCounter: util.Ptr(model.MsgCounterType(502)), + }, + Cmd: model.CmdType{ + LoadControlLimitListData: &model.LoadControlLimitListDataType{ + LoadControlLimitData: []model.LoadControlLimitDataType{ + {}, + }, }, }, + DeviceRemote: s.remoteDevice, + EntityRemote: s.monitoredEntity, } - s.sut.loadControlWriteCB(&msg2) + s.sut.loadControlWriteCB(msg3) assert.False(s.T(), s.eventCalled) - msg3 := msg - msg3.RequestHeader.MsgCounter = util.Ptr(model.MsgCounterType(503)) - msg3.Cmd = model.CmdType{ - LoadControlLimitListData: &model.LoadControlLimitListDataType{ - LoadControlLimitData: []model.LoadControlLimitDataType{ - { - LimitId: util.Ptr(model.LoadControlLimitIdType(0)), - IsLimitActive: util.Ptr(true), - Value: model.NewScaledNumberType(1000), - TimePeriod: model.NewTimePeriodTypeWithRelativeEndTime(time.Minute * 2), + msg4 := &spineapi.Message{ + RequestHeader: &model.HeaderType{ + MsgCounter: util.Ptr(model.MsgCounterType(503)), + }, + Cmd: model.CmdType{ + LoadControlLimitListData: &model.LoadControlLimitListDataType{ + LoadControlLimitData: []model.LoadControlLimitDataType{ + { + LimitId: util.Ptr(model.LoadControlLimitIdType(0)), + IsLimitActive: util.Ptr(true), + Value: model.NewScaledNumberType(1000), + TimePeriod: model.NewTimePeriodTypeWithRelativeEndTime(time.Minute * 2), + }, }, }, }, + DeviceRemote: s.remoteDevice, + EntityRemote: s.monitoredEntity, } - s.sut.loadControlWriteCB(&msg3) + s.sut.loadControlWriteCB(msg4) assert.True(s.T(), s.eventCalled) + s.eventCalled = false - msg4 := msg - msg4.RequestHeader.MsgCounter = util.Ptr(model.MsgCounterType(504)) - msg4.Cmd = model.CmdType{ - Filter: []model.FilterType{ - { - CmdControl: &model.CmdControlType{ - Partial: util.Ptr(model.ElementTagType{}), - }, - }, + msg5 := &spineapi.Message{ + RequestHeader: &model.HeaderType{ + MsgCounter: util.Ptr(model.MsgCounterType(504)), }, - LoadControlLimitListData: &model.LoadControlLimitListDataType{ - LoadControlLimitData: []model.LoadControlLimitDataType{ + Cmd: model.CmdType{ + Filter: []model.FilterType{ { - LimitId: util.Ptr(model.LoadControlLimitIdType(0)), - IsLimitActive: util.Ptr(true), - Value: model.NewScaledNumberType(5000), - TimePeriod: model.NewTimePeriodTypeWithRelativeEndTime(time.Hour * 3), + CmdControl: &model.CmdControlType{ + Partial: util.Ptr(model.ElementTagType{}), + }, }, }, - }, + LoadControlLimitListData: &model.LoadControlLimitListDataType{ + LoadControlLimitData: []model.LoadControlLimitDataType{ + { + LimitId: util.Ptr(model.LoadControlLimitIdType(0)), + IsLimitActive: util.Ptr(true), + Value: model.NewScaledNumberType(5000), + TimePeriod: model.NewTimePeriodTypeWithRelativeEndTime(time.Hour * 3), + }, + }, + }}, + DeviceRemote: s.remoteDevice, + EntityRemote: s.monitoredEntity, } - s.sut.loadControlWriteCB(&msg4) + s.sut.loadControlWriteCB(msg5) assert.True(s.T(), s.eventCalled) + s.eventCalled = false } func (s *CsLPCSuite) Test_UpdateUseCaseAvailability() {