-
Notifications
You must be signed in to change notification settings - Fork 27
/
TasksApiTests.cs
82 lines (73 loc) · 2.96 KB
/
TasksApiTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using Crowdin.Api.Tasks;
using Crowdin.Api.Tests.Core;
using Newtonsoft.Json;
using Xunit;
namespace Crowdin.Api.Tests.Tasks
{
public class TasksApiTests
{
private static readonly JsonSerializerSettings Settings = TestUtils.CreateJsonSerializerOptions();
[Fact]
public void AddTask_VendorGengo_RequestSerialization_ToneNotSet()
{
var request = new VendorGengoTaskCreateForm
{
Type = TaskType.TranslateByVendor,
Tone = VendorGengoTaskCreateForm.TaskTone.NotSet
};
string requestJson = JsonConvert.SerializeObject(request, Settings);
Assert.NotNull(requestJson);
Assert.Equal(Core.Resources.Tasks.AddTask_RightRequestJson_VendorGengo_ToneNotSet, requestJson);
}
[Fact]
public void AddTask_VendorGengo_RequestSerialization_ToneInformal()
{
var request = new VendorGengoTaskCreateForm
{
Type = TaskType.TranslateByVendor,
Tone = VendorGengoTaskCreateForm.TaskTone.Informal
};
string requestJson = JsonConvert.SerializeObject(request, Settings);
Assert.NotNull(requestJson);
Assert.Equal(Core.Resources.Tasks.AddTask_RightRequestJson_VendorGengo_ToneInformal, requestJson);
}
[Fact]
public void AddTask_VendorGengo_RequestSerialization_ToneOther()
{
var request = new VendorGengoTaskCreateForm
{
Type = TaskType.TranslateByVendor,
Tone = VendorGengoTaskCreateForm.TaskTone.Other
};
string requestJson = JsonConvert.SerializeObject(request, Settings);
Assert.NotNull(requestJson);
Assert.Equal(Core.Resources.Tasks.AddTask_RightRequestJson_VendorGengo_ToneOther, requestJson);
}
[Fact]
public void AddTask_VendorManual_RequestSerialization()
{
var request = new VendorManualTaskCreateForm
{
Title = "My task",
LanguageId = "es",
FileIds = new[] { 1, 2, 3 },
Type = TaskType.TranslateByVendor,
Vendor = TaskVendor.Lingo24,
Status = TaskStatus.InProgress,
Description = "My amazing task",
SkipAssignedStrings = true,
SkipUntranslatedStrings = true,
LabelIds = new[] { 1 },
Assignees = new[]
{
new TaskAssigneeForm { Id = 1, WordsCount = 20 },
new TaskAssigneeForm { Id = 2, WordsCount = 30 }
}
};
string actualRequestJson = JsonConvert.SerializeObject(request, Settings);
string expectedRequestJson = TestUtils.CompactJson(Core.Resources.Tasks.AddTask_RightRequestJson_VendorManual);
Assert.Equal(expectedRequestJson, actualRequestJson);
}
}
}