public HttpResponseMessage Post(Contact contact) { _repository.Post(contact); var response = new HttpResponseMessage<Contact>(contact); response.Headers.Location = new Uri(contact.Self, UriKind.Relative); return response; }
public void When_POST_then_location_is_set() { _repository.Setup(x => x.Post(It.IsAny<Contact>())) .Callback<Contact>(x => x.ContactId = 1); var contact = new Contact { Name = "Foo Bar" }; var response = _resource.Post(contact); Assert.Equal("/contact/1", response.Headers.Location.OriginalString); }
public void When_POST_then_contact_is_added() { var contact = new Contact { Name = "Foo Bar" }; _resource.Post(contact); _repository.Verify(x => x.Post(contact)); }