Exemple #1
0
        public void Constructor3ShouldStoreAndPrintValueAndSymbolWithPounds()
        {
            WaterContent        wc  = new WaterContent(.1);
            WeightOfSolidMatter wsm = new WeightOfSolidMatter(10, WeightUnits.Grams);
            WeightOfWater       ww  = new WeightOfWater(wc, wsm, WeightUnits.Pounds);

            Assert.AreEqual(Math.Round(ww.NumericValue, 4), .0022);
            Assert.AreEqual(ww.UnitOfMeasure, WeightUnits.Pounds);
        }
        public void Constructor1ShouldStoreAndPrintValueAndSymbol()
        {
            WaterContent wc            = new WaterContent(.1);
            String       correctAnswer = "w = 10 %";

            Assert.AreEqual("w", wc.Symbol);
            Assert.AreEqual(wc.NumericValue, .1);
            Assert.AreEqual(correctAnswer, wc.ToString());
        }
        public void Constructor3ShouldStoreAndPrintValueAndSymbolWithKilograms()
        {
            WaterContent        wc  = new WaterContent(.1);
            WeightOfWater       ww  = new WeightOfWater(10, WeightUnits.Grams);
            WeightOfSolidMatter wsm = new WeightOfSolidMatter(wc, ww, WeightUnits.Kilograms);

            Assert.AreEqual(Math.Round(wsm.NumericValue, 2), .10);
            Assert.AreEqual(wsm.UnitOfMeasure, WeightUnits.Kilograms);
        }
        public void Constructor2ShouldStoreAndPrintValueAndSymbol()
        {
            WeightOfSolidMatter wsm = new WeightOfSolidMatter(10, WeightUnits.Kilograms);
            WeightOfWater       ww  = new WeightOfWater(10000, WeightUnits.Grams);
            WaterContent        wc  = new WaterContent(wsm, ww);
            String correctAnswer    = "w = 100 %";

            Assert.AreEqual("w", wc.Symbol);
            Assert.AreEqual(wc.NumericValue, 1);
            Assert.AreEqual(correctAnswer, wc.ToString());
        }
Exemple #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WeightOfSolidMatter"/> class.
 /// </summary>
 /// <param name="waterContent">w in w=W_w/W_s.</param>
 /// <param name="waterWeight">W_w in w=W_w/W_s.</param>
 /// <param name="units">Measurement unit to hold value after initial calculation (ie kg).</param>
 public WeightOfSolidMatter(WaterContent waterContent, WeightOfWater waterWeight, WeightUnits units)
     : this(BaseWeightScalar.ConvertToUnits(waterWeight, units).NumericValue / waterContent.NumericValue, units)
 {
 }