public void Given_ZeroFeetAndZeroInch_When_ShouldReturnEqual()
        {
            QuantitiyMeasurement firstFeet  = new QuantitiyMeasurement(Unit.FEET, 0.0);
            QuantitiyMeasurement secondFeet = new QuantitiyMeasurement(Unit.INCH, 0.0);

            Assert.IsTrue(this.measurement.UnitConversion(firstFeet, secondFeet));
        }
        public void GivenInch_When_SameValue_ShouldReturnTrue()
        {
            QuantitiyMeasurement firstInchValue  = new QuantitiyMeasurement(Unit.INCH, 10.0);
            QuantitiyMeasurement secondInchValue = new QuantitiyMeasurement(Unit.INCH, 10.0);

            Assert.AreEqual(firstInchValue.GetType(), secondInchValue.GetType());
        }
        public void Given_OneFeetAndOneInch_When_UnitConversiond_ShouldReturnFalse()
        {
            QuantitiyMeasurement feet1 = new QuantitiyMeasurement(Unit.FEET, 1.0);
            QuantitiyMeasurement inch1 = new QuantitiyMeasurement(Unit.INCH, 1.0);

            Assert.AreNotEqual(feet1, inch1);
        }
        public void GivenInch_When_SameReference_ShouldReturnTrue()
        {
            QuantitiyMeasurement firstReferanceInch  = new QuantitiyMeasurement();
            QuantitiyMeasurement secondReferanceInch = firstReferanceInch;

            Assert.AreEqual(firstReferanceInch, secondReferanceInch);
        }
        public void GivenFeet_When_Type_EqualToReturnTrue()
        {
            QuantitiyMeasurement firstFeetValue  = new QuantitiyMeasurement(Unit.FEET, 0.0);
            QuantitiyMeasurement secondFeetValue = new QuantitiyMeasurement(Unit.FEET, 0.0);

            Assert.AreEqual(firstFeetValue.GetType(), secondFeetValue.GetType());
        }
Пример #6
0
        /// <summary>
        /// To convert the values of the units
        /// </summary>
        /// <param name="firstUnit">First unit</param>
        /// <param name="secondUnit">Second unit</param>
        /// <returns>Condition according to comparison</returns>
        public bool UnitConversion(QuantitiyMeasurement firstUnit, QuantitiyMeasurement secondUnit)
        {
            double firstBaseUnit  = this.GetUnits(firstUnit.unitType);
            double secondBaseUnit = this.GetUnits(secondUnit.unitType);

            return(this.CompareUnits(firstUnit, secondUnit, firstBaseUnit, secondBaseUnit));
        }
