Created
March 18, 2012 05:02
-
-
Save MattHoneycutt/2069029 to your computer and use it in GitHub Desktop.
SpecsFor.Mvc Examples
This file contains hidden or 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
public class UserRegistrationSpecs | |
{ | |
public class when_a_new_user_registers : SpecsFor<MvcWebApp> | |
{ | |
protected override void Given() | |
{ | |
SUT.NavigateTo<AccountController>(c => c.Register()); | |
} | |
protected override void When() | |
{ | |
SUT.FindFormFor<RegisterModel>() | |
.Field(m => m.Email).SetValueTo("[email protected]") | |
.Field(m => m.UserName).SetValueTo("Test User") | |
.Field(m => m.Password).SetValueTo("P@ssword!") | |
.Field(m => m.ConfirmPassword).SetValueTo("P@ssword!") | |
.Submit(); | |
} | |
[Test] | |
public void then_it_redirects_to_the_home_page() | |
{ | |
SUT.Route.ShouldMapTo<HomeController>(c => c.Index()); | |
} | |
[Test] | |
public void then_it_sends_the_user_an_email() | |
{ | |
SUT.Mailbox().MailMessages.Count().ShouldEqual(1); | |
} | |
[Test] | |
public void then_it_sends_to_the_right_address() | |
{ | |
SUT.Mailbox().MailMessages[0].To[0].Address.ShouldEqual("[email protected]"); | |
} | |
[Test] | |
public void then_it_comes_from_the_expected_address() | |
{ | |
SUT.Mailbox().MailMessages[0].From.Address.ShouldEqual("[email protected]"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment