This commit is contained in:
Lukáš Kaňka
2023-09-01 23:01:48 +02:00
parent f606c8bf4b
commit 05f75328d0
55 changed files with 120884 additions and 4 deletions
Binary file not shown.
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RestApiTests.Models.Create
{
public class UsersCreateRequest
{
public string name { get; set; }
public string job { get; set; }
}
}
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RestApiTests.Models.Create
{
public class UsersCreateResponse
{
public string name { get; set; }
public string job { get; set; }
public string id { get; set; }
public DateTime createdAt { get; set; }
}
}
@@ -35,6 +35,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="FluentAssertions, Version=6.12.0.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
<HintPath>..\packages\FluentAssertions.6.12.0\lib\net47\FluentAssertions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
@@ -51,6 +54,7 @@
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
@@ -83,6 +87,8 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Models\Create\UsersCreateResponse.cs" />
<Compile Include="Models\Create\UsersCreateRequest.cs" />
<Compile Include="Models\UsersResponse.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestFixtures\UsersTests.cs" />
@@ -1,5 +1,7 @@
using Newtonsoft.Json;
using FluentAssertions;
using Newtonsoft.Json;
using NUnit.Framework;
using RestApiTests.Models.Create;
using RestApiTests.Models.Users;
using RestSharp;
using System;
@@ -12,7 +14,7 @@ namespace RestApiTests.TestFixtures
{
internal class UsersTests
{
[Test]
[Test] // test zde spouštíme jako debug test (Aspon první fáze)
public void GetUsers()
{
var endpoint = "https://reqres.in/api/users";
@@ -23,8 +25,40 @@ namespace RestApiTests.TestFixtures
var response = client.Execute(request);
var responseBody =
JsonConvert.DeserializeObject<UsersResponse>(response.Content);
// Verify (fluent package)
response.StatusCode.Should().Be(System.Net.HttpStatusCode.OK);
responseBody.page.Should().Be(1);
responseBody.data.Should().NotBeNullOrEmpty();
}
[Test]
public void CreateUsers()
{
var endpoint = "https://reqres.in/api/users";
var client = new RestClient(endpoint);
var request = new RestRequest(endpoint);
request.Method = Method.Post;
var payload = new UsersCreateRequest
{
name = "John",
job = "Engineer"
};
request.AddJsonBody(payload);
var response = client.Execute(request);
var responseBody =
JsonConvert.DeserializeObject<UsersCreateResponse>(response.Content);
// Verify (fluent package)
response.StatusCode.Should().Be(System.Net.HttpStatusCode.Created);
responseBody.id.Should().NotBeNullOrEmpty();
}
}
}
+4
View File
@@ -6,6 +6,10 @@
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
File diff suppressed because it is too large Load Diff
Binary file not shown.
@@ -6,6 +6,10 @@
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Binary file not shown.
@@ -1 +1 @@
235453772
1546717492
@@ -1 +1 @@
eac0b6e671c59a64893b0cb449a977cf2e297416
c6db05c2910e1a5d4cc06f6aeaaa5f3f62d3be58
@@ -36,3 +36,6 @@ C:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\RestApiTests\RestApiTests\obj\
C:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\RestApiTests\RestApiTests\obj\Debug\RestApiTests.pdb
C:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\RestApiTests\RestApiTests\bin\Debug\Newtonsoft.Json.dll
C:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\RestApiTests\RestApiTests\bin\Debug\Newtonsoft.Json.xml
C:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\RestApiTests\RestApiTests\bin\Debug\FluentAssertions.dll
C:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\RestApiTests\RestApiTests\bin\Debug\FluentAssertions.pdb
C:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\RestApiTests\RestApiTests\bin\Debug\FluentAssertions.xml
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FluentAssertions" version="6.12.0" targetFramework="net472" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="7.0.0" targetFramework="net472" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
<package id="NUnit" version="3.13.3" targetFramework="net472" />
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff