/***************************************************
 ** @author   STF 487
 ** @version  0.0.1
 ** @purpose  1:15.8, Ensure that decoded content match is allowed for present template restriction
 ** @verdict  pass accept, ttcn3verdict:pass
 ***************************************************/


module Sem_1508_TemplateRestrictions_049 {

  type record MessageType {
    hexstring payload
  }

  type record Mymessage {
    integer field1,
    bitstring field2 optional
  }


  type port loopbackPort message{inout MessageType};


  type component GeneralComp {
    port loopbackPort messagePort
  }

  testcase TC_Sem_1508_TemplateRestrictions_049() runs on GeneralComp {
    var bitstring v_enc;
    var Mymessage v_testMessage;
    var MessageType Message;
    template (present) MessageType mw_matchingTemplate := {
      payload :=  decmatch Mymessage: {field1:= 10, field2 := '1001'B}
    }

    v_testMessage := {
      field1 := 10,
      field2 := '1001'B
    }

    Message.payload := bit2hex(encvalue(v_testMessage));		//encode message to payload

    messagePort.send(Message);	//send message

    alt {
      [] messagePort.receive(mw_matchingTemplate) {
        setverdict(pass);
      }
      [] messagePort.receive {
        setverdict(fail,mw_matchingTemplate);
      }
    }
  }

  control{
    execute(TC_Sem_1508_TemplateRestrictions_049());
  }

}
