public IActionResult DistanceConverter(DistanceConverter converter)
 {
     if (converter.FromDistance > 0)
     {
         converter.CalculateDistance();
     }
     return(View(converter));
 }
        public void TestMilestoMetres()
        {
            DistanceConverter converter = new DistanceConverter();

            converter.FromUnit = DistanceConverter.MILES;
            converter.ToUnit   = DistanceConverter.METRES;

            converter.FromDistance = 1.0;
            converter.CalculateDistance();

            double expectedDistance = 1609.34;

            Assert.AreEqual(expectedDistance, converter.ToDistance);
        }
Exemple #3
0
        public void TestMilesToFeet()
        {
            DistanceConverter converter = new DistanceConverter();

            converter.FromUnit = DistanceUnits.Miles;
            converter.ToUnit   = DistanceUnits.Feet;

            converter.FromDistance = 1.0;
            converter.CalculateDistance();

            double exptectedDistance = 5280;

            Assert.AreEqual(exptectedDistance, converter.ToDistance);
        }
Exemple #4
0
        public void TestMetresToMiles()
        {
            DistanceConverter converter = new DistanceConverter();

            converter.FromUnit = DistanceUnits.Metres;
            converter.ToUnit   = DistanceUnits.Miles;

            converter.FromDistance = 1609.34;
            converter.CalculateDistance();

            double exptectedDistance = 1.0;

            Assert.AreEqual(exptectedDistance, converter.ToDistance);
        }
Exemple #5
0
        public void TestFeetToMetres()
        {
            DistanceConverter converter = new DistanceConverter();

            converter.FromUnit = DistanceUnits.Feet;
            converter.ToUnit   = DistanceUnits.Metres;

            converter.FromDistance = 3.28084;
            converter.CalculateDistance();

            double exptectedDistance = 1.0;

            Assert.AreEqual(exptectedDistance, converter.ToDistance);
        }
        public void TestMetresToFeet()
        {
            DistanceConverter converter = new DistanceConverter();

            converter.FromUnit = DistanceConverter.METRES;
            converter.ToUnit   = DistanceConverter.FEET;

            converter.FromDistance = 1;
            converter.CalculateDistance();

            double expectedDistance = 3.28084;

            Assert.AreEqual(expectedDistance, converter.ToDistance);
        }
        public void TestFeetToMiles()
        {
            DistanceConverter converter = new DistanceConverter();

            converter.FromUnit = DistanceConverter.FEET;
            converter.ToUnit   = DistanceConverter.MILES;

            converter.FromDistance = 1.0;
            converter.CalculateDistance();

            double expectedDistance = 0.0001893939393939394;

            Assert.AreEqual(expectedDistance, converter.ToDistance);
        }
        public void TestMetresToMiles()
        {
            // 1. Arrange
            DistanceConverter converter = new DistanceConverter();

            converter.FromUnit = DistanceUnits.Metres;
            converter.ToUnit   = DistanceUnits.Miles;

            converter.FromDistance = 1609.34; //TODO: ADJUST UNIT

            // 2. Act
            converter.CalculateDistance();
            double expectedDistance = 1;

            // 3. Assert
            Assert.AreEqual(expectedDistance, converter.ToDistance);
        }
        public void TestMilesToFeet()
        {
            //aranged all the values needed
            DistanceConverter converter = new DistanceConverter();

            converter.FromUnit = DistanceConverter.MILES;
            converter.ToUnit = DistanceConverter.FEET;
            
            //act
            converter.FromDistance = 1.0;
            converter.CalculateDistance();

            double expectedDistance = 5280;

            //Assurt
            Assert.AreEqual(expectedDistance, converter.ToDistance);
        }
        public void TestCalculateDistanceFeetToMiles()
        {
            //Arrange
            DistanceConverter distanceConverter = new DistanceConverter();

            distanceConverter.FromUnit     = DistanceUnits.FEET;
            distanceConverter.ToUnit       = DistanceUnits.MILES;
            distanceConverter.FromDistance = 10560.0;

            //Act
            distanceConverter.CalculateDistance();

            //Assert
            double expectedToDistance = 2.0;

            Assert.AreEqual(expectedToDistance, distanceConverter.ToDistance);
        }
        public void TestCalculateDistanceMetresToFeet()
        {
            //Arrange
            DistanceConverter distanceConverter = new DistanceConverter();

            distanceConverter.FromUnit     = DistanceUnits.METRES;
            distanceConverter.ToUnit       = DistanceUnits.FEET;
            distanceConverter.FromDistance = 2.0;

            //Act
            distanceConverter.CalculateDistance();

            //Assert
            double expectedToDistance = 6.56168;

            Assert.AreEqual(expectedToDistance, distanceConverter.ToDistance);
        }
        public void TestCalculateDistanceMetresToMiles()
        {
            //Arrange
            DistanceConverter distanceConverter = new DistanceConverter();

            distanceConverter.FromUnit     = DistanceUnits.METRES;
            distanceConverter.ToUnit       = DistanceUnits.MILES;
            distanceConverter.FromDistance = 3218.68;

            //Act
            distanceConverter.CalculateDistance();

            //Assert
            double expectedToDistance = 2.0;

            Assert.AreEqual(expectedToDistance, distanceConverter.ToDistance);
        }
        public void TestFeetToMiles()
        {
            // 1. Arrange
            DistanceConverter converter = new DistanceConverter();

            converter.FromUnit = DistanceUnits.Feet;
            converter.ToUnit   = DistanceUnits.Miles;

            converter.FromDistance = 5280;

            // 2. Act
            converter.CalculateDistance();
            double expectedDistance = 1;

            // 3. Assert
            Assert.AreEqual(expectedDistance, converter.ToDistance);
        }
