public void Given1Inch1Yard_ForCompare_shouldReturnFalse() { LengthQuantity yardObject = new LengthQuantity("yard", 1); LengthQuantity inchObject = new LengthQuantity("inch", 1); Assert.IsFalse(this.compare.CompareLength(yardObject, inchObject)); } //// end : public void Given1Inch1Yard_ForCompare_shouldReturnTrue()
public void Given1feet2Inch_ForSum_shouldReturn14Inch() { LengthQuantity feetObject = new LengthQuantity("feet", 1); LengthQuantity inchObject = new LengthQuantity("inch", 2); Assert.AreEqual(14, Calculate.AddToInch(feetObject, inchObject)); } //// end : public void Given1feet2Inch_ForSum_shouldReturn14Inch()
public void Given12Inch1Feet_ForCompare_shouldReturnTrue() { LengthQuantity inchObject = new LengthQuantity("inch", 12); LengthQuantity feetObject = new LengthQuantity("feet", 1); Assert.IsTrue(this.compare.CompareLength(inchObject, feetObject)); } //// end : public void Given12Inch1Feet_ForCompare_shouldReturnTrue()
public void Given1Feet1Yard_ForCompare_shouldReturnFalse() { LengthQuantity yardObject = new LengthQuantity("yard", 1); LengthQuantity feetObject = new LengthQuantity("feet", 1); Assert.IsFalse(this.compare.CompareLength(yardObject, feetObject)); } //// end : public void Given1Feet1Yard_ForCompare_shouldReturnTrue()
public void Given1Feet1Feet_ForSum_shouldReturn24Inch() { LengthQuantity feetObject1 = new LengthQuantity("feet", 1); LengthQuantity feetObject2 = new LengthQuantity("feet", 1); Assert.AreEqual(24, Calculate.AddToInch(feetObject1, feetObject2)); } //// end : public void Given1Feet1Feet_ForSum_shouldReturn24Inch()
public void Given2Inch2andhalfCm_ForSum_shouldReturn3Inch() { LengthQuantity inchObject = new LengthQuantity("inch", 2); LengthQuantity centimetermObject = new LengthQuantity("cm", 2.5); Assert.AreEqual(3, Calculate.AddToInch(inchObject, centimetermObject)); } //// end : public void Given1Feet1Feet_ForSum_shouldReturn24Inch()
public void Given2Inch2Inch_ForSum_shouldReturn4Inch() { LengthQuantity inchObject1 = new LengthQuantity("inch", 2); LengthQuantity inchObject2 = new LengthQuantity("inch", 2); Assert.AreEqual(4, Calculate.AddToInch(inchObject2, inchObject2)); } //// end : public void Given2Inch2Inch_ForSum_shouldReturn4Inch()
public void Given2Inch5Cm_ForCompare_shouldReturnTrue() { LengthQuantity yardObject = new LengthQuantity("cm", 5); LengthQuantity inchObject = new LengthQuantity("inch", 2); Assert.IsTrue(this.compare.CompareLength(yardObject, inchObject)); } //// end : public void Given36Inch1Yard_ForCompare_shouldReturnTrue()
public void GivenInchObject_CheckEqualityOfValues_ReturnBool() { // create object for Feet class LengthQuantity inch = new LengthQuantity("inch"); // set values in feet object inch.Length = 20.5; Assert.IsTrue(inch.Equals(inch)); } //// end : public void GivenFeetObject_CheckEqualityOfValues_ReturnBool()
public void GivenFeetObject_CheckEqualityOfValues_ReturnBool() { // create object for Feet class LengthQuantity feet = new LengthQuantity("feet"); // set values in feet object feet.Length = 20.5; Assert.IsTrue(feet.Equals(feet)); } //// end : public void GivenFeetObject_CheckEqualityOfValues_ReturnBool()
public void GivenFeetObject_CheckForReference_ShouldReturnBool() { // crating oject for FeetMeasurment class LengthQuantity feet = new LengthQuantity("feet"); // creating another object for FeetMeasurment class LengthQuantity secondFeet = new LengthQuantity("feet"); Assert.IsFalse(feet.Equals(secondFeet)); } //// end : public void GivenFeetObject_CheckForReference_ShouldReturnBool()
public void GivenInchObject_CheckForReference_ShouldReturnBool() { // crating oject for FeetMeasurment class LengthQuantity inch = new LengthQuantity("inch"); // creating another object for FeetMeasurment class LengthQuantity secondInch = new LengthQuantity("inch"); Assert.IsFalse(inch.Equals(secondInch)); } //// end : public void GivenInchObject_CheckForReference_ShouldReturnBool()
public void GivenInchObject_CheckForType_ShouldReturnBool() { // crating oject for FeetMeasurment class LengthQuantity inch = new LengthQuantity("inch"); // creating oject for object class object obj = new object(); Assert.IsFalse(inch.Equals(obj)); } //// end : public void GivenInchObject_CheckForType_ShouldReturnBool()
/// <summary> /// method to add two length quantities /// </summary> /// <param name="quantityOne"> first value </param> /// <param name="quantityTwo"> second value </param> /// <returns> sum in inches </returns> public static double AddToInch(LengthQuantity quantityOne, LengthQuantity quantityTwo) { try { if (quantityOne.Unit != 0 && quantityTwo.Unit != 0) { return((((double)quantityOne.Unit / (double)LengthUnits.inch) * quantityOne.Length) + (((double)quantityTwo.Unit / (double)LengthUnits.inch) * quantityTwo.Length)); } else { throw new ArgumentNullException(); } } catch (ArgumentNullException exception) { Console.WriteLine(exception.Message); throw; } } //// end : public static double AddToInch(LengthQuantity quantityOne, LengthQuantity quantityTwo)
/// <summary> /// method to compare two length 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 CompareLength(LengthQuantity quantityOne, LengthQuantity 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.Length == (int)quantityTwo.Unit * quantityTwo.Length); } else { return(false); } } catch (Exception exception) { Console.WriteLine(exception.Message); throw; } } //// end : public bool CompareLength(Measure quantityOne, Measure quantityTwo)
public void GivenFeetObject_CheckForNull_ShouldReturnBool() { LengthQuantity feet = new LengthQuantity("feet"); Assert.IsFalse(feet.Equals(null)); } //// end : public void GivenFeetObject_CheckForNull_ShouldReturnBool()
public void GivenInchObject_CheckForNull_ShouldReturnBool() { LengthQuantity inch = new LengthQuantity("inch"); Assert.IsFalse(inch.Equals(null)); } //// end : public void GivenInchObject_CheckForNull_ShouldReturnBool()