Created
September 12, 2012 19:35
-
-
Save gustafnk/3709329 to your computer and use it in GitHub Desktop.
Using RazorGenerator and CsQuery to assert on Razor views
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@model MyNamespace.Models.EditViewModel | |
<div> | |
<h1>Hello world</h1> | |
<span class="foo">@Model.Bar</span> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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