Exemple #14
0
        public void TestMilesToFeet()
        {
            //Arrange - converter object created
            DistanceConverter converter = new DistanceConverter();


            converter.FromUnit = DistanceConverter.MILES;
            converter.ToUnit   = DistanceConverter.FEET;

            converter.FromDistance = 1.0;
            //Act - distance is calculated
            converter.CalculateDistance();

            double expectedDistance = 5280;

            //Assert - result is tested with the expected result
            Assert.AreEqual(expectedDistance, converter.ToDistance);
        }
Exemple #15
0
        public void TestMetresToMiles()
        {
            //Arrange
            DistanceConverter converter = new DistanceConverter();

            converter.FromUnit = DistanceConverter.METRES;
            converter.ToUnit   = DistanceConverter.MILES;

            converter.InputDistance = 1609.34;

            //Act
            converter.CalculateDistance();

            double expectedDistance = 1;

            //Assert
            Assert.AreEqual(expectedDistance, converter.OutputDistance);
        }
Exemple #16
0
        public void MetresToMiles()
        {
            //Arrange - converter object created
            DistanceConverter converter = new DistanceConverter();


            converter.FromUnit = DistanceConverter.METRES;
            converter.ToUnit   = DistanceConverter.MILES;

            converter.FromDistance = 1609;
            //Act - distance is calculated
            converter.CalculateDistance();

            double expectedDistance = 1;

            //Assert - result is tested with the expected result
            Assert.AreEqual(expectedDistance, converter.ToDistance);
        }
Exemple #17
0
        public void TestMilesToFeet()
        {
            //Arrange
            DistanceConverter converter = new DistanceConverter();

            converter.FromUnit = DistanceConverter.MILES;
            converter.ToUnit   = DistanceConverter.FEET;

            converter.InputDistance = 1.0;

            //Act
            converter.CalculateDistance();

            double expectedDistance = 5280;

            //Assert
            Assert.AreEqual(expectedDistance, converter.OutputDistance);
        }
        public void TestFeetToMetres()
        {
            // Arrange
            DistanceConverter converter = new DistanceConverter();

            converter.FromUnit = DistanceConverter.FEET;
            converter.ToUnit   = DistanceConverter.METRES;

            converter.FromDistance = 3.28084;

            //Act
            converter.CalculateDistance();

            double expectedDistance = 1.0;

            // Assert
            Assert.AreEqual(expectedDistance, converter.ToDistance);
        }
        public void TestMilesToFeet()
        {
            // Arrange stage - created converter, initialised all values
            DistanceConverter converter = new DistanceConverter();

            converter.FromUnit = DistanceUnits.Miles;
            converter.ToUnit   = DistanceUnits.Feet;

            converter.FromDistance = 1.0;

            // Act stage
            converter.CalculateDistance();

            double expectedDistance = 5280;

            // Assert stage
            Assert.AreEqual(expectedDistance, converter.ToDistance);
        }
Exemple #20
0
        public void TestMetresToMiles()
        {
            // Arrange

            DistanceConverter converter = new DistanceConverter();

            converter.FromUnit = UnitEnum.METER;
            converter.ToUnit   = UnitEnum.MILE;

            converter.FromDistance = 1609.34;

            // Act

            converter.CalculateDistance();

            double expectedDistance = 1.0;

            // Assert

            Assert.AreEqual(expectedDistance, converter.ToDistance);
        }
Exemple #21
0
        public void TestFeetToMiles()
        {
            // Arrange

            DistanceConverter converter = new DistanceConverter();

            converter.FromUnit = UnitEnum.FEET;
            converter.ToUnit   = UnitEnum.MILE;

            converter.FromDistance = 5280;

            // Act

            converter.CalculateDistance();

            double expectedDistance = 1.0;

            // Assert

            Assert.AreEqual(expectedDistance, converter.ToDistance);
        }