public void AddRsvpItem(RSVP rsvp) { using (var context = new WeddingContext()) { context.Rsvps.Add(rsvp); context.SaveChanges(); } }
public void AddRsvp_NoValueForName_EntityWrapperAddRsvpItemNotCalled() { // setup var rsvp = new RSVP { Email = "*****@*****.**" }; // action _postHelper.AddRsvp(rsvp); // assert _entityWrapper.DidNotReceive().AddRsvpItem(Arg.Any<RSVP>()); }
public void AddRsvp_NoValueForName_ReturnsErrorMessage() { // setup var rsvp = new RSVP {Email = "*****@*****.**"}; // action var msg = _postHelper.AddRsvp(rsvp); // assert Assert.AreEqual(Constants.ErrorMessage, msg); }
public void AddRsvp_NoValueForEmail_ReturnsErrorMessage() { // setup var rsvp = new RSVP { Name = "Mister Test" }; // action var msg = _postHelper.AddRsvp(rsvp); // assert Assert.AreEqual(Constants.ErrorMessage, msg); }
public void AddRsvp_CorrectData_ReturnsSuccessMessage() { // setup var rsvp = new RSVP { Name = "Mister Test", Email = "*****@*****.**" }; // action var msg = _postHelper.AddRsvp(rsvp); // assert Assert.AreEqual(Constants.SuccessMessage, msg); }
public void AddRsvp_CorrectData_CallingEntityWrapperAddRsvpItem() { // setup var rsvp = new RSVP {Name="Mister Test", Email="*****@*****.**"}; // action _postHelper.AddRsvp(rsvp); // assert _entityWrapper.Received().AddRsvpItem(Arg.Any<RSVP>()); }
public string AddRsvp(RSVP rsvp) { if (!IsValid(rsvp)) return Constants.ErrorMessage; rsvp.Email = rsvp.Email.ToLower(); try { _entityWrapper.AddRsvpItem(rsvp); } catch (Exception) { return Constants.ErrorMessage; } return Constants.SuccessMessage; }
public void AddRsvp_NoValueForEmail_EntityWrapperAddRsvpItemNotCalled() { // setup var rsvp = new RSVP { Name = "Mister Test" }; // action _postHelper.AddRsvp(rsvp); // assert _entityWrapper.DidNotReceive().AddRsvpItem(Arg.Any<RSVP>()); }
public void AddRsvp_PoorlyFormattedEmail_EmailIsFormattedProperly() { // setup var rsvp = new RSVP { Name = "Mister Test", Email = "*****@*****.**"}; // action _postHelper.AddRsvp(rsvp); // assert Assert.AreEqual("*****@*****.**", rsvp.Email); }
public bool IsValid(RSVP rsvp) { return rsvp != null && !IsNullOrWhiteSpace(rsvp.Name) && !IsNullOrWhiteSpace(rsvp.Email); }