Exemplo n.º 1
0
        public async Task Delete500InternalServerError()
        {
            using var clientFactory = new TestFaultyClientFactory <BookStoreApi.Code.AppDataSeeder>();
            var exampleDTO = GetUpdateExampleDTO();
            var client     = await clientFactory.GetTestClientAsync(async (client) => await AuthorizeMethods.AutorizeAsync(() => AppDataSeeder.AdminDto, client));

            var postResponse = await client.DeleteAsync($"api/Authors/{exampleDTO.Id}");

            Assert.AreEqual(HttpStatusCode.InternalServerError, postResponse.StatusCode);
        }
Exemplo n.º 2
0
        public async Task Update500InternalServerError()
        {
            using var clientFactory = new TestFaultyClientFactory <BookStoreApi.Code.AppDataSeeder>();
            var exampleDTO = GetUpdateExampleDTO();
            var content    = new StringContent(JsonConvert.SerializeObject(exampleDTO), Encoding.UTF8, MediaTypeNames.Application.Json);
            var client     = await clientFactory.GetTestClientAsync((client) => AuthorizeMethods.AutorizeAsync(() => AppDataSeeder.AdminDto, client));

            var postResponse = await client.PutAsync($"api/Authors/{exampleDTO.Id}", content);

            Assert.AreEqual(HttpStatusCode.InternalServerError, postResponse.StatusCode);
        }
Exemplo n.º 3
0
        public async Task GetAll500InternalServerError()
        {
            using var clientFactory = new TestFaultyClientFactory <BookStoreApi.Code.AppDataSeeder>();
            var client = await clientFactory.GetTestClientAsync();

            var response = await client.GetAsync("/api/Authors");

            var responseString = await response.Content.ReadAsStringAsync();

            // Assert
            System.Diagnostics.Trace.Write(responseString);
            Assert.AreEqual(System.Net.HttpStatusCode.InternalServerError, response.StatusCode);
        }