Skip to content

Instantly share code, notes, and snippets.

@gustafnk
Created September 12, 2012 19:35
Show Gist options
  • Save gustafnk/3709329 to your computer and use it in GitHub Desktop.
Save gustafnk/3709329 to your computer and use it in GitHub Desktop.
Using RazorGenerator and CsQuery to assert on Razor views
@model MyNamespace.Models.EditViewModel
<div>
<h1>Hello world</h1>
<span class="foo">@Model.Bar</span>
</div>
[TestFixture]
class EditSpikeTests
{
[Test]
public void Baz_in_class_foo()
{
var view = new EditSpike();
var html = view.Render(new EditViewModel {Bar = "Baz"});
var dom = CQ.Create(html);
var foo = dom.Select(".foo").Text();
Assert.AreEqual("Baz", foo);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment