Exemplo n.º 1
0
        public void TestCrearRepetido()
        {
            JavaScriptSerializer js = new JavaScriptSerializer();

            try
            {
                PreMatriculaAlumno alumno = new PreMatriculaAlumno()
                {
                    DNIAlumno      = "99988877",
                    NombreAlumno   = "María",
                    ApellidoAlumno = "Garcia",
                    Colegio        = "Santa María",
                    Estado         = "Activo"
                };

                string         jsonSolicitud = js.Serialize(alumno);
                byte[]         ByteMatricula = Encoding.UTF8.GetBytes(jsonSolicitud);
                HttpWebRequest request       = WebRequest.Create("http://localhost:8915/PreMatricula.svc/PreMatriculaAlumno") as HttpWebRequest;
                request.Method        = "POST";
                request.ContentLength = ByteMatricula.Length;
                request.ContentType   = "application/json";
                var rqt = request.GetRequestStream();
            }
            catch (WebException error)
            {
                HttpStatusCode    codigo            = ((HttpWebResponse)error.Response).StatusCode;
                StreamReader      reader            = new StreamReader(error.Response.GetResponseStream());
                string            tramaJson         = reader.ReadToEnd();
                RepetidoException repetidoException = js.Deserialize <RepetidoException>(tramaJson);
                Assert.AreEqual(HttpStatusCode.Conflict, codigo);
                Assert.AreEqual("101", repetidoException.Codigo);
                Assert.AreEqual("El alumno ya existe", repetidoException.Descripcion);
            }
        }
Exemplo n.º 2
0
        public void TestSolicitudCrearRepetido()
        {
            JavaScriptSerializer js = new JavaScriptSerializer();

            try
            {
                DateTime           fecha = DateTime.Now;
                SolicitudMatricula solicitudMatricula = new SolicitudMatricula()
                {
                    NombreAlumno         = "Jorge",
                    ApellidosAlumno      = "Gonzales",
                    DNI                  = "99551133",
                    Nivel                = 'S',
                    grado                = 'Q',
                    FechaSolicitud       = fecha,
                    FechaVisita          = fecha,
                    NombrePadreApoderado = "ApoderadoName",
                    DNIPadreApoderado    = "99663322",
                    EmailPadreApoderado  = "*****@*****.**",
                    EstadoSolicitud      = 'P'//Creamos solicitud en pendiente
                };

                string         jsonSolicitud = js.Serialize(solicitudMatricula);
                byte[]         ByteMatricula = Encoding.UTF8.GetBytes(jsonSolicitud);
                HttpWebRequest request       = WebRequest.Create("http://localhost:7981/SolicitudMatriculas.svc/Solicitud") as HttpWebRequest;
                request.Method        = "POST";
                request.ContentLength = ByteMatricula.Length;
                request.ContentType   = "application/json";
                var rqt = request.GetRequestStream();
            }
            catch (WebException error)
            {
                HttpStatusCode    codigo            = ((HttpWebResponse)error.Response).StatusCode;
                StreamReader      reader            = new StreamReader(error.Response.GetResponseStream());
                string            tramaJson         = reader.ReadToEnd();
                RepetidoException repetidoException = js.Deserialize <RepetidoException>(tramaJson);
                Assert.AreEqual(HttpStatusCode.Conflict, codigo);
                Assert.AreEqual("101", repetidoException.Codigo);
                Assert.AreEqual("El alumno ya existe", repetidoException.Descripcion);
            }
        }
Exemplo n.º 3
0
        public void TestEliminarInactivo()
        {
            JavaScriptSerializer js = new JavaScriptSerializer();

            try
            {
                HttpWebRequest requestD = WebRequest.Create("http://localhost:8915/PreMatricula.svc/PreMatriculaAlumno/87654321") as HttpWebRequest;
                requestD.Method = "DELETE";
                HttpWebResponse responseD = requestD.GetResponse() as HttpWebResponse;
            }
            catch (WebException error)
            {
                HttpStatusCode    codigo            = ((HttpWebResponse)error.Response).StatusCode;
                StreamReader      reader            = new StreamReader(error.Response.GetResponseStream());
                string            tramaJson         = reader.ReadToEnd();
                RepetidoException repetidoException = js.Deserialize <RepetidoException>(tramaJson);
                Assert.AreEqual(HttpStatusCode.Conflict, codigo);
                Assert.AreEqual("102", repetidoException.Codigo);
                Assert.AreEqual("No se puede eliminar el alumno, se encuentra inactivo.", repetidoException.Descripcion);
            }
        }
Exemplo n.º 4
0
        public void TestSolicitudEliminarCerrado()
        {
            JavaScriptSerializer js = new JavaScriptSerializer();

            try
            {
                HttpWebRequest requestD = WebRequest.Create("http://localhost:7981/SolicitudMatriculas.svc/Solicitud/99551133") as HttpWebRequest;
                requestD.Method = "DELETE";
                HttpWebResponse responseD = requestD.GetResponse() as HttpWebResponse;
            }
            catch (WebException error)
            {
                HttpStatusCode    codigo            = ((HttpWebResponse)error.Response).StatusCode;
                StreamReader      reader            = new StreamReader(error.Response.GetResponseStream());
                string            tramaJson         = reader.ReadToEnd();
                RepetidoException repetidoException = js.Deserialize <RepetidoException>(tramaJson);
                Assert.AreEqual(HttpStatusCode.Conflict, codigo);
                Assert.AreEqual("103", repetidoException.Codigo);
                Assert.AreEqual("No puede eliminar una solicitud aceptada.", repetidoException.Descripcion);
            }
        }