|
1 | 1 | using System.Net;
|
2 | 2 | using System.Text;
|
3 |
| -using Newtonsoft.Json; |
4 |
| -using Newtonsoft.Json.Serialization; |
5 | 3 | using RestSharp.Serializers.NewtonsoftJson;
|
6 | 4 | using RestSharp.Tests.Shared.Extensions;
|
7 | 5 | using RestSharp.Tests.Shared.Fixtures;
|
8 | 6 |
|
9 |
| -namespace RestSharp.Tests.Serializers.Json; |
10 |
| - |
11 |
| -public class NewtonsoftJsonTests { |
12 |
| - static readonly Fixture Fixture = new(); |
| 7 | +namespace RestSharp.Tests.Serializers.Json.NewtonsoftJson; |
13 | 8 |
|
| 9 | +public class IntegratedSimpleTests { |
14 | 10 | string _body;
|
15 | 11 |
|
16 |
| - readonly JsonSerializerSettings _jsonSerializerSettings = new() { |
17 |
| - ContractResolver = new DefaultContractResolver { |
18 |
| - NamingStrategy = new CamelCaseNamingStrategy() |
19 |
| - }, |
20 |
| - Formatting = Formatting.None |
21 |
| - }; |
22 |
| - |
23 | 12 | void CaptureBody(HttpListenerRequest request, HttpListenerResponse response) => _body = request.InputStream.StreamToString();
|
24 | 13 |
|
25 |
| - [Fact] |
26 |
| - public void Serialize_multiple_objects_within_one_thread() { |
27 |
| - var serializer = new JsonNetSerializer(); |
28 |
| - var dummy1 = Fixture.Create<TestClass>(); |
29 |
| - var dummy2 = Fixture.Create<TestClass>(); |
30 |
| - var dummy3 = Fixture.Create<TestClass>(); |
31 |
| - var expectedSerialization1 = JsonConvert.SerializeObject(dummy1, _jsonSerializerSettings); |
32 |
| - var expectedSerialization2 = JsonConvert.SerializeObject(dummy2, _jsonSerializerSettings); |
33 |
| - var expectedSerialization3 = JsonConvert.SerializeObject(dummy3, _jsonSerializerSettings); |
34 |
| - |
35 |
| - var actualSerialization1 = serializer.Serialize(dummy1); |
36 |
| - var actualSerialization2 = serializer.Serialize(dummy2); |
37 |
| - var actualSerialization3 = serializer.Serialize(dummy3); |
38 |
| - |
39 |
| - actualSerialization1.Should().Be(expectedSerialization1); |
40 |
| - actualSerialization2.Should().Be(expectedSerialization2); |
41 |
| - actualSerialization3.Should().Be(expectedSerialization3); |
42 |
| - } |
43 |
| - |
44 |
| - [Fact] |
45 |
| - public void Serialize_within_multiple_threads() { |
46 |
| - var serializer = new JsonNetSerializer(); |
47 |
| - |
48 |
| - Parallel.For( |
49 |
| - 0, |
50 |
| - 100, |
51 |
| - _ => { |
52 |
| - var dummy = Fixture.Create<TestClass>(); |
53 |
| - var expectedSerialization = JsonConvert.SerializeObject(dummy, _jsonSerializerSettings); |
54 |
| - var actualSerialization = serializer.Serialize(dummy); |
55 |
| - |
56 |
| - actualSerialization.Should().Be(expectedSerialization); |
57 |
| - } |
58 |
| - ); |
59 |
| - } |
| 14 | + static readonly Fixture Fixture = new(); |
60 | 15 |
|
61 | 16 | [Fact]
|
62 | 17 | public async Task Use_JsonNet_For_Requests() {
|
|
0 commit comments