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

rwjdk / TrelloDotNet / 10590394740

28 Aug 2024 04:51AM UTC coverage: 61.117% (-0.4%) from 61.47%
10590394740

push

github

rwjdk
Add SubType for UpdateCardTrigger

897 of 1837 branches covered (48.83%)

Branch coverage included in aggregate %.

8 of 26 new or added lines in 1 file covered. (30.77%)

6 existing lines in 3 files now uncovered.

2341 of 3461 relevant lines covered (67.64%)

50.55 hits per line

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

29.17
/TrelloDotNet/TrelloDotNet/AutomationEngine/Model/Triggers/CardUpdatedTrigger.cs
1
using System;
2
using System.Threading.Tasks;
3
using TrelloDotNet.AutomationEngine.Interface;
4
using TrelloDotNet.Model.Webhook;
5

6
namespace TrelloDotNet.AutomationEngine.Model.Triggers
7
{
8
    /// <summary>
9
    /// Trigger when a card is Updated (This happens in various basic events so is kind of a catch all Trigger to things happening on a card)
10
    /// </summary>
11
    public class CardUpdatedTrigger : IAutomationTrigger
12
    {
13
        private readonly CardUpdatedTriggerSubType? _subType;
14

15
        /// <summary>
16
        /// Constructor
17
        /// </summary>
18
        public CardUpdatedTrigger()
2✔
19
        {
20
            _subType = null;
2✔
21
        }
2✔
22

23
        /// <summary>
24
        /// Constructor
25
        /// </summary>
26
        /// <param name="subType">Optional SubType (Example: if it was the name that was updated, the due date, or something else) - If not specified this will react to any card update event</param>
NEW
27
        public CardUpdatedTrigger(CardUpdatedTriggerSubType subType)
×
28
        {
NEW
29
            _subType = subType;
×
NEW
30
        }
×
31

32

33
        /// <summary>
34
        /// If the Trigger is met
35
        /// </summary>
36
        /// <remarks>
37
        /// While this is built to support async execution, It is best practice to keep a Trigger as light as possible only checking values against the webhook Action and not make any API Calls. The reason for this is that Triggers are called quite often, so it is better to make simple triggers and supplement with Conditions
38
        /// </remarks>
39
        /// <param name="webhookAction">The Webhook Action that led to the check of the trigger. This object also have the TrelloClient and information about the event at your disposal</param>
40
        /// <returns>If trigger is met or not</returns>
41
        public async Task<bool> IsTriggerMetAsync(WebhookAction webhookAction)
42
        {
43
            await Task.CompletedTask;
2✔
44
            var isUpdateCard = webhookAction.Type == WebhookActionTypes.UpdateCard;
2✔
45
            if (!isUpdateCard)
2✔
46
            {
47
                return false;
1✔
48
            }
49

50
            switch (_subType)
1!
51
            {
52
                case CardUpdatedTriggerSubType.NameChanged:
NEW
53
                    return webhookAction.Display.TranslationKey == "action_renamed_card";
×
54
                case CardUpdatedTriggerSubType.DescriptionChanged:
NEW
55
                    return webhookAction.Display.TranslationKey == "action_changed_description_of_card";
×
56
                case CardUpdatedTriggerSubType.DueDateAdded:
NEW
57
                    return webhookAction.Display.TranslationKey == "action_added_a_due_date";
×
58
                case CardUpdatedTriggerSubType.DueDateChanged:
NEW
59
                    return webhookAction.Display.TranslationKey == "action_changed_a_due_date";
×
60
                case CardUpdatedTriggerSubType.DueDateMarkedAsComplete:
NEW
61
                    return webhookAction.Display.TranslationKey == "action_marked_the_due_date_complete";
×
62
                case CardUpdatedTriggerSubType.DueDateMarkedAsIncomplete:
NEW
63
                    return webhookAction.Display.TranslationKey == "action_marked_the_due_date_incomplete";
×
64
                case CardUpdatedTriggerSubType.DueDateRemoved:
NEW
65
                    return webhookAction.Display.TranslationKey == "action_removed_a_due_date";
×
66
                case CardUpdatedTriggerSubType.StartDateAdded:
NEW
67
                    return webhookAction.Display.TranslationKey == "action_added_a_start_date";
×
68
                case CardUpdatedTriggerSubType.StartDateChanged:
NEW
69
                    return webhookAction.Display.TranslationKey == "action_changed_a_start_date";
×
70
                case CardUpdatedTriggerSubType.StartDateRemoved:
NEW
71
                    return webhookAction.Display.TranslationKey == "action_removed_a_start_date";
×
72
                case CardUpdatedTriggerSubType.MovedToOtherList:
NEW
73
                    return webhookAction.Display.TranslationKey == "action_move_card_from_list_to_list";
×
74
                case CardUpdatedTriggerSubType.MovedHigherInList:
NEW
75
                    return webhookAction.Display.TranslationKey == "action_moved_card_higher";
×
76
                case CardUpdatedTriggerSubType.MovedLowerInList:
NEW
77
                    return webhookAction.Display.TranslationKey == "action_moved_card_lower";
×
78
                case CardUpdatedTriggerSubType.Archived:
NEW
79
                    return webhookAction.Display.TranslationKey == "action_archived_card";
×
80
                case CardUpdatedTriggerSubType.Unarchived:
NEW
81
                    return webhookAction.Display.TranslationKey == "action_sent_card_to_board";
×
82
            }
83

84
            return true;
1✔
85
        }
2✔
86
    }
87
}
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

© 2025 Coveralls, Inc