public
Created

  • Download Gist
ConferenceTest.cs
C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
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");

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?

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.