package se.raddo.raddose3D.tests;

import se.raddo.raddose3D.ContainerMixture;

import static org.testng.Assert.assertTrue;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import se.raddo.raddose3D.Beam;
import se.raddo.raddose3D.BeamTophat;
import se.raddo.raddose3D.ContainerElemental;

public class ContainerTests {
  public void testTransparency() {
    ContainerMixture containerMix = new ContainerMixture(0.0, 2.23, "pyrex");
    
    List<String> containerElementNames = new ArrayList<String>();
    List<Double> containerElementNums = new ArrayList<Double>();
    
    containerElementNames.add("S");
    containerElementNames.add("O");
    containerElementNums.add(1.0);
    containerElementNums.add(2.0);
    ContainerElemental containerElem = new ContainerElemental(0.0, 2.65, 
        containerElementNames, containerElementNums);
    
    Map<Object, Object> beamProperties = new HashMap<Object, Object>();
    beamProperties.put(Beam.BEAM_COLL_H, 80.);
    beamProperties.put(Beam.BEAM_COLL_V, 80.);
    beamProperties.put(Beam.BEAM_FLUX, 9.281e8);
    beamProperties.put(Beam.BEAM_ENERGY, 8.05);
    Beam b = new BeamTophat(beamProperties);
    
    containerMix.calculateContainerAttenuation(b);
    containerElem.calculateContainerAttenuation(b);
    
    boolean zeroContainerAttenuationFractionMix = false;
    if (containerMix.getContainerAttenuationFraction() < 1e-6) {
      zeroContainerAttenuationFractionMix = true;
    }
    assertTrue(zeroContainerAttenuationFractionMix, "Zero mixture thickness results in non-negligible container attenuation");
    
    boolean zeroContainerAttenuationFractionElem = false;
    if (containerElem.getContainerAttenuationFraction() < 1e-6) {
      zeroContainerAttenuationFractionElem = true;
    }
    assertTrue(zeroContainerAttenuationFractionElem, "Zero elemental thickness results in non-negligible container attenuation");
  }
}

@@ -365,16 +365,177 @@
 Tests %7B%0A
+  /**%0A   * Check that when the container thickness is zero, the X-ray beam is not %0A   * attenuated at all i.e. the container attenuation fraction is zero.%0A   */%0A
   public
@@ -2101,10 +2101,1652 @@
 %22);%0A  %7D%0A
+  %0A  /**%0A   * Check that the mass attenuation coefficient of alanine is the same when%0A   * calculated using the constituent elemental composition and when you%0A   * use the mixture definition directly from the NIST tables.%0A   */%0A  public void testElementalMatchesMixture() %7B%0A    ContainerMixture containerMix = new ContainerMixture(50.0, 1.424, %22alanine%22);%0A    %0A    List%3CString%3E containerElementNames = new ArrayList%3CString%3E();%0A    List%3CDouble%3E containerElementNums = new ArrayList%3CDouble%3E();%0A    %0A    containerElementNames.add(%22H%22);%0A    containerElementNames.add(%22C%22);%0A    containerElementNames.add(%22N%22);%0A    containerElementNames.add(%22O%22);%0A    containerElementNums.add(7.0);%0A    containerElementNums.add(3.0);%0A    containerElementNums.add(1.0);%0A    containerElementNums.add(2.0);%0A    ContainerElemental containerElem = new ContainerElemental(50.0, 1.424, %0A        containerElementNames, containerElementNums);%0A    %0A    Map%3CObject, Object%3E beamProperties = new HashMap%3CObject, Object%3E();%0A    beamProperties.put(Beam.BEAM_COLL_H, 80.);%0A    beamProperties.put(Beam.BEAM_COLL_V, 80.);%0A    beamProperties.put(Beam.BEAM_FLUX, 9.281e8);%0A    beamProperties.put(Beam.BEAM_ENERGY, 8.05);%0A    Beam b = new BeamTophat(beamProperties);%0A    %0A    containerMix.calculateContainerAttenuation(b);%0A    containerElem.calculateContainerAttenuation(b);%0A    %0A    boolean equalMassAttenuation = false; %0A    if (containerMix.getMassAttenuationCoefficient() - containerElem.getMassAttenuationCoefficient() %3C 1e-2) %7B%0A      equalMassAttenuation = true;%0A    %7D%0A    assertTrue(equalMassAttenuation,%22Mass attenuation of mixture and elemental components don't agree.%22);%0A  %7D%0A
 %7D%0A

add another test for the container class.