Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        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));
            }
        }
Esempio n. 5
0
        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");
        }