public void WithViewModelRendersWithoutExceptions() { var view = new Edit(); try { RouteTable.Routes.Add("Account_Edit", new Route("Account/Edit/{accountId}", new MvcRouteHandler())); } catch (ArgumentException) { // Already exists, which is ok. } var viewModel = new EditViewModel { AccountId = 123, DisplayName = null }; var html = view.RenderAsHtml(viewModel); }
public void WithoutViewModelRendersWithoutExceptions() { var view = new Edit(); var viewModel = new EditViewModel { AccountId = 612345 }; try { RouteTable.Routes.Add("Account_Edit", new Route("Account/Edit/{accountId}", new MvcRouteHandler())); } catch (ArgumentException) { // Already exists, which is ok. } var html = view.RenderAsHtml(viewModel); Assert.IsNotNull(html.DocumentNode.SelectSingleNode("//form"), "Form missing"); Assert.IsNotNull( html.DocumentNode.SelectSingleNode("//input[@type='text' and @name='DisplayName' and @value='']"), "DisplayName textbox missing."); Assert.IsNotNull(html.DocumentNode.SelectSingleNode("//input[@type='submit']"), "Submit button missing"); Assert.IsNotNull(html.DocumentNode.SelectSingleNode("//a[@href='/Account']"), "Cancel link missing"); }