示例#1
0
        public void ApiDeleteEntities(EntityFactory entityFactory)
        {
            // create some test entities over the api to run the delete tests against
            var entityList = entityFactory.ConstructAndSave(_output, 1);

            foreach (var entityObject in entityList)
            {
                // instantiate a list of entity names and guids to be deleted
                var entityKeysGuids = new List <KeyValuePair <string, Guid> >();
                entityKeysGuids.Add(new KeyValuePair <string, Guid>(entityObject.EntityName, entityObject.Id));

                // populate the list using information returned from create entities.
                GetParentKeysGuids(entityObject).ForEach(x => entityKeysGuids.Add(x));

                foreach (var entityKeyGuid in entityKeysGuids)
                {
                    // instantiate a new rest client, and configure the Uri

                    var endPoint = $"/api/entity/{entityKeyGuid.Key}/{entityKeyGuid.Value}";
                    var api      = new WebApi(_configure, _output);
                    api.ConfigureAuthenticationHeaders();

                    Assert.Equal(HttpStatusCode.OK, api.Get(endPoint).StatusCode);
                    Assert.Equal(HttpStatusCode.OK, api.Delete(endPoint).StatusCode);
                    Assert.Equal(HttpStatusCode.NoContent, api.Get(endPoint).StatusCode);
                    Assert.Equal(HttpStatusCode.OK, api.Delete(endPoint).StatusCode);
                }
            }
        }
示例#2
0
        public void TestApiEndPointsUnauthorized(string entityName)
        {
            var api      = new WebApi(_configure, _output);
            var response = api.Get($"/api/entity/{entityName}");

            // valid response code
            Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);
        }
示例#3
0
        public void TestApiEndPoints(string entityName)
        {
            var api = new WebApi(_configure, _output);

            api.ConfigureAuthenticationHeaders();
            var response = api.Get($"/api/entity/{entityName}");

            // a valid response code
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
        }
 protected void CrearThumbnailsHoteles_Click(object sender, EventArgs e)
 {
     try {
         Error.Text = string.Empty;
         WebApi.ObtenerToken(WebApi.UrlWebApi, WebApi.UsuarioWebApi, WebApi.ContrasenyaWebApi);
         WebApi.Get(WebApi.UrlWebApi, string.Format("/api/Hotel/Actions/CrearThumbnails?nuevoAncho={0}&nuevoAlto={1}", AnchoHoteles.Text, AltoHoteles.Text));
     } catch (Exception _excepcion) {
         if (_excepcion is WebException)
         {
             _excepcion = WebApi.ProcesarExcepcionWeb((WebException)_excepcion, "a");
         }
         Error.Text = _excepcion.Message + _excepcion.StackTrace;
     }
 }
 protected void Crear_Click(object sender, EventArgs e)
 {
     try {
         Error.Text = string.Empty;
         WebApi.ObtenerToken(WebApi.UrlWebApi, WebApi.UsuarioWebApi, WebApi.ContrasenyaWebApi);
         WebApi.Get(WebApi.UrlWebApi, string.Format("/api/Global/Actions/CrearThumbnail?rutaOrigen={0}&rutaDestino={1}&ancho={2}&alto={3}", Server.UrlEncode(RutaImagen.Text), Server.UrlEncode(RutaThumbnail1.Text), Ancho.Text, Alto.Text));
     } catch (Exception _excepcion) {
         if (_excepcion is WebException)
         {
             _excepcion = WebApi.ProcesarExcepcionWeb((WebException)_excepcion, "a");
         }
         Error.Text = _excepcion.Message + _excepcion.StackTrace;
     }
 }
示例#6
0
        private async void FormKelasReguler_Load(object sender, EventArgs e)
        {
            CommonFunction.FormLoading(this, progressBar1, true);

            HttpResponseMessage responseFakultas = await webApi.Get(UrlGetFakultas);

            if (!responseFakultas.IsSuccessStatusCode)
            {
                MessageBox.Show(responseFakultas.ReasonPhrase);
            }

            List <Fakultas> listFakultas = JsonConvert.DeserializeObject <List <Fakultas> >(responseFakultas.Content.ReadAsStringAsync().Result);

            listFakultas.Insert(0, new Fakultas()
            {
                NamaFakultas = "Pilih", KodeFakultas = "0"
            });
            cmbFakultas.DataSource    = listFakultas;
            cmbFakultas.DisplayMember = "NamaFakultas";
            cmbFakultas.ValueMember   = "KodeFakultas";
            cmbFakultas.SelectedIndex = 0;

            CommonFunction.FormLoading(this, progressBar1, false);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     try {
         Mensajes.Text = string.Empty;
         WebApi.ObtenerToken(WebApi.UrlWebApi, WebApi.UsuarioWebApi, WebApi.ContrasenyaWebApi);
         Mensajes.Text = string.Join("<br/>", JsonConvert.DeserializeObject <List <string> >(WebApi.Get(WebApi.UrlWebApi, "/api/Calendario/Actions/LocalizarImagenes")));
     } catch (Exception _excepcion) {
         if (_excepcion is WebException)
         {
             _excepcion = WebApi.ProcesarExcepcionWeb((WebException)_excepcion, "a");
         }
         Mensajes.Text = _excepcion.Message + _excepcion.StackTrace;
     }
 }