コード例 #1
0
ファイル: LogTest.cs プロジェクト: danilodumba/qsLog-api
        // [Fact]
        // public async Task Deve_Retornar_Lista_Por_ProjectID()
        // {
        //     var model = new LogModel
        //     {
        //         Description = "Teste description",
        //         Source = "Source adsdlasjd ajsdh kj jahs dkjhs akjdh kasjhdjk asdh kj",
        //         LogType = Domains.Logs.LogTypeEnum.Information
        //     };

        //     await this.CriarLog(model);
        //     var dataInicial = DateTime.Now.ToString("yyyy-MM-dd");
        //     var dataFinal = DateTime.Now.ToString("yyyy-MM-dd");;

        //     var response = await this.Get($"{dataInicial}/{dataFinal}/?projectID=" + model.LogType);
        //     string error = "";
        //     if (!response.IsSuccessStatusCode)
        //     {
        //         error = await response.Content.ReadAsStringAsync();
        //     }

        //     Assert.True(response.IsSuccessStatusCode, error);

        //     var list = JsonConvert.DeserializeObject<List<LogListDTO>>(await response.Content.ReadAsStringAsync());
        //     Assert.True(list.Count > 0, "Deve retornar uma lista de logs maior que zero pra o projectID.");
        // }


        private async Task <Guid> CriarLog()
        {
            var model = LogMock.GetLogModel();

            var response = await this.Post($"?api-key={this.ObterApiKeyProjeto()}", model, false);

            if (!response.IsSuccessStatusCode)
            {
                throw new Exception("Erro ao criar log");
            }

            return(JsonConvert.DeserializeObject <Guid>(await response.Content.ReadAsStringAsync()));
        }
コード例 #2
0
ファイル: LogTest.cs プロジェクト: danilodumba/qsLog-api
        public async Task Deve_Criar_Log()
        {
            var model = LogMock.GetLogModel();

            //var response = await this.Post($"?api-key=e4bde140-3da5-e549-827c-a007a85c541a", model, false);
            var response = await this.Post($"?api-key={this.ObterApiKeyProjeto()}", model, false);

            string error = "";

            if (!response.IsSuccessStatusCode)
            {
                error = await response.Content.ReadAsStringAsync();
            }

            Assert.True(response.IsSuccessStatusCode, error);
        }