Skip to content

Commit 7ed8653

Browse files
authored
Merge pull request #33 from SimplifyNet/dependabot/nuget/develop/RestSharp-107.0.star
Update RestSharp requirement from 106.15.* to 107.0.*
2 parents 9d2e47e + a59c4b8 commit 7ed8653

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

.vscode/launch.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"version": "0.2.0",
33
"configurations": [
44
{
5-
"name": "TesterApp Launch",
5+
"name": "TestServer Launch",
66
"type": "coreclr",
77
"request": "launch",
88
"preLaunchTask": "Build",
@@ -13,5 +13,14 @@
1313
{
1414
"ASPNETCORE_ENVIRONMENT": "Development"
1515
}
16+
},
17+
{
18+
"name": "TestClient Launch",
19+
"type": "coreclr",
20+
"request": "launch",
21+
"preLaunchTask": "Build",
22+
"program": "${workspaceFolder}/src/TestClient/bin/Debug/net6.0/TestClient.dll",
23+
"cwd": "${workspaceFolder}/src/TestClient/bin/Debug/net6.0/",
24+
"internalConsoleOptions": "openOnSessionStart"
1625
}]
1726
}

src/TestClient/Program.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@ private static void Main()
1010
{
1111
var client = new RestClient("http://localhost:5000/");
1212

13-
var request = new RestRequest("api/v1/testIn", Method.POST)
13+
var request = new RestRequest("api/v1/testIn", Method.Post)
1414
{
15-
AlwaysMultipartFormData = true,
16-
Files = { FileParameter.Create("test file", Encoding.UTF8.GetBytes("Hello World!!!"), "MyFile.txt", "text/plain") }
15+
AlwaysMultipartFormData = true
1716
};
1817

19-
var result = client.Execute(request);
18+
request.AddFile("test file", Encoding.UTF8.GetBytes("Hello World!!!"), "MyFile.txt", "text/plain");
19+
20+
var result = client.ExecuteAsync(request).Result;
2021

2122
if (result.IsSuccessful != true)
22-
throw new InvalidOperationException("Error sending file");
23+
throw new InvalidOperationException("Error sending file: " + result.Content);
2324

2425
Console.WriteLine("HTTP status: " + result.StatusCode);
2526
Console.ReadLine();

src/TestClient/TestClient.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
<IsPackable>false</IsPackable>
66
</PropertyGroup>
77
<ItemGroup>
8-
<PackageReference Include="RestSharp" Version="106.15.*" />
8+
<PackageReference Include="RestSharp" Version="107.3.*" />
99
</ItemGroup>
1010
</Project>

src/TestServer/Controllers/Api/v1/TestInController.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@ public override async Task<ControllerResponse> Invoke()
1818
using var stream = new StreamReader(file.Data);
1919
var fileData = await stream.ReadToEndAsync();
2020

21-
Trace.WriteLine($"Files count: '{Model.Files}'");
21+
Trace.WriteLine($"Files count: '{Model.Files.Count}'");
2222
Trace.WriteLine($"File name: '{file.FileName}'");
2323
Trace.WriteLine($"File content: '{fileData}'");
2424

2525
// Assert
2626

2727
if (file.Name != "test file")
28-
throw new InvalidDataException($"Wrong name, actual: '{file.Name}'");
28+
return Content($"Wrong name, actual: '{file.Name}'", 500);
2929

3030
if (file.FileName != "MyFile.txt")
31-
throw new InvalidDataException($"Wrong file name, actual: '{file.FileName}'");
31+
return Content($"Wrong file name, actual: '{file.FileName}'", 500);
3232

3333
if (fileData != "Hello World!!!")
34-
throw new InvalidDataException($"Wrong file data, actual: '{fileData}'");
34+
return Content($"Wrong file data, actual: '{fileData}'", 500);
3535

3636
return NoContent();
3737
}

0 commit comments

Comments
 (0)