<?xml version="1.0" encoding="UTF-8"?>

<test-data
    xmlns="http://pmd.sourceforge.net/rule-tests"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests http://pmd.sourceforge.net/rule-tests_1_0_0.xsd">

    <test-code>
        <description>Directly accessing the Trigger.old map.</description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
trigger AccountTrigger on Account (before insert, before update) {
   Account a = Trigger.new[0]; //Bad: Accessing the trigger array directly is not recommended.
}
		]]></code>
	</test-code>

    <test-code>
        <description>Looping through map, best practice</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
trigger AccountTrigger on Account (before insert, before update) {
   foreach ( Account a : Trigger.new ){   
        //Good: Iterate through the trigger.new array instead.
        system.debug(a);
   }
}
		]]></code>
    </test-code>

    <test-code>
        <description>Regression issue #792</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
class NotATrigger {
   void foo(){
        Account[] accounts = opportunity.Accounts[0];
   }
}

		]]></code>
    </test-code>
    
</test-data>
