Beispiel #1
0
        public void Constructor2ShouldStoreAndPrintValueAndSymbolWithPounds()
        {
            WeightOfSolidMatter wsm = new WeightOfSolidMatter(10, WeightUnits.Grams);
            TotalWeight         tw  = new TotalWeight(20, WeightUnits.Grams);
            WeightOfWater       ww  = new WeightOfWater(wsm, tw, WeightUnits.Pounds);

            Assert.AreEqual(Math.Round(ww.NumericValue, 3), 0.022);
            Assert.AreEqual(ww.UnitOfMeasure, WeightUnits.Pounds);
        }
Beispiel #2
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 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 Constructor2ShouldStoreAndPrintValueAndSymbolWithKilograms()
        {
            WeightOfWater       ww  = new WeightOfWater(10, WeightUnits.Grams);
            TotalWeight         tw  = new TotalWeight(20, WeightUnits.Grams);
            WeightOfSolidMatter wsm = new WeightOfSolidMatter(ww, tw, WeightUnits.Kilograms);

            Assert.AreEqual(Math.Round(wsm.NumericValue, 2), .01);
            Assert.AreEqual(wsm.UnitOfMeasure, WeightUnits.Kilograms);
        }
Beispiel #5
0
        public void Constructor1ShouldStoreAndPrintValueAndSymbol()
        {
            WeightOfWater ww            = new WeightOfWater(10, WeightUnits.Grams);
            String        correctAnswer = "W_w = 10 g";

            Assert.AreEqual("W_w", ww.Symbol);
            Assert.AreEqual(ww.NumericValue, 10);
            Assert.AreEqual(ww.UnitOfMeasure, WeightUnits.Grams);
            Assert.AreEqual(correctAnswer, ww.ToString());
        }
        public void Constructor2ShouldStoreAndPrintValueAndSymbolWithPoundPerFootCubed()
        {
            WeightOfWater     ww  = new WeightOfWater(10, WeightUnits.Grams);
            WaterVolume       wv  = new WaterVolume(10, VolumeUnits.CubicCentimeters);
            UnitWeightOfWater uww = new UnitWeightOfWater(ww, wv, UnitWeightUnits.PoundPerCubicFoot);

            Assert.AreEqual(Math.Round(uww.NumericValue, 1), 62.4);
            Assert.AreEqual(uww.UnitOfMeasure, UnitWeightUnits.PoundPerCubicFoot);
            Assert.AreEqual(uww.Symbol, "𝛾_w");
        }
        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());
        }
Beispiel #8
0
        public void Constructor2ShouldStoreAndPrintValueAndSymbolWithGrams()
        {
            WeightOfSolidMatter wsm = new WeightOfSolidMatter(10, WeightUnits.Grams);
            TotalWeight         tw  = new TotalWeight(20, WeightUnits.Grams);
            WeightOfWater       ww  = new WeightOfWater(wsm, tw, WeightUnits.Grams);
            String correctAnswer    = "W_w = 10 g";

            Assert.AreEqual("W_w", ww.Symbol);
            Assert.AreEqual(ww.NumericValue, 10);
            Assert.AreEqual(ww.UnitOfMeasure, WeightUnits.Grams);
            Assert.AreEqual(correctAnswer, ww.ToString());
        }
Beispiel #9
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)
 {
 }
Beispiel #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WeightOfSolidMatter"/> class.
 /// </summary>
 /// <param name="waterWeight">W_w in W=W_w+W_s.</param>
 /// <param name="totalWeight">W in W=W_w+W_s.</param>
 /// <param name="units">Measurement unit to hold value after initial calculation (ie kg).</param>
 public WeightOfSolidMatter(WeightOfWater waterWeight, TotalWeight totalWeight, WeightUnits units)
     : this(ConvertToUnits(totalWeight, units).NumericValue - ConvertToUnits(waterWeight, units).NumericValue, units)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="UnitWeightOfWater"/> class.
 /// </summary>
 /// <param name="waterWeight">W_w in gamma_w=W_w/V_w.</param>
 /// <param name="waterVolume">V_w in gamma_w=W_w/V_w.</param>
 /// <param name="units">Measurement system to hold value in after calculation.</param>
 public UnitWeightOfWater(WeightOfWater waterWeight, WaterVolume waterVolume, UnitWeightUnits units)
     : this(ConvertToUnits(new BaseUnitWeightScalar("𝛾", BaseWeightScalar.ConvertToUnits(waterWeight, WeightUnits.Kilograms).NumericValue / BaseVolumeScalar.ConvertToUnits(waterVolume, VolumeUnits.CubicMeters).NumericValue, UnitWeightUnits.KilogramPerMeterCubed), units).NumericValue, units)
 {
 }