package test.microlevel.tonicfiring;
import static org.junit.Assert.*
import java.util.*;
import repast.simphony.*;
import motorunit.*;
import umontreal.iro.lecuyer.randvar.
                               RandomVariateGen;
public class TonicFiringTester extends TesterAgent {
  private RunningNeuron motorNeuron;
  private FakeNeuron fakeNeuron;
  ...
  public TonicFiringTester() {
    motorNeuron = (RunningNeuron) 
       getTestEnvironment().getAgent("Motorneuron");
    fakeNeuron = (FakeNeuron)
        getTestEnvironment().getAgent("FakeNeuron");
    ...
  }
  ...
  @ScheduledMethod(start = ScheduleParameters.END)
  public void testTonicFiringOfMotorNeuron() {
    // motorneuron has to generate some spikes.
    assertTrue(motorNeuronSpikes.size() > 0);

    Vector<Double> isiV = ISIDistribution.
     getInstance().calculateISI(motorNeuronSpikes);
    RandomVariateGen rvgSim = 
       RandomVariateGenFactory.getGenerator(isiV);
    assertNotNull(rvgSim);
    RandomVariateGen rvgExp = 
                        motorNeuron.getRandomGen();
    assertNotNull(rvgExp);
    // distribution should be the same
    assertEquals(rvgExp.getClass().getName(), 
                     rvgSim.getClass().getName());

    Distribution dExp = rvgExp.getDistribution();
    Distribution dSim = rvgSim.getDistribution();
    // alpha parameters should be close
    double alphaExp = dExp.getParams()[0];
    double alphaSim = dSim.getParams()[0];
    assertEquals(alphaExp, alphaSim, 0.1);
    // gamma parameters should be close
    double gammaExp = dExp.getParams()[1];
    double gammaSim = dSim.getParams()[1];
    assertEquals(gammaExp, gammaSim, 0.1);
  }
  @ScheduledMethod(start = ScheduleParameters.END)
  public void testConductionOfSpikes() {    
    for (int i = 0; i < fnActivities.size(); i++) {
      double axonalDelay = fnActivities.get(i)
 	- mnSpikes.get(i);
      assertEquals(10.0, axonalDelay, 0.0);
    }
  }
}
