public void DeleteAlumnoTest()
        {
            AlumnoesController controller   = new AlumnoesController();
            IHttpActionResult  actionResult =
                controller.PostAlumno(
                    new Alumno
            {
                Nombre    = "Ferran",
                Apellidos = "Lopez",
                Dni       = "12345266Y"
            });

            var contentResult = actionResult as
                                CreatedAtRouteNegotiatedContentResult <Alumno>;

            IHttpActionResult actionDeleteResult =
                controller.DeleteAlumno(contentResult.Content.Id);

            var contentDeleteResult = actionDeleteResult as
                                      OkNegotiatedContentResult <Alumno>;

            Assert.IsNotNull(contentDeleteResult);
            Assert.IsNotNull(contentDeleteResult.Content);
            Assert.IsTrue(contentDeleteResult.Content.Id == contentResult.Content.Id);
        }
Exemple #2
0
        public void PostAlumnoTest()
        {
            AlumnoesController controller   = new AlumnoesController();
            IHttpActionResult  actionResult = controller.PostAlumno(new Alumno
            {
                Nombre    = "Ferran",
                Apellidos = "Ferrer",
                Dni       = "23927012C"
            });

            var contentResult = actionResult as CreatedAtRouteNegotiatedContentResult <Alumno>;

            Assert.IsNotNull(actionResult);
            Assert.IsTrue(contentResult.RouteName == "DefaultApi");
        }