Exemplo n.º 1
0
        public ViewResult FarenheitToCelsius(FarCelViewModel model)
        {
            try
            {
                Farenheit2Celsius temperature = new Farenheit2Celsius();
                model.Result = temperature.Convert(model.Choice, model.Temperature);
                ModelState.Clear();

                return(View(model));
            }
            catch (InvalidCastException ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Converter", "Error")));
            }
            //This catch block will catch other types of unhandled exceptions
            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Converter", "Error")));
            }

            //return View();  //Calls view=ActionMethod name by default
            //return View("myViewName"); //Calls "MyViewName" regardless
            //return View("myViewName", MyViewModel);  //Calls another view
            //return View(myViewModel); //Calls view=ActionMethod with another model
        }
Exemplo n.º 2
0
        public void TestCel2Far()
        {
            //
            // TODO: Add test logic here
            //
            Farenheit2Celsius celfar = new Farenheit2Celsius();

            //Act
            double actual          = celfar.Convert('c', 7.65);
            double actualrounded   = Math.Round(actual, 2);
            double expectedrounded = 45.77;

            //Assert
            Assert.AreEqual(expectedrounded, actualrounded);
        }
Exemplo n.º 3
0
        public void TestFar2Cel()
        {
            //
            // TODO: Add test logic here
            //

            //Arrange
            Farenheit2Celsius farcel = new Farenheit2Celsius();

            //Act
            double actual          = farcel.Convert('f', 45.7777);
            double actualrounded   = Math.Round(actual, 2);
            double expectedrounded = 7.65;

            //Assert
            Assert.AreEqual(expectedrounded, actualrounded);
        }