-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathLabelTests.cs
89 lines (65 loc) · 2.31 KB
/
LabelTests.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
83
84
85
86
87
88
89
using System.Collections.Generic;
using System.Threading.Tasks;
using Fortnox.SDK;
using Fortnox.SDK.Entities;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace FortnoxSDK.Tests.ConnectorTests;
[TestClass]
public class LabelTests
{
public FortnoxClient FortnoxClient = TestUtils.DefaultFortnoxClient;
[TestMethod]
public async Task Test_Label_CRUD()
{
#region Arrange
//Add code to create required resources
#endregion Arrange
var connector = FortnoxClient.LabelConnector;
var randomLabel = TestUtils.RandomString();
#region CREATE
var newLabel = new Label()
{
Description = randomLabel
};
var createdLabel = await connector.CreateAsync(newLabel);
Assert.AreEqual(randomLabel, createdLabel.Description);
#endregion CREATE
#region UPDATE
var updatedRandomLabel = TestUtils.RandomString();
createdLabel.Description = updatedRandomLabel;
var updatedLabel = await connector.UpdateAsync(createdLabel);
Assert.AreEqual(updatedRandomLabel, updatedLabel.Description);
#endregion UPDATE
#region READ / GET
//Not allowed to read single label
#endregion READ / GET
#region DELETE
await connector.DeleteAsync(createdLabel.Id);
#endregion DELETE
#region Delete arranged resources
//Add code to delete temporary resources
#endregion Delete arranged resources
}
[TestMethod]
public async Task Test_Label_Find()
{
var connector = FortnoxClient.LabelConnector;
var existingCount = (await connector.FindAsync(null)).Entities.Count;
var createdEntries = new List<Label>();
//Add entries
for (var i = 0; i < 5; i++)
{
var createdEntry = await connector.CreateAsync(new Label() { Description = TestUtils.RandomString() });
createdEntries.Add(createdEntry);
}
//Filter not supported
var fullCollection = await connector.FindAsync(null);
Assert.AreEqual(existingCount + 5, fullCollection.Entities.Count);
//Limit not supported
//Delete entries
foreach (var entry in createdEntries)
{
await connector.DeleteAsync(entry.Id);
}
}
}