/***************************************************
 ** @author   STF 470
 ** @version  0.0.1
 ** @purpose  1:21.1.2, Ensure that unmap operation with one component port as a parameter works correctly
 ** @verdict  pass accept, ttcn3verdict:pass
 ***************************************************/

// The following requirements are tested:
// To ease ... map operations related to all ... mappings of ... a port, it is
// allowed to use ... unmap operations with one argument only. This one argument
// specifies one side of the connections to be ... unmapped.

module Sem_210102_disconnect_and_unmap_operations_006 {

    type port P message {
        inout integer
    }

    type component GeneralComp
    {
        port P p;
    }

	function checkMapped(boolean p_stateActive) runs on GeneralComp
	{
		if(p.checkstate("Mapped") xor not p_stateActive) {
			setverdict(pass);
		} else {
			setverdict(fail);
		}
	}

    testcase TC_Sem_210102_disconnect_and_unmap_operations_006() runs on GeneralComp system GeneralComp {
		var GeneralComp v_ptc1 := GeneralComp.create;

		map(self:p, system:p);
		map(v_ptc1:p, system:p);

		unmap(v_ptc1:p);

		// verity that ports are really unmapped
        checkMapped(true); // still mapped to system:p
        v_ptc1.start(checkMapped(false)); // no active mapping
		all component.done;
    }
    control{
        execute(TC_Sem_210102_disconnect_and_unmap_operations_006());
    }
}

