public void Given1TonAnd1000Kg_ForCompare_shouldReturnTrue()
        {
            WeightQuantity tonObject      = new WeightQuantity("ton", 1);
            WeightQuantity kilogramObject = new WeightQuantity("kg", 1000);

            Assert.IsTrue(this.compare.CompareWeight(tonObject, kilogramObject));
        } //// end : public void Given1TonAnd1000Kg_ForCompare_shouldReturnTrue()
        public void Given1TonAnd1000Kg_ForSum_shouldReturn1001Kg()
        {
            WeightQuantity tonObject  = new WeightQuantity("ton", 1);
            WeightQuantity gramObject = new WeightQuantity("gram", 1000);

            Assert.AreEqual(1001, Calculate.AddToKg(tonObject, gramObject));
        } //// end : public void Given1TonAnd1000Kg_ForCompare_shouldReturnTrue()
        public void Given1KgAnd1000Grams_ForCompare_shouldReturnTrue()
        {
            WeightQuantity kilogramObject = new WeightQuantity("kg", 1);
            WeightQuantity gramObject     = new WeightQuantity("gram", 1000);

            Assert.IsTrue(this.compare.CompareWeight(kilogramObject, gramObject));
        } //// end : public void Given1KgAnd1000Grams_ForCompare_shouldReturnTrue()
Esempio n. 4
0
        } //// end  : public static double AddToLiters(VolumeQuantity quantityOne, VolumeQuantity quantityTwo)

        /// <summary>
        /// method to add two Weight quantities
        /// </summary>
        /// <param name="quantityOne"> first value </param>
        /// <param name="quantityTwo"> second value </param>
        /// <returns> sum in kg </returns>
        public static double AddToKg(WeightQuantity quantityOne, WeightQuantity quantityTwo)
        {
            try
            {
                if (quantityOne.Unit != 0 && quantityTwo.Unit != 0)
                {
                    return((((double)quantityOne.Unit / (double)WeightUnits.kg) * quantityOne.Weight) + (((double)quantityTwo.Unit / (double)WeightUnits.kg) * quantityTwo.Weight));
                }
                else
                {
                    throw new ArgumentOutOfRangeException();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
                throw;
            }
        } //// end  : public static double AddToKg(WeightQuantity quantityOne, WeightQuantity quantityTwo)
Esempio n. 5
0
        } //// end : public bool CompareVolume(VolumeQuantity quantityOne, VolumeQuantity quantityTwo)

        /// <summary>
        /// method to compare two volume quantities
        /// </summary>
        /// <param name="quantityOne"> quantity one to compare </param>
        /// <param name="quantityTwo"> quantity two to compare </param>
        /// <returns> true or false </returns>
        public bool CompareWeight(WeightQuantity quantityOne, WeightQuantity quantityTwo)
        {
            try
            {
                // checking if quantity unit is not 0, if yes return the inner statement
                // if not : return false
                if (quantityOne.Unit != 0 && quantityTwo.Unit != 0)
                {
                    return((int)quantityOne.Unit * quantityOne.Weight == (int)quantityTwo.Unit * quantityTwo.Weight);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
                throw;
            }
        } //// end : public bool CompareWeight(WeightQuantity quantityOne, WeightQuantity quantityTwo)