I encounter with below mentioed errors when I am trying to write TTD for  ‘ViewBag’ property in MVC3

//Error1Predefined type ‘Microsoft.CSharp.RuntimeBinder.Binder’ is not defined or importedTestProject1

 //Error2One or more types required to compile a dynamic expression cannot be found. Are you missing references to Microsoft.CSharp.dll and System.Core.dll?D:\MYPractice\MVC\RazorApplication\MVCDemo\TestProject1\UnitTest1.cs3113TestProject1

 Controller : 

public ActionResult Index()

        {

            ViewBag.Message = “Welcome to MVC3 demo”;

            return View(“Index”);

        }

MS Test :

public void TestMessage()

        {

            HomeController controler = new HomeController();

             ViewResult res = controler.Index() as ViewResult;

            Assert.AreEqual(“Welcome to MVC3 demo”, res.ViewBag.Message);

        }

Solution :

1 . Right Click on MsTest project and select ‘Add reference’ 

2. Select ‘.Net’  tab in Add reference window.

3. Add select ‘Microsoft.CSharp.dll’ and click on add.

 Now try to run test again.