controllercontext

Unit testing method converting MVC view to string using View.Render method

我怕爱的太早我们不能终老 提交于 2019-12-23 09:33:31
问题 I have written method that converts MVC view to string and test method to check if it returns string. Of course it works with Web but when I run test in NUnit it throws a NullReferenceException in System.Web when method tries to call View.Render. Here is StackTrace: w System.Web.VirtualPath.GetCacheKey() w System.Web.Compilation.BuildManager.GetCacheKeyFromVirtualPath(VirtualPath virtualPath, Boolean& keyFromVPP) w System.Web.Compilation.BuildManager.GetVPathBuildResultFromCacheInternal

How do I Unit Test Actions without Mocking that use UpdateModel?

人盡茶涼 提交于 2019-11-27 16:29:49
问题 I have been working my way through Scott Guthrie's excellent post on ASP.NET MVC Beta 1. In it he shows the improvements made to the UpdateModel method and how they improve unit testing. I have recreated a similar project however anytime I run a UnitTest that contains a call to UpdateModel I receive an ArgumentNullException naming the controllerContext parameter. Here's the relevant bits, starting with my model: public class Country { public Int32 ID { get; set; } public String Name { get;