Skip to content

Instantly share code, notes, and snippets.

@jbogard
Created October 24, 2013 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbogard/7136623 to your computer and use it in GitHub Desktop.
Save jbogard/7136623 to your computer and use it in GitHub Desktop.
var conference = new Conference("CodeMash");
var attendee = new Attendee("Bob", "Joe") { Email = "bob@bob.com" };
attendee.RegisterFor(conference);
fixture.SaveAll(conference, attendee);
var model = new ConferenceEditModel {
Id = conference.Id,
Name = "BUILD",
Attendees = new[] {
new ConferenceEditModel.AttendeeModel {
Id = attendee.Id,
FirstName = "George",
LastName = "Smith",
Email = "foo@foo.com"
}
}
};
var controller = fixture.CreateInstance<ConferenceController>();
var result = controller.Edit(model);
fixture.CommitTransaction();
conference = fixture.GetById<Conference>(conference.Id);
conference.Name.ShouldEqual(model.Name);
attendee = fixture.GetById<Attendee>(attendee.Id);
attendee.FirstName.ShouldEqual(model.Attendees[0].FirstName);
attendee.LastName.ShouldEqual(model.Attendees[0].LastName);
attendee.Email.ShouldEqual(model.Attendees[0].Email);
result.ShouldBeRedirectTo<ConferenceController>(c => c.Index(null), "Default");
@darrencauthon
Copy link

I put this comment in on the blog, but just to repeat it...

How does the assertion on line 33 pass? Your'e setting the attendee email address with a setter, and there's no "save" on the object afterwards. How can this test pass?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment