public void Post([FromBody] TestDto dto)
 {
     try
     {
         throw new NotImplementedException("post");
     }
     catch (Exception e)
     {
         _loggerFactory.CreateLogger <DirectExceptionController>().LogError(e, "DirectExceptionController");
     }
 }
Example #2
0
        public async Task ExOnPost()
        {
            var host = await _hostBuilder.StartAsync();

            var     client = host.GetTestClient();
            TestDto dto    = new TestDto {
                Data = "hey !"
            };
            var json = JsonConvert.SerializeObject(dto);

            HttpContent payload  = new StringContent(json, Encoding.UTF8, "application/json");
            var         response = await client.PostAsync("/api/directException", payload);

            response.EnsureSuccessStatusCode();

            var          memoryStore = host.Services.GetRequiredService <ErrorStore>();
            List <Error> found       = await memoryStore.GetAllAsync();

            Assert.Single(found);
            Assert.Contains("RawPostedData", found.First().CustomData.Keys);
            Assert.Equal(@"{""Data"":""hey !""}", found.First().CustomData["RawPostedData"]);
        }