1
1
using System ;
2
2
using System . Linq ;
3
+ using System . Threading . Tasks ;
3
4
4
5
using Todoist . Net . Models ;
5
6
using Todoist . Net . Tests . Extensions ;
@@ -21,25 +22,51 @@ public ReminersServiceTests(ITestOutputHelper outputHelper)
21
22
}
22
23
23
24
[ Fact ]
24
- public void CreateDelete_Success ( )
25
+ public async Task CreateDelete_Success ( )
25
26
{
26
27
var client = TodoistClientFactory . Create ( _outputHelper ) ;
27
28
28
29
var transaction = client . CreateTransaction ( ) ;
29
30
30
- var itemId = transaction . Items . AddAsync ( new Item ( "Temp" ) ) . Result ;
31
+ var itemId = await transaction . Items . AddAsync ( new Item ( "Temp" ) ) . ConfigureAwait ( false ) ;
31
32
var reminderId =
32
- transaction . Reminders . AddAsync ( new Reminder ( itemId ) { DueDate = new DueDate ( DateTime . UtcNow . AddDays ( 1 ) ) } ) . Result ;
33
- transaction . CommitAsync ( ) . Wait ( ) ;
33
+ await transaction . Reminders . AddAsync ( new Reminder ( itemId ) { DueDate = new DueDate ( DateTime . UtcNow . AddDays ( 1 ) ) } ) . ConfigureAwait ( false ) ;
34
+ await transaction . CommitAsync ( ) . ConfigureAwait ( false ) ;
34
35
35
- var reminders = client . Reminders . GetAsync ( ) . Result ;
36
+ var reminders = await client . Reminders . GetAsync ( ) . ConfigureAwait ( false ) ;
36
37
Assert . True ( reminders . Any ( ) ) ;
37
38
38
- var reminderInfo = client . Reminders . GetAsync ( reminderId ) . Result ;
39
+ var reminderInfo = await client . Reminders . GetAsync ( reminderId ) . ConfigureAwait ( false ) ;
39
40
Assert . True ( reminderInfo != null ) ;
40
41
41
- client . Reminders . DeleteAsync ( reminderInfo . Reminder . Id ) . Wait ( ) ;
42
- client . Items . DeleteAsync ( itemId ) ;
42
+ await client . Reminders . DeleteAsync ( reminderInfo . Reminder . Id ) . ConfigureAwait ( false ) ;
43
+ await client . Items . DeleteAsync ( itemId ) ;
44
+ }
45
+
46
+ [ Fact ]
47
+ public async Task AddRelativeReminder_Success ( )
48
+ {
49
+ var client = TodoistClientFactory . Create ( _outputHelper ) ;
50
+
51
+ var item = new Item ( "Test" )
52
+ {
53
+ DueDate = new DueDate ( DateTime . UtcNow . AddDays ( 1 ) )
54
+ } ;
55
+
56
+ var taskId = await client . Items . AddAsync ( item ) . ConfigureAwait ( false ) ;
57
+
58
+ var user = await client . Users . GetCurrentAsync ( ) . ConfigureAwait ( false ) ;
59
+ var reminder = new Reminder ( taskId )
60
+ {
61
+ MinuteOffset = 60 ,
62
+ NotifyUid = user . Id
63
+ } ;
64
+
65
+ var reminderId = await client . Reminders . AddAsync ( reminder ) . ConfigureAwait ( false ) ;
66
+
67
+ Assert . NotNull ( reminderId . PersistentId ) ;
68
+
69
+ await client . Items . DeleteAsync ( item . Id ) ;
43
70
}
44
71
}
45
72
}
0 commit comments