コード例 #1
0
        public async System.Threading.Tasks.Task Save()
        {
            RequestCenarioSave cenarioToBeSave = new RequestCenarioSave
            {
                Nome        = "Insert" + DateTime.Now,
                TopologiaId = 1,
                Id          = 0
            };

            HttpResponseMessage response = await _clientCall.Save(_baseController + "Save/", JsonConvert.SerializeObject(cenarioToBeSave));

            Assert.IsTrue(response.IsSuccessStatusCode);
            if (response.IsSuccessStatusCode)
            {
                var retorno = await response.Content.ReadAsStringAsync();

                RequestCenario cenarioRetorno = JsonConvert.DeserializeObject <RequestCenario>(JObject.Parse(retorno)["data"].ToString());

                Cenario cenarioafterSave = _unitOfw.CenarioRepository.Get(y => y.Id == cenarioRetorno.Id).FirstOrDefault();

                Assert.AreEqual(cenarioToBeSave.Nome, cenarioafterSave.Nome);

                Assert.AreEqual(cenarioToBeSave.TopologiaId, cenarioafterSave.TopologiaId);
            }
        }
コード例 #2
0
        public async System.Threading.Tasks.Task Get()
        {
            int fluxogramaId = 7038;

            try
            {
                var draing = _drawingAppService.pr_VCM_NoDrawingSelect(fluxogramaId);
            }
            catch (Exception ex)
            {
                throw;
            }


            var             filter    = "y => y.TipoEntidadeId == 224 && y.TopologiaId == 5077";
            List <Entidade> entidades = await _unitOfw.EntidadeRepository.EntidadesEntity(filter);


            #region Test
            //List<Entidade> entidades = _unitOfw.EntidadeRepository.EntidadesEntity(y => y.TipoEntidadeId == 224 && y.TopologiaId == 5077
            //                                           , y => y.TipoEntidadeId == 224 && y.TopologiaId == 5077
            //                                           , y => y.TipoEntidadeId == 224 && y.TopologiaId == 5077
            //                                           , y => y.TipoEntidadeId == 224 && y.TopologiaId == 5077
            //                                           , y => y.TipoEntidadeId == 224 && y.TopologiaId == 5077
            //                                           , y => y.TipoEntidadeId == 224 && y.TopologiaId == 5077
            //                                           , y => y.TipoEntidadeId == 224 && y.TopologiaId == 5077
            //                                           , y => y.TipoEntidadeId == 224 && y.TopologiaId == 5077
            //                                           , y => y.TipoEntidadeId == 224 && y.TopologiaId == 5077
            //                                           , y => y.TipoEntidadeId == 224 && y.TopologiaId == 5077
            //                                           , y => y.TipoEntidadeId == 224 && y.TopologiaId == 5077
            //                                           , y => y.TipoEntidadeId == 224 && y.TopologiaId == 5077
            //                                           , y => y.TipoEntidadeId == 224 && y.TopologiaId == 5077
            //                                           , y => y.TipoEntidadeId == 224 && y.TopologiaId == 5077
            //                                           , y => y.TipoEntidadeId == 224 && y.TopologiaId == 5077
            //                                           , y => y.TipoEntidadeId == 224 && y.TopologiaId == 5077
            //                                           , y => y.TipoEntidadeId == 224 && y.TopologiaId == 5077
            //                                           , y => y.TopologiaId == 5077
            //                                           , y => y.Id == 224
            //                                           , y => y.TipoEntidadeId == 224 && y.TopologiaId == 5077
            //                                           , y => y.TipoEntidadeId == 224 && y.TopologiaId == 5077
            //                                           , y => y.TipoEntidadeId == 224 && y.TopologiaId == 5077
            //                                           );
            #endregion

            int idCenario = _unitOfw.CenarioRepository.Get().ToList().FirstOrDefault().Id;

            HttpResponseMessage response = await _clientCall.Detail(_baseController + "Detail/" + idCenario);

            Assert.IsTrue(response.IsSuccessStatusCode);
            if (response.IsSuccessStatusCode)
            {
                var retorno = await response.Content.ReadAsStringAsync();

                RequestCenario cenario = JsonConvert.DeserializeObject <RequestCenario>(JObject.Parse(retorno)["data"].ToString());

                Assert.IsNotNull(cenario);
                Assert.AreEqual(Convert.ToInt32(idCenario), Convert.ToInt32(cenario.Id));
            }
        }
コード例 #3
0
        public async System.Threading.Tasks.Task SaveUpdate()
        {
            int idCenario = 1;
            RequestCenarioSave cenarioToBeSave = new RequestCenarioSave
            {
                Nome = "Update" + DateTime.Now,
                Id   = idCenario
            };

            HttpClient client = new HttpClient {
                BaseAddress = new Uri(_baseAddress)
            };

            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, _baseController + "Save/")
            {
                Content = new StringContent(JsonConvert.SerializeObject(cenarioToBeSave), Encoding.UTF8, "application/json")
            };

            HttpResponseMessage response = await client.SendAsync(request);

            Assert.IsTrue(response.IsSuccessStatusCode);
            if (response.IsSuccessStatusCode)
            {
                var retorno = await response.Content.ReadAsStringAsync();

                RequestCenario cenarioRetorno = JsonConvert.DeserializeObject <RequestCenario>(JObject.Parse(retorno)["data"].ToString());

                Cenario cenarioAfterUpdate = _unitOfw.CenarioRepository.Get(y => y.Id == idCenario).FirstOrDefault();


                Assert.AreEqual(cenarioToBeSave.Nome, cenarioAfterUpdate.Nome);
                Assert.AreEqual(cenarioRetorno.Nome, cenarioAfterUpdate.Nome);

                Assert.AreEqual(cenarioToBeSave.TopologiaId, cenarioAfterUpdate.TopologiaId);
                Assert.AreEqual(cenarioRetorno.TopologiaId, cenarioAfterUpdate.TopologiaId);
            }
        }