package internal
import (
"testing"
"github.com/stretchr/testify/assert"
)
const (
SendEsp = `
FIMS
FIMSPASS
<MSG/>
false
1
FLOP-CHDT-ORMS-FIMS
false
`
ReceiveEsp = `
FIMS
FIMSPASS
2
`
ReceiveResp string = `
<?xml version="1.0" encoding="UTF-8"?> <msg xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="unisysaodbsis.xsd"> <meta> <sndr>AODB</sndr> <seqn>820830</seqn> <dttm>20180527124442</dttm> <type>FLOP</type> <styp>ESTT</styp> </meta> <flop> <flid>10725849</flid> <ffid>CA-CA4242-A-27MAY181955-D</ffid> <estt>27MAY181945</estt> </flop> </msg>
<?xml version="1.0" encoding="UTF-8"?> <msg xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="unisysaodbsis.xsd"> <meta> <sndr>AODB</sndr> <seqn>820830</seqn> <dttm>20180527124442</dttm> <type>FLOP</type> <styp>ESTT</styp> </meta> <flop> <flid>10725849</flid> <ffid>CA-CA4242-A-27MAY181955-D</ffid> <estt>27MAY181945</estt> </flop> </msg>
`
Msg string = ` AODB 820830 20180527124442 FLOP ESTT 10725849 CA-CA4242-A-27MAY181955-D 27MAY181945 `
ErrMsg string = `soap:Serverinvalid route envent id 20Can not find the event [FLOP-ESTT-ATC-ALL1]`
)
func TestSend(t *testing.T) {
assert := assert.New(t)
// assert equality
// assert.Equal(123, 123, "they should be equal")
msg := CreateSend("FIMS", "FIMSPASS", 1, "FLOP-CHDT-ORMS-FIMS", false, "")
// println(msg)
assert.Equal(SendEsp, msg, "send post should be equal")
}
func TestReceive(t *testing.T) {
assert := assert.New(t)
msg := CreateReceive("FIMS", "FIMSPASS", 2)
assert.Equal(ReceiveEsp, msg, "receive post should be equal")
}
func TestGetMsg(t *testing.T) {
assert := assert.New(t)
msgs := GetMsgs(ReceiveResp)
assert.Equal(2, len(msgs), "should get 2 message")
assert.Equal(Msg, msgs[0], "message")
}
func TestGetErrMsg(t *testing.T) {
assert := assert.New(t)
errMsg := GetErrMsg(ErrMsg)
assert.Equal("Can not find the event [FLOP-ESTT-ATC-ALL1]", errMsg)
}