public void APersonMustHaveAName() { //Arrange PersonBL logic = new PersonBL(); Person person = new Person() { Id = 1, Name = "", BirthDate = new DateTime(1999, 1, 1) }; //Act (and assert) Assert.ThrowsException <ArgumentException>(() => logic.Create(person)); }
public void APersonMustHaveAName() { //ARRANGE PersonBL logic = new PersonBL(); Person person = new Person() { Id = 1, Name = "", BirthDate = DateTime.Now }; //Act & Assert //Action no devuelve valor y Function si devuelve Assert.ThrowsException <ArgumentException>(() => logic.Create(person)); }
public void APersonIsCreated() { //Arrange PersonBL logic = new PersonBL(); Person person = new Person() { Id = 1, Name = "John Smith", BirthDate = new DateTime(1999, 1, 1) }; //Act logic.Create(person); var lastInserted = logic.GetById(1); //Assert Assert.IsNotNull(lastInserted, "The last inserted is null."); }
// POST: api/Home public HttpResponseMessage Post(PersonDTO person) { PersonBL personBL = new PersonBL(); ResponseFormat <bool> response = new ResponseFormat <bool>(); response.Data = personBL.Create(person); if (response.Data) { response.Message = "Person Created"; response.Success = true; return(Request.CreateResponse(HttpStatusCode.OK, response)); } else { response.Message = "There Was Some Error"; response.Success = false; return(Request.CreateResponse(HttpStatusCode.OK, response)); } }
public void APersonIsCreated() //Prueba de crear un objeto { //Arrange: configura todo lo que va a utilizar PersonBL logic = new PersonBL(); Person person = new Person() { Id = 1, Name = "Some Person", BirthDate = DateTime.Now }; //Act: llama al método logic.Create(person); Person saved = logic.GetById(1); //Assert: que tuvo que pasar Assert.IsNotNull(saved, "Person should have not been null after insert"); }