Пример #7
0
        /// <summary>
        /// Addition of  unit
        /// </summary>
        /// <param name="firstUnit">first unit for addition</param>
        /// <param name="secondUnit">second unit for addition></param>
        /// <returns>addition of both units</returns>
        public double Addition(QuantitiyMeasurement firstUnit, QuantitiyMeasurement secondUnit)
        {
            double baseUnit1 = this.GetUnits(firstUnit.unitType);
            double baseUnit2 = this.GetUnits(secondUnit.unitType);

            return(Math.Round(firstUnit.value * baseUnit1) + Math.Round(secondUnit.value * baseUnit2));
        }
        public void GivenFeet_When_SameReference_ShouldReturnTrue()
        {
            QuantitiyMeasurement firstReferanceFeet  = new QuantitiyMeasurement();
            QuantitiyMeasurement secondReferanceFeet = new QuantitiyMeasurement();

            Assert.AreEqual(firstReferanceFeet, secondReferanceFeet);
        }
        public void Given_Negative1KgAnd1000Grams_WhenCompared_ShouldReturnTrue()
        {
            QuantitiyMeasurement killogram = new QuantitiyMeasurement(Unit.KILLOGRAM, -1.0);
            QuantitiyMeasurement gram      = new QuantitiyMeasurement(Unit.GRAM, 1000.0);
            bool compare = this.measurement.UnitConversion(killogram, gram);

            Assert.IsFalse(compare);
        }
        public void Given1TonAnd1000Kgs_WhenCompared_ShouldReturnTrue()
        {
            QuantitiyMeasurement tonne     = new QuantitiyMeasurement(Unit.TON, 1.0);
            QuantitiyMeasurement killogram = new QuantitiyMeasurement(Unit.KILLOGRAM, 1000.0);
            bool compare = this.measurement.UnitConversion(tonne, killogram);

            Assert.IsTrue(compare);
        }
        public void Given_1TonAnd1000Grams_WhenAdded_ShouldReturn1001Kgs()
        {
            QuantitiyMeasurement tonne = new QuantitiyMeasurement(Unit.TON, 1.0);
            QuantitiyMeasurement gram  = new QuantitiyMeasurement(Unit.GRAM, 1000.0);
            double addition            = this.measurement.Addition(tonne, gram);

            Assert.AreEqual(1001.0, addition);
        }
        public void Given_1GallonAnd3point78Litres_WhenAdded_ShouldReturn7point56Inch()
        {
            QuantitiyMeasurement gallon = new QuantitiyMeasurement(Unit.GALLON, 1.0);
            QuantitiyMeasurement litre  = new QuantitiyMeasurement(Unit.LITRE, 3.78);
            double addition             = this.measurement.Addition(gallon, litre);

            Assert.AreEqual(8.0, addition);
        }
        public void Given_1LitreAnd1000Ml_WhenAdded_ShouldReturn2Litres()
        {
            QuantitiyMeasurement litre      = new QuantitiyMeasurement(QuantitiyMeasurement.Unit.LITRE, 1.0);
            QuantitiyMeasurement milliliter = new QuantitiyMeasurement(QuantitiyMeasurement.Unit.MiLLILITERS, 1000.0);
            double addition = this.measurement.Addition(litre, milliliter);

            Assert.AreEqual(2.0, addition);
        }
        public void Given_36InchAnd1yard_When_UnitConversiond_ShouldReturnEqualLength()
        {
            QuantitiyMeasurement inch = new QuantitiyMeasurement(Unit.INCH, 36.0);
            QuantitiyMeasurement yard = new QuantitiyMeasurement(Unit.YARD, 1.0);
            bool compare = this.measurement.UnitConversion(inch, yard);

            Assert.IsTrue(compare);
        }
        public void Given_Negative1LitreAnd1000Ml_WhenCompared_ShouldReturnTrue()
        {
            QuantitiyMeasurement litre      = new QuantitiyMeasurement(Unit.LITRE, -1.0);
            QuantitiyMeasurement milliliter = new QuantitiyMeasurement(Unit.MiLLILITERS, 1000.0);
            bool compare = this.measurement.UnitConversion(litre, milliliter);

            Assert.IsFalse(compare);
        }
        public void Give_100CelsiusAnd212Fahrenheit_WhenCompared_ShouldReturnTrue()
        {
            QuantitiyMeasurement celsius    = new QuantitiyMeasurement(Unit.CELSIUS, 100.0);
            QuantitiyMeasurement fahrenheit = new QuantitiyMeasurement(Unit.FAHRENHEIT, 212.0);
            bool compare = this.measurement.ConvertTemperature(celsius, fahrenheit);

            Assert.IsTrue(compare);
        }
        public void Given_Negative212Fahrenheitand100Celsius_WhenCompared_ShouldReturnTrue()
        {
            QuantitiyMeasurement fahrenheit = new QuantitiyMeasurement(Unit.FAHRENHEIT, -212.0);
            QuantitiyMeasurement celsius    = new QuantitiyMeasurement(Unit.CELSIUS, 100.0);
            bool compareCheck = this.measurement.ConvertTemperature(fahrenheit, celsius);

            Assert.IsFalse(compareCheck);
        }
        public void Given1FeetAnd1Feet_WhenAdded_ShouldReturn24Inch()
        {
            QuantitiyMeasurement feet1 = new QuantitiyMeasurement(Unit.FEET, 1.0);
            QuantitiyMeasurement feet2 = new QuantitiyMeasurement(Unit.FEET, 1.0);
            double addition            = this.measurement.Addition(feet1, feet2);

            Assert.AreEqual(24, addition);
        }
        public void GivenFeet_When_SameValue_ShouldReturnEqual()
        {
            QuantitiyMeasurement firstFeetValue  = new QuantitiyMeasurement(Unit.FEET, 10.0);
            QuantitiyMeasurement secondFeetValue = new QuantitiyMeasurement(Unit.FEET, 10.0);
            bool equals = firstFeetValue.Equals(secondFeetValue);

            Assert.True(equals);
        }
        public void Given_1FeetAnd2Inches_WhenAdded_ShouldReturn14Inch()
        {
            QuantitiyMeasurement feet = new QuantitiyMeasurement(Unit.FEET, 1.0);
            QuantitiyMeasurement inch = new QuantitiyMeasurement(Unit.INCH, 2.0);
            double addition           = this.measurement.Addition(feet, inch);

            Assert.AreEqual(14, addition);
        }
        public void Given2InchAnd2Inch_WhenAdded_ShouldReturn4Inch()
        {
            QuantitiyMeasurement inch1 = new QuantitiyMeasurement(Unit.INCH, 2.0);
            QuantitiyMeasurement inch2 = new QuantitiyMeasurement(Unit.INCH, 2.0);
            double addition            = this.measurement.Addition(inch1, inch2);

            Assert.AreEqual(4, addition);
        }
        public void Given_1InchAnd1Cms_WhenCompared_ShouldReturnFalse()
        {
            QuantitiyMeasurement inch = new QuantitiyMeasurement(Unit.INCH, 5.0);
            QuantitiyMeasurement cm   = new QuantitiyMeasurement(Unit.CMS, 5.0);
            bool compare = this.measurement.UnitConversion(inch, cm);

            Assert.IsFalse(compare);
        }
        public void GivenZeroFeet_When_ZeroFeet_ShouldReturnZero()
        {
            QuantitiyMeasurement firstFeet  = new QuantitiyMeasurement(Unit.FEET, 0.0);
            QuantitiyMeasurement secondFeet = new QuantitiyMeasurement(Unit.FEET, 0.0);
            bool equals = firstFeet.Equals(secondFeet);

            Assert.IsTrue(equals);
        }
        public void Given_3NegativeFeetAnd1Yard_WhenUnitConversiond_ShouldReturnTrue()
        {
            QuantitiyMeasurement yard = new QuantitiyMeasurement(Unit.YARD, 1.0);
            QuantitiyMeasurement feet = new QuantitiyMeasurement(Unit.FEET, -3.0);
            bool compare = this.measurement.UnitConversion(yard, feet);

            Assert.IsFalse(compare);
        }
        public void Given_1LitreAnd1Milliliter_WhenCompared_ShouldReturnFalse()
        {
            QuantitiyMeasurement litre      = new QuantitiyMeasurement(Unit.LITRE, 1);
            QuantitiyMeasurement milliLiter = new QuantitiyMeasurement(Unit.MiLLILITERS, 1);
            bool compare = this.measurement.UnitConversion(litre, milliLiter);

            Assert.IsFalse(compare);
        }
        public void Given_1GallonAnd1Litre_WhenCompared_ShouldReturnFalse()
        {
            QuantitiyMeasurement gallon = new QuantitiyMeasurement(Unit.GALLON, 1);
            QuantitiyMeasurement litre  = new QuantitiyMeasurement(Unit.LITRE, 1);
            bool compare = this.measurement.UnitConversion(gallon, litre);

            Assert.IsFalse(compare);
        }
        public void Given_1InchAnd2AndHalfCMS_WhenAdded_ShouldReturn3Inch()
        {
            QuantitiyMeasurement inch1 = new QuantitiyMeasurement(Unit.INCH, 2.0);
            QuantitiyMeasurement cms2  = new QuantitiyMeasurement(Unit.CMS, 2.5);
            double addition            = this.measurement.Addition(inch1, cms2);

            Assert.AreEqual(3, addition);
        }
        /// <summary>
        /// Test case Negative: Given 1 yard and 36 inch when compared returns true
        /// </summary>
        public void Given_OneNeagtiveYardAnd36Inch_When_UnitConversiond_ShouldReturnEqualLength()
        {
            QuantitiyMeasurement yard = new QuantitiyMeasurement(Unit.YARD, -1.0);
            QuantitiyMeasurement inch = new QuantitiyMeasurement(Unit.INCH, 36.0);
            bool compare = this.measurement.UnitConversion(yard, inch);

            Assert.IsFalse(compare);
        }
        public void GivenInch_When_Zero_ShouldReturnFalse()
        {
            QuantitiyMeasurement firstInch  = new QuantitiyMeasurement(Unit.INCH, 0.0);
            QuantitiyMeasurement secondInch = new QuantitiyMeasurement(Unit.INCH, 0.0);
            bool equals = firstInch.Equals(secondInch);

            Assert.IsTrue(equals);
        }
        public void Given_1GallonAnd3Point78Litres_WhenCompared_ShouldReturnTrue()
        {
            QuantitiyMeasurement gallon = new QuantitiyMeasurement(Unit.GALLON, 1.0);
            QuantitiyMeasurement litre  = new QuantitiyMeasurement(Unit.LITRE, 3.78);
            bool compare = this.measurement.UnitConversion(gallon, litre);

            Assert.IsTrue(compare);
        }