Advertisement
crawenn

Untitled

Jan 30th, 2023
2,576
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.59 KB | None | 0 0
  1. using System.Net.Http;
  2. using Xunit;
  3.  
  4. namespace API_Test
  5. {
  6.     public class APITest
  7.     {
  8.         [Fact]
  9.         public async void GetRequestTest()
  10.         {
  11.             // Create a new instance of HttpClient
  12.             using (var client = new HttpClient())
  13.             {
  14.                 // Make the GET request to the API endpoint
  15.                 var response = await client.GetAsync("https://api.example.com/data");
  16.  
  17.                 // Assert that the response was successful (200 OK)
  18.                 Assert.True(response.IsSuccessStatusCode);
  19.             }
  20.         }
  21.     }
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement