/** * This operation checks the Material class to make sure that simple attributes such as names and * properties can be changed. */ @Test public void checkSimpleAttributes() { // Local Declarations Material testMaterial = TestMaterialFactory.createCO2(); // Check the name testMaterial.setName("CO2"); assertEquals("CO2", testMaterial.getName()); // Check properties - just test handling a few testMaterial.setProperty("molar mass (g/mol)", 44.01); double mass = testMaterial.getProperty("molar mass (g/mol)"); assertEquals(44.01, mass, 1.0e-16); testMaterial.setProperty("vapor pressure (MPa)", 5.73); double pressure = testMaterial.getProperty("vapor pressure (MPa)"); assertEquals(5.73, pressure, 1.0e-16); // Get all the properties and make sure they have molar mass and vapor // pressure. Map<String, Double> properties = testMaterial.getProperties(); assertTrue(properties.containsKey("molar mass (g/mol)")); assertTrue(properties.containsKey("vapor pressure (MPa)")); // Make sure that requesting a property that isn't in the map returns // 0.0. assertEquals(0.0, testMaterial.getProperty("penguin"), 1.0e-8); // Make some more test materials Material carbon = new Material(); carbon.setName("C"); Material c1 = new Material(); c1.setName("12C"); // Test the get isotopic number and get elemental name assertEquals(12, c1.getIsotopicNumber()); assertEquals(carbon.getName(), carbon.getElementalName()); assertEquals(0, carbon.getIsotopicNumber()); assertEquals(carbon.getName(), c1.getElementalName()); return; }