• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rwjdk / TrelloDotNet / 13348478040

15 Feb 2025 08:38PM UTC coverage: 45.015% (-0.5%) from 45.513%
13348478040

push

github

rwjdk
Compile errors

948 of 2838 branches covered (33.4%)

Branch coverage included in aggregate %.

0 of 1 new or added line in 1 file covered. (0.0%)

272 existing lines in 7 files now uncovered.

2456 of 4724 relevant lines covered (51.99%)

41.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/TrelloDotNet/Model/CardsFilterCondition.cs
1
using System.Collections.Generic;
2
using System;
3
using System.Linq;
4

5
namespace TrelloDotNet.Model
6
{
7
    /// <summary>
8
    /// Represent a condition 
9
    /// </summary>
10
    public class CardsFilterCondition
11
    {
UNCOV
12
        private CardsFilterCondition()
×
13
        {
14
            //Empty
UNCOV
15
        }
×
16

UNCOV
17
        internal CardsConditionField Field { get; set; }
×
18
        internal CustomField CustomFieldEntry { get; set; }
×
19
        internal CardsCondition Condition { get; set; }
×
20

UNCOV
21
        internal DateTimeOffset? ValueAsDateTimeOffset { get; set; }
×
22
        internal List<DateTimeOffset> ValueAsDateTimeOffsets { get; set; }
×
23

UNCOV
24
        internal string ValueAsString { get; set; }
×
25
        internal List<string> ValueAsStrings { get; set; }
×
26

UNCOV
27
        internal decimal? ValueAsNumber { get; set; }
×
28
        internal List<decimal> ValueAsNumbers { get; set; }
×
29
        internal bool ValueAsBoolean { get; set; }
×
30

31
        /// <summary>
32
        /// Create a Condition for a string-based Custom Field
33
        /// </summary>
34
        /// <param name="customField">The custom field to check</param>
35
        /// <param name="condition">The condition</param>
36
        /// <param name="strings">The string or strings to use in the condition</param>
37
        /// <returns>The Condition</returns>
38
        public static CardsFilterCondition CustomField(CustomField customField, CardsConditionString condition, params string[] strings)
39
        {
UNCOV
40
            List<string> values = null;
×
UNCOV
41
            string value = null;
×
42
            if (strings.Length == 1)
×
43
            {
UNCOV
44
                value = strings[0];
×
45
            }
46
            else
47
            {
48
                values = strings.ToList();
×
49
            }
50

51
            return new CardsFilterCondition
×
52
            {
×
UNCOV
53
                Field = CardsConditionField.CustomField,
×
UNCOV
54
                Condition = (CardsCondition)Convert.ToInt32(condition),
×
UNCOV
55
                ValueAsString = value,
×
UNCOV
56
                ValueAsStrings = values,
×
57
                CustomFieldEntry = customField,
×
UNCOV
58
            };
×
59
        }
60

61
        /// <summary>
62
        /// Create a Condition for a number-based Custom Field
63
        /// </summary>
64
        /// <param name="customField">The custom field to check</param>
65
        /// <param name="condition">The condition</param>
66
        /// <param name="numbers">The number, or numbers to use in the condition</param>
67
        /// <returns>The Condition</returns>
68
        public static CardsFilterCondition CustomField(CustomField customField, CardsConditionNumber condition, params int[] numbers)
69
        {
70
            return CustomField(customField, condition, numbers.Select(Convert.ToDecimal).ToArray());
×
71
        }
72

73
        /// <summary>
74
        /// Create a Condition for a number-based Custom Field
75
        /// </summary>
76
        /// <param name="customField">The custom field to check</param>
77
        /// <param name="condition">The condition</param>
78
        /// <param name="numbers">The number, or numbers to use in the condition</param>
79
        /// <returns>The Condition</returns>
80
        public static CardsFilterCondition CustomField(CustomField customField, CardsConditionNumber condition, params decimal[] numbers)
81
        {
UNCOV
82
            List<decimal> values = null;
×
UNCOV
83
            decimal? value = null;
×
UNCOV
84
            if (numbers.Length == 1)
×
85
            {
86
                value = numbers[0];
×
87
            }
88
            else
89
            {
UNCOV
90
                values = numbers.ToList();
×
91
            }
92

93
            return new CardsFilterCondition
×
UNCOV
94
            {
×
UNCOV
95
                Field = CardsConditionField.CustomField,
×
96
                Condition = (CardsCondition)Convert.ToInt32(condition),
×
97
                ValueAsNumber = value,
×
98
                ValueAsNumbers = values,
×
99
                CustomFieldEntry = customField,
×
100
            };
×
101
        }
102

103
        /// <summary>
104
        /// Create a Condition for a date-based Custom Field
105
        /// </summary>
106
        /// <param name="customField">The custom field to check</param>
107
        /// <param name="condition">The condition</param>
108
        /// <param name="dateTimeOffsets">The DateTime, or DateTimes to use in the condition</param>
109
        /// <returns>The Condition</returns>
110
        public static CardsFilterCondition CustomField(CustomField customField, CardsConditionDate condition, params DateTimeOffset[] dateTimeOffsets)
111
        {
112
            List<DateTimeOffset> values = null;
×
113
            DateTimeOffset? value = null;
×
114
            if (dateTimeOffsets.Length == 1)
×
115
            {
UNCOV
116
                value = dateTimeOffsets[0];
×
117
            }
118
            else
119
            {
120
                values = dateTimeOffsets.ToList();
×
121
            }
122

123
            return new CardsFilterCondition
×
124
            {
×
UNCOV
125
                Field = CardsConditionField.CustomField,
×
UNCOV
126
                Condition = (CardsCondition)Convert.ToInt32(condition),
×
UNCOV
127
                ValueAsDateTimeOffset = value,
×
UNCOV
128
                ValueAsDateTimeOffsets = values,
×
129
                CustomFieldEntry = customField,
×
130
            };
×
131
        }
132

133
        /// <summary>
134
        /// Create a Condition for a boolean-based Custom Field (aka a Checkbox)
135
        /// </summary>
136
        /// <param name="customField">The custom field to check</param>
137
        /// <param name="condition">The condition</param>
138
        /// <param name="boolean">The Boolean to use in the condition</param>
139
        /// <returns>The Condition</returns>
140
        public static CardsFilterCondition CustomField(CustomField customField, CardsConditionBoolean condition, bool boolean)
141
        {
142
            return new CardsFilterCondition
×
143
            {
×
UNCOV
144
                Field = CardsConditionField.CustomField,
×
UNCOV
145
                Condition = (CardsCondition)Convert.ToInt32(condition),
×
UNCOV
146
                ValueAsBoolean = boolean,
×
UNCOV
147
                CustomFieldEntry = customField,
×
148
            };
×
149
        }
150

151
        /// <summary>
152
        /// Create a condition to only return cards that are complete (DueComplete == true)
153
        /// </summary>
154
        /// <returns>The Condition</returns>
155
        public static CardsFilterCondition IsComplete()
156
        {
157
            return new CardsFilterCondition
×
UNCOV
158
            {
×
UNCOV
159
                Field = CardsConditionField.DueComplete,
×
UNCOV
160
                Condition = CardsCondition.Equal,
×
UNCOV
161
                ValueAsBoolean = true,
×
162
            };
×
163
        }
164

165
        /// <summary>
166
        /// Create a condition to only return cards that are not complete (DueComplete == false)
167
        /// </summary>
168
        /// <returns>The Condition</returns>
169
        public static CardsFilterCondition IsNotComplete()
170
        {
UNCOV
171
            return new CardsFilterCondition
×
172
            {
×
UNCOV
173
                Field = CardsConditionField.DueComplete,
×
UNCOV
174
                Condition = CardsCondition.Equal,
×
UNCOV
175
                ValueAsBoolean = false,
×
UNCOV
176
            };
×
177
        }
178

179
        /// <summary>
180
        /// Create a condition to only return cards that have at least 1 Label (not a specific one)
181
        /// </summary>
182
        /// <returns>The Condition</returns>
183
        public static CardsFilterCondition HasAnyLabel()
184
        {
UNCOV
185
            return new CardsFilterCondition
×
UNCOV
186
            {
×
187
                Field = CardsConditionField.Label,
×
UNCOV
188
                Condition = CardsCondition.HasAnyValue
×
UNCOV
189
            };
×
190
        }
191

192
        /// <summary>
193
        /// Create a condition to only return cards that have no labels at all assigned to them
194
        /// </summary>
195
        /// <returns>The Condition</returns>
196
        public static CardsFilterCondition HasNoLabels()
197
        {
198
            return new CardsFilterCondition
×
199
            {
×
UNCOV
200
                Field = CardsConditionField.Label,
×
UNCOV
201
                Condition = CardsCondition.DoNotHaveAnyValue
×
UNCOV
202
            };
×
203
        }
204

205
        /// <summary>
206
        /// Create a listId based condition (example only cards on a specific list)
207
        /// </summary>
208
        /// <param name="condition">The condition the listIds values should meet</param>
209
        /// <param name="listIds">One or more listIds that should bee the condition</param>
210
        /// <returns>The Condition</returns>
211
        public static CardsFilterCondition ListId(CardsConditionId condition, params string[] listIds)
212
        {
213
            return AdvancedStringCondition(CardsConditionField.List, (CardsConditionString)Convert.ToInt32(condition), listIds);
×
214
        }
215

216
        /// <summary>
217
        /// Create a card-named based condition (example only cards whose names contains a specific word)
218
        /// </summary>
219
        /// <param name="condition">The condition that should apply to the name</param>
220
        /// <param name="textValues">One or more Texts the condition should adhere to</param>
221
        /// <returns>The Condition</returns>
222
        public static CardsFilterCondition Name(CardsConditionString condition, params string[] textValues)
223
        {
UNCOV
224
            return AdvancedStringCondition(CardsConditionField.Name, condition, textValues);
×
225
        }
226

227
        /// <summary>
228
        /// Create a condition to only return cards that do not have a description
229
        /// </summary>
230
        /// <returns>The condition</returns>
231
        public static CardsFilterCondition HasNoDescription()
232
        {
233
            return AdvancedNumberCondition(CardsConditionField.Description, CardsConditionNumber.Equal, 0);
×
234
        }
235

236
        /// <summary>
237
        /// Create a condition to only return cards that do have a description
238
        /// </summary>
239
        /// <returns>The condition</returns>
240
        public static CardsFilterCondition HasDescription()
241
        {
UNCOV
242
            return AdvancedNumberCondition(CardsConditionField.Description, CardsConditionNumber.NotEqual, 0);
×
243
        }
244

245
        /// <summary>
246
        /// Create a description-named based condition (example only cards whose description start with a specific word)
247
        /// </summary>
248
        /// <param name="condition">The condition that should apply to the description</param>
249
        /// <param name="textValues">One or more Texts the condition should adhere to</param>
250
        /// <returns>The Condition</returns>
251
        public static CardsFilterCondition Description(CardsConditionString condition, params string[] textValues)
252
        {
UNCOV
253
            return AdvancedStringCondition(CardsConditionField.Name, condition, textValues);
×
254
        }
255

256
        /// <summary>
257
        /// Create a label-based condition  (example only cards that have 2 specific labelIds)
258
        /// </summary>
259
        /// <param name="condition">The condition for the labelIds</param>
260
        /// <param name="labelIds">One of more labelIds that the condition should adhere to</param>
261
        /// <returns>THe condition</returns>
262
        public static CardsFilterCondition LabelId(CardsConditionId condition, params string[] labelIds)
263
        {
264
            return AdvancedStringCondition(CardsConditionField.Label, (CardsConditionString)Convert.ToInt32(condition), labelIds);
×
265
        }
266

267
        /// <summary>
268
        /// Create a condition based on how many labels are on the cards (example only return cards that have over 3 labels on them)
269
        /// </summary>
270
        /// <param name="condition">The condition the label-count should meet</param>
271
        /// <param name="value">The count that the condition should adhere to</param>
272
        /// <returns>The condition</returns>
273
        public static CardsFilterCondition LabelCount(CardsConditionCount condition, int value)
274
        {
UNCOV
275
            return AdvancedNumberCondition(CardsConditionField.Label, (CardsConditionNumber)Convert.ToInt32(condition), value);
×
276
        }
277

278
        /// <summary>
279
        /// Create a condition based on how many cards have a label count in a certain range (Example the all cards that have between 1 and 3 labels)
280
        /// </summary>
281
        /// <param name="min">The minimum count</param>
282
        /// <param name="max">The maximum count</param>
283
        /// <returns>The Condition</returns>
284
        public static CardsFilterCondition LabelCountBetween(int min, int max)
285
        {
UNCOV
286
            var decimals = new List<decimal>() { min, max };
×
UNCOV
287
            return AdvancedNumberCondition(CardsConditionField.Label, CardsConditionNumber.Between, decimals.ToArray());
×
288
        }
289

290
        /// <summary>
291
        /// Create a condition based on how many cards have a label count outside a certain range (Example the all cards that have below 2 or above 5 (ignoring cards with 2,3,4 and 5 labels))
292
        /// </summary>
293
        /// <param name="mustBeBelow">The lower bound (excluding the indicated number)</param>
294
        /// <param name="mustBeAbove">The upper bound (excluding the indicated number)</param>
295
        /// <returns>The Condition</returns>
296
        public static CardsFilterCondition LabelCountNotBetween(int mustBeBelow, int mustBeAbove)
297
        {
UNCOV
298
            var decimals = new List<decimal>() { mustBeBelow, mustBeAbove };
×
299
            return AdvancedNumberCondition(CardsConditionField.Label, CardsConditionNumber.NotBetween, decimals.ToArray());
×
300
        }
301

302
        /// <summary>
303
        /// Create a condition to only return cards that have at least 1 Member (not a specific one)
304
        /// </summary>
305
        /// <returns>The Condition</returns>
306
        public static CardsFilterCondition HasAnyMember()
307
        {
UNCOV
308
            return new CardsFilterCondition
×
309
            {
×
310
                Field = CardsConditionField.Member,
×
311
                Condition = CardsCondition.HasAnyValue
×
312
            };
×
313
        }
314

315
        /// <summary>
316
        /// Create a condition to only return cards that have no members at all assigned to them
317
        /// </summary>
318
        /// <returns>The Condition</returns>
319
        public static CardsFilterCondition HasNoMembers()
320
        {
321
            return new CardsFilterCondition
×
322
            {
×
323
                Field = CardsConditionField.Member,
×
UNCOV
324
                Condition = CardsCondition.DoNotHaveAnyValue
×
UNCOV
325
            };
×
326
        }
327

328
        /// <summary>
329
        /// Create a member-based condition  (example only cards that have 2 specific memberIds)
330
        /// </summary>
331
        /// <param name="condition">The condition for the memberIds</param>
332
        /// <param name="memberIds">One of more memberIds that the condition should adhere to</param>
333
        /// <returns>THe condition</returns>
334
        public static CardsFilterCondition MemberId(CardsConditionId condition, params string[] memberIds)
335
        {
UNCOV
336
            return AdvancedStringCondition(CardsConditionField.Member, (CardsConditionString)Convert.ToInt32(condition), memberIds);
×
337
        }
338

339
        /// <summary>
340
        /// Create a condition based on how many members are on the cards (example only return cards that have over 2 members on them)
341
        /// </summary>
342
        /// <param name="condition">The condition the member-count should meet</param>
343
        /// <param name="value">The count that the condition should adhere to</param>
344
        /// <returns>The condition</returns>
345
        public static CardsFilterCondition MemberCount(CardsConditionCount condition, int value)
346
        {
347
            return AdvancedNumberCondition(CardsConditionField.Member, (CardsConditionNumber)Convert.ToInt32(condition), value);
×
348
        }
349

350
        /// <summary>
351
        /// Create a condition based on how many cards have a member count in a certain range (Example the all cards that have between 1 and 2 members)
352
        /// </summary>
353
        /// <param name="min">The minimum count</param>
354
        /// <param name="max">The maximum count</param>
355
        /// <returns>The Condition</returns>
356
        public static CardsFilterCondition MemberCountBetween(int min, int max)
357
        {
UNCOV
358
            var decimals = new List<decimal>() { min, max };
×
UNCOV
359
            return AdvancedNumberCondition(CardsConditionField.Member, CardsConditionNumber.Between, decimals.ToArray());
×
360
        }
361

362
        /// <summary>
363
        /// Create a condition based on how many cards have a member count outside a certain range (Example the all cards that have below 3 or above 4 (ignoring cards with 3 and 4 members))
364
        /// </summary>
365
        /// <param name="mustBeBelow">The lower bound (excluding the indicated number)</param>
366
        /// <param name="mustBeAbove">The upper bound (excluding the indicated number)</param>
367
        /// <returns>The Condition</returns>
368
        public static CardsFilterCondition MemberCountNotBetween(int mustBeBelow, int mustBeAbove)
369
        {
UNCOV
370
            var decimals = new List<decimal>() { mustBeBelow, mustBeAbove };
×
UNCOV
371
            return AdvancedNumberCondition(CardsConditionField.Member, CardsConditionNumber.Between, decimals.ToArray());
×
372
        }
373

374
        /// <summary>
375
        /// Create a Due-date based condition
376
        /// </summary>
377
        /// <param name="condition">The condition the Due date should have</param>
378
        /// <param name="includeCardsThatAreMarkedAsComplete">Indicate if cards with due dates but are marked as completed should be included or not</param>
379
        /// <param name="dateTimeOffset">One of more dates the conditions should adhere to</param>
380
        /// <returns>The Condition</returns>
381
        public static CardsFilterCondition Due(CardsConditionDate condition, bool includeCardsThatAreMarkedAsComplete, params DateTimeOffset[] dateTimeOffset)
382
        {
UNCOV
383
            return AdvancedDateTimeOffsetCondition(includeCardsThatAreMarkedAsComplete ? CardsConditionField.Due : CardsConditionField.DueWithNoDueComplete, condition, dateTimeOffset);
×
384
        }
385

386
        /// <summary>
387
        /// Create a Condition where Due Date should be inside a certain date range
388
        /// </summary>
389
        /// <param name="includeCardsThatAreMarkedAsComplete">Indicate if cards with due dates but are marked as completed should be included or not</param>
390
        /// <param name="from">From Date</param>
391
        /// <param name="to">To Date</param>
392
        /// <returns>The Condition</returns>
393
        public static CardsFilterCondition DueBetween(bool includeCardsThatAreMarkedAsComplete, DateTimeOffset from, DateTimeOffset to)
394
        {
395
            return AdvancedDateTimeOffsetCondition(includeCardsThatAreMarkedAsComplete ? CardsConditionField.Due : CardsConditionField.DueWithNoDueComplete, CardsConditionDate.Between, from, to);
×
396
        }
397

398
        /// <summary>
399
        /// Create a Condition where Due Date should be outside a certain date range
400
        /// </summary>
401
        /// <param name="includeCardsThatAreMarkedAsComplete">Indicate if cards with due dates but are marked as completed should be included or not</param>
402
        /// <param name="mustBeBefore">Lower bound or the excluded range</param>
403
        /// <param name="mustBeAfter">Upper bound of the excluded range</param>
404
        /// <returns>THe Condition</returns>
405
        public static CardsFilterCondition DueNotBetween(bool includeCardsThatAreMarkedAsComplete, DateTimeOffset mustBeBefore, DateTimeOffset mustBeAfter)
406
        {
UNCOV
407
            return AdvancedDateTimeOffsetCondition(includeCardsThatAreMarkedAsComplete ? CardsConditionField.Due : CardsConditionField.DueWithNoDueComplete, CardsConditionDate.NotBetween, mustBeBefore, mustBeAfter);
×
408
        }
409

410
        /// <summary>
411
        /// Create a Condition where Start Date should be inside a certain date range
412
        /// </summary>
413
        /// <param name="from">From Date</param>
414
        /// <param name="to">To Date</param>
415
        /// <returns>The Condition</returns>
416
        public static CardsFilterCondition StartBetween(DateTimeOffset from, DateTimeOffset to)
417
        {
UNCOV
418
            return AdvancedDateTimeOffsetCondition(CardsConditionField.Start, CardsConditionDate.Between, from, to);
×
419
        }
420

421
        /// <summary>
422
        /// Create a Condition where Start Date should be outside a certain date range
423
        /// </summary>
424
        /// <param name="mustBeBefore">Lower bound or the excluded range</param>
425
        /// <param name="mustBeAfter">Upper bound of the excluded range</param>
426
        /// <returns>THe Condition</returns>
427
        public static CardsFilterCondition StartNotBetween(DateTimeOffset mustBeBefore, DateTimeOffset mustBeAfter)
428
        {
UNCOV
429
            return AdvancedDateTimeOffsetCondition(CardsConditionField.Start, CardsConditionDate.NotBetween, mustBeBefore, mustBeAfter);
×
430
        }
431

432
        /// <summary>
433
        /// Create a Condition where Created Date should be inside a certain date range
434
        /// </summary>
435
        /// <param name="from">From Date</param>
436
        /// <param name="to">To Date</param>
437
        /// <returns>The Condition</returns>
438
        public static CardsFilterCondition CreatedBetween(DateTimeOffset from, DateTimeOffset to)
439
        {
UNCOV
440
            return AdvancedDateTimeOffsetCondition(CardsConditionField.Created, CardsConditionDate.Between, from, to);
×
441
        }
442

443
        /// <summary>
444
        /// Create a Condition where Created Date should be outside a certain date range
445
        /// </summary>
446
        /// <param name="mustBeBefore">Lower bound or the excluded range</param>
447
        /// <param name="mustBeAfter">Upper bound of the excluded range</param>
448
        /// <returns>THe Condition</returns>
449
        public static CardsFilterCondition CreatedNotBetween(DateTimeOffset mustBeBefore, DateTimeOffset mustBeAfter)
450
        {
UNCOV
451
            return AdvancedDateTimeOffsetCondition(CardsConditionField.Created, CardsConditionDate.NotBetween, mustBeBefore, mustBeAfter);
×
452
        }
453

454
        /// <summary>
455
        /// Create a condition that only return cards that have due dates past UTC Now (and are not marked as completed)
456
        /// </summary>
457
        /// <returns>The Condition</returns>
458
        public static CardsFilterCondition Overdue()
459
        {
UNCOV
460
            return new CardsFilterCondition
×
UNCOV
461
            {
×
UNCOV
462
                Field = CardsConditionField.DueWithNoDueComplete,
×
UNCOV
463
                Condition = CardsCondition.LessThanOrEqual,
×
UNCOV
464
                ValueAsDateTimeOffset = DateTimeOffset.UtcNow
×
UNCOV
465
            };
×
466
        }
467

468
        /// <summary>
469
        /// Create a condition that only return cards that are due Today (Due between start and end of today and are not marked as completed)
470
        /// </summary>
471
        /// <returns>The Condition</returns>
472
        public static CardsFilterCondition DueToday()
473
        {
UNCOV
474
            DateTime startOfToday = DateTimeOffset.UtcNow.Date;
×
UNCOV
475
            return new CardsFilterCondition
×
UNCOV
476
            {
×
UNCOV
477
                Field = CardsConditionField.DueWithNoDueComplete,
×
UNCOV
478
                Condition = CardsCondition.Between,
×
UNCOV
479
                ValueAsDateTimeOffsets = new List<DateTimeOffset> { startOfToday, startOfToday.AddDays(1).AddSeconds(-1) }
×
UNCOV
480
            };
×
481
        }
482

483
        /// <summary>
484
        /// Create a condition that only return cards that have a due date that is past UTC Now (and are not marked as completed)
485
        /// </summary>
486
        /// <returns>The Condition</returns>
487
        public static CardsFilterCondition NotOverdue()
488
        {
UNCOV
489
            return new CardsFilterCondition
×
UNCOV
490
            {
×
UNCOV
491
                Field = CardsConditionField.DueWithNoDueComplete,
×
UNCOV
492
                Condition = CardsCondition.GreaterThan,
×
UNCOV
493
                ValueAsDateTimeOffset = DateTimeOffset.UtcNow
×
UNCOV
494
            };
×
495
        }
496

497
        /// <summary>
498
        /// Create a Condition that only return cards that have a Start date that is past UTC Now
499
        /// </summary>
500
        /// <returns>The Condition</returns>
501
        public static CardsFilterCondition Started()
502
        {
UNCOV
503
            return new CardsFilterCondition
×
UNCOV
504
            {
×
UNCOV
505
                Field = CardsConditionField.Start,
×
UNCOV
506
                Condition = CardsCondition.LessThanOrEqual,
×
UNCOV
507
                ValueAsDateTimeOffset = DateTimeOffset.UtcNow
×
UNCOV
508
            };
×
509
        }
510

511
        /// <summary>
512
        /// Create a Condition that only return cards that have a start date that are after UTC Now
513
        /// </summary>
514
        /// <returns>The condition</returns>
515
        public static CardsFilterCondition NotStarted()
516
        {
UNCOV
517
            return new CardsFilterCondition
×
UNCOV
518
            {
×
UNCOV
519
                Field = CardsConditionField.Start,
×
UNCOV
520
                Condition = CardsCondition.GreaterThan,
×
UNCOV
521
                ValueAsDateTimeOffset = DateTimeOffset.UtcNow
×
UNCOV
522
            };
×
523
        }
524

525
        /// <summary>
526
        /// Create a condition to only return cards that have a due date assigned to them
527
        /// </summary>
528
        /// <param name="includeCardsThatAreMarkedAsComplete">Indicate if cards with due dates but are marked as completed should be included or not</param>
529
        /// <returns>The Condition</returns>
530
        public static CardsFilterCondition HasDueDate(bool includeCardsThatAreMarkedAsComplete)
531
        {
UNCOV
532
            return new CardsFilterCondition
×
UNCOV
533
            {
×
UNCOV
534
                Field = includeCardsThatAreMarkedAsComplete ? CardsConditionField.Due : CardsConditionField.DueWithNoDueComplete,
×
UNCOV
535
                Condition = CardsCondition.HasAnyValue
×
UNCOV
536
            };
×
537
        }
538

539
        /// <summary>
540
        /// Create a condition to only return cards that have no due dates assigned to them
541
        /// </summary>
542
        /// <returns>The Condition</returns>
543
        public static CardsFilterCondition HasNoDueDate()
544
        {
UNCOV
545
            return new CardsFilterCondition
×
UNCOV
546
            {
×
UNCOV
547
                Field = CardsConditionField.Due,
×
UNCOV
548
                Condition = CardsCondition.DoNotHaveAnyValue
×
UNCOV
549
            };
×
550
        }
551

552
        /// <summary>
553
        /// Create a condition to only return cards that have a start dates assigned to them
554
        /// </summary>
555
        /// <returns>The Condition</returns>
556
        public static CardsFilterCondition HasStartDate()
557
        {
UNCOV
558
            return new CardsFilterCondition
×
UNCOV
559
            {
×
UNCOV
560
                Field = CardsConditionField.Start,
×
UNCOV
561
                Condition = CardsCondition.HasAnyValue
×
UNCOV
562
            };
×
563
        }
564

565
        /// <summary>
566
        /// Create a condition to only return cards that have no start dates assigned to them
567
        /// </summary>
568
        /// <returns>The Condition</returns>
569
        public static CardsFilterCondition HasNoStartDate()
570
        {
UNCOV
571
            return new CardsFilterCondition
×
UNCOV
572
            {
×
UNCOV
573
                Field = CardsConditionField.Start,
×
UNCOV
574
                Condition = CardsCondition.DoNotHaveAnyValue
×
UNCOV
575
            };
×
576
        }
577

578
        /// <summary>
579
        /// Create a Start-date based condition
580
        /// </summary>
581
        /// <param name="condition">The condition the Start date should have</param>
582
        /// <param name="dateTimeOffset">One of more dates the conditions should adhere to</param>
583
        /// <returns>The Condition</returns>
584
        public static CardsFilterCondition Start(CardsConditionDate condition, params DateTimeOffset[] dateTimeOffset)
585
        {
UNCOV
586
            return AdvancedDateTimeOffsetCondition(CardsConditionField.Start, condition, dateTimeOffset);
×
587
        }
588

589
        /// <summary>
590
        /// Create a Created-date based condition
591
        /// </summary>
592
        /// <param name="condition">The condition the Created date should have</param>
593
        /// <param name="dateTimeOffset">One of more dates the conditions should adhere to</param>
594
        /// <returns>The Condition</returns>
595
        public static CardsFilterCondition Created(CardsConditionDate condition, params DateTimeOffset[] dateTimeOffset)
596
        {
UNCOV
597
            return AdvancedDateTimeOffsetCondition(CardsConditionField.Created, condition, dateTimeOffset);
×
598
        }
599

600
        /// <summary>
601
        /// Create a generic string-based Condition
602
        /// </summary>
603
        /// <param name="field">Field to Check</param>
604
        /// <param name="condition">Condition to have</param>
605
        /// <param name="strings">One or more string the condition should adhere to</param>
606
        /// <returns>The Condition</returns>
607
        public static CardsFilterCondition AdvancedStringCondition(CardsConditionField field, CardsConditionString condition, params string[] strings)
608
        {
UNCOV
609
            List<string> values = null;
×
UNCOV
610
            string value = null;
×
UNCOV
611
            if (strings.Length == 1)
×
612
            {
UNCOV
613
                value = strings[0];
×
614
            }
615
            else
616
            {
UNCOV
617
                values = strings.ToList();
×
618
            }
619

UNCOV
620
            return new CardsFilterCondition
×
UNCOV
621
            {
×
UNCOV
622
                Field = field,
×
UNCOV
623
                Condition = (CardsCondition)Convert.ToInt32(condition),
×
UNCOV
624
                ValueAsStrings = values,
×
UNCOV
625
                ValueAsString = value
×
UNCOV
626
            };
×
627
        }
628

629
        /// <summary>
630
        /// Create a generic number-based Condition
631
        /// </summary>
632
        /// <param name="field">Field to Check</param>
633
        /// <param name="condition">Condition to have</param>
634
        /// <param name="numbers">One or more numbers the condition should adhere to</param>
635
        /// <returns>The Condition</returns>
636
        public static CardsFilterCondition AdvancedNumberCondition(CardsConditionField field, CardsConditionNumber condition, params decimal[] numbers)
637
        {
UNCOV
638
            List<decimal> values = null;
×
UNCOV
639
            decimal? value = null;
×
UNCOV
640
            if (numbers.Length == 1)
×
641
            {
UNCOV
642
                value = numbers[0];
×
643
            }
644
            else
645
            {
UNCOV
646
                values = numbers.ToList();
×
647
            }
648

UNCOV
649
            return new CardsFilterCondition
×
UNCOV
650
            {
×
UNCOV
651
                Field = field,
×
UNCOV
652
                Condition = (CardsCondition)Convert.ToInt32(condition),
×
UNCOV
653
                ValueAsNumbers = values,
×
UNCOV
654
                ValueAsNumber = value
×
UNCOV
655
            };
×
656
        }
657

658
        /// <summary>
659
        /// Create a generic date-based Condition
660
        /// </summary>
661
        /// <param name="field">Field to Check</param>
662
        /// <param name="condition">Condition to have</param>
663
        /// <param name="datetimeOffsets">One or more dates the condition should adhere to</param>
664
        /// <returns>The Condition</returns>
665
        public static CardsFilterCondition AdvancedDateTimeOffsetCondition(CardsConditionField field, CardsConditionDate condition, params DateTimeOffset[] datetimeOffsets)
666
        {
UNCOV
667
            List<DateTimeOffset> values = null;
×
UNCOV
668
            DateTimeOffset? value = null;
×
UNCOV
669
            if (datetimeOffsets.Length == 1)
×
670
            {
UNCOV
671
                value = datetimeOffsets[0];
×
672
            }
673
            else
674
            {
UNCOV
675
                values = datetimeOffsets.ToList();
×
676
            }
677

UNCOV
678
            return new CardsFilterCondition
×
UNCOV
679
            {
×
UNCOV
680
                Field = field,
×
UNCOV
681
                Condition = (CardsCondition)Convert.ToInt32(condition),
×
UNCOV
682
                ValueAsDateTimeOffsets = values,
×
UNCOV
683
                ValueAsDateTimeOffset = value
×
UNCOV
684
            };
×
685
        }
686
    }
687
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc