title: conversion Error from String to System.Web.Mvc.ViewResult in MVC3
body: <p>Hi I am quite new on MVC and I am trying to create a simple conversion from Fahrenheit to Celsius along with its unit testing. Sorry in advance for putting all the code here.</p>
  
  <p>This is my controller code:</p>
  
  <pre><code>public string Convert(double value,string option)
  {
      string d;
  
      if(option=="1") {
          d = " To Celcius"+FahrenheitToCelsius(value).ToString();
      }
      else {
          d = " To Fahrenheit" + CelsiusToFahrenheit(value).ToString();
      }
      return "ConvertTo" + d;
  }
  
  public static double CelsiusToFahrenheit(double temperatureCelsius)
  {
      double celsius = temperatureCelsius;
      return (celsius * 9 / 5) + 32;
  }
  
  public static double FahrenheitToCelsius (double temperatureFahrenheit)
  {
      double fahrenheit = temperatureFahrenheit;
      return (fahrenheit - 32) * 5 / 9;
  }
  </code></pre>
  
  <p>This is my View Page</p>
  
  <pre><code>protected void btnConvert(object sender, EventArgs e)
  {
      if (DropDownList1.SelectedValue=="1"){
          double temp = TemperatureConverterController.FahrenheitToCelsius(double.Parse(TextBox1.Text));
          Literal1.Text = temp.ToString();
      }
      else{
          double temp = TemperatureConverterController.CelsiusToFahrenheit(double.Parse(TextBox1.Text));
          Literal1.Text = temp.ToString();
          Literal1.Text = temp.ToString();
      }
  }
  </code></pre>
  
  <p>When i do this unit testing i got an error:</p>
  
  <pre><code>[TestMethod]
  public void ConvertReturnsAViewResultWhenInputDataIsValid()
  {
      //Arrange
      var controller = new TemperatureConverterController();
  
      //Act
      double x = 80;
      double y = 25;
      var result = controller.Convert(x, "1") as ViewResult;
      //    here i get this error under ViewResult //
  
      //Assert
      Assert.IsInstanceOfType(result, typeof(ViewResult));
  }
  
  [TestMethod]
  public void ConvertAsksForAViewTemplateNamedConvert()
  {
      //Arrange
      var controller = new TemperatureConverterController();
      String expectedViewTemplate = "Convert";
  
      //Act
      double x = 80;
      double y = 25;
      var result = controller.Convert(x, "1") as ViewResult;
      ////Assert
      Assert.AreEqual&lt;String&gt;(expectedViewTemplate, result.ViewName);
  }
  </code></pre>
  
  <p><strong>Error is:</strong></p>
  
  <pre><code>Error   Cannot convert type 'string' to 'System.Web.Mvc.ViewResult' via a reference conversion, boxing conversion, unboxing conversion, wrapping conversion, or null type conversion.
  </code></pre>