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

rwjdk / TrelloDotNet / 15715919831

17 Jun 2025 07:01PM UTC coverage: 79.816% (-0.5%) from 80.303%
15715919831

push

github

rwjdk
Version 2.0.6

2539 of 3460 branches covered (73.38%)

Branch coverage included in aggregate %.

27 of 75 new or added lines in 9 files covered. (36.0%)

6 existing lines in 2 files now uncovered.

4480 of 5334 relevant lines covered (83.99%)

107.47 hits per line

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

88.68
/src/TrelloDotNet/TrelloClient.Lists.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Threading;
5
using System.Threading.Tasks;
6
using TrelloDotNet.Control;
7
using TrelloDotNet.Model;
8
using TrelloDotNet.Model.Options.GetBoardOptions;
9
using TrelloDotNet.Model.Options.GetListOptions;
10

11
namespace TrelloDotNet
12
{
13
    public partial class TrelloClient
14
    {
15
        /// <summary>
16
        /// Adds a new list (column) to a board.
17
        /// </summary>
18
        /// <param name="list">The list object to add</param>
19
        /// <param name="cancellationToken">Cancellation Token</param>
20
        /// <returns>The created list</returns>
21
        public async Task<List> AddListAsync(List list, CancellationToken cancellationToken = default)
22
        {
23
            var parameters = _queryParametersBuilder.GetViaQueryParameterAttributes(list);
123✔
24
            _queryParametersBuilder.AdjustForNamedPosition(parameters, list.NamedPosition);
123✔
25
            return await _apiRequestController.Post<List>($"{UrlPaths.Lists}", cancellationToken, parameters);
123✔
26
        }
123✔
27

28
        /// <summary>
29
        /// Archives a list.
30
        /// </summary>
31
        /// <param name="listId">The ID of the list to archive</param>
32
        /// <param name="cancellationToken">Cancellation Token</param>
33
        /// <returns>The archived list</returns>
34
        public async Task<List> ArchiveListAsync(string listId, CancellationToken cancellationToken = default)
35
        {
36
            return await _apiRequestController.Put<List>($"{UrlPaths.Lists}/{listId}", cancellationToken, new QueryParameter("closed", true));
4✔
37
        }
4✔
38

39
        /// <summary>
40
        /// Permanently deletes a list and any cards it contains. This operation is irreversible. Use ArchiveListAsync for a non-permanent alternative.
41
        /// </summary>
42
        /// <param name="listId">The ID of the list to delete</param>
43
        /// <param name="cancellationToken">Cancellation Token</param>
44
        public async Task DeleteListAsync(string listId, CancellationToken cancellationToken = default)
45
        {
46
            await ArchiveListAsync(listId, cancellationToken);
3✔
47
            await _apiRequestController.Delete($"{UrlPaths.Lists}/{listId}", cancellationToken, 0);
3✔
48
        }
3✔
49

50
        /// <summary>
51
        /// Reopens an archived list, making it active on the board again.
52
        /// </summary>
53
        /// <param name="listId">The ID of the list to reopen</param>
54
        /// <param name="cancellationToken">Cancellation Token</param>
55
        /// <returns>The reopened list</returns>
56
        public async Task<List> ReOpenListAsync(string listId, CancellationToken cancellationToken = default)
57
        {
58
            return await _apiRequestController.Put<List>($"{UrlPaths.Lists}/{listId}", cancellationToken, new QueryParameter("closed", false));
1✔
59
        }
1✔
60

61
        /// <summary>
62
        /// Updates the properties of an existing list.
63
        /// </summary>
64
        /// <param name="listWithChanges">The list object containing the updated properties</param>
65
        /// <param name="cancellationToken">Cancellation Token</param>
66
        /// <returns>The updated list</returns>
67
        [Obsolete("Use UpdateList overload that does delta updates (List<ListUpdate> valuesToUpdate). This Method will be removed in TrelloDotNet 3.0")]
68
        public async Task<List> UpdateListAsync(List listWithChanges, CancellationToken cancellationToken = default)
69
        {
UNCOV
70
            var parameters = _queryParametersBuilder.GetViaQueryParameterAttributes(listWithChanges);
×
UNCOV
71
            _queryParametersBuilder.AdjustForNamedPosition(parameters, listWithChanges.NamedPosition);
×
UNCOV
72
            return await _apiRequestController.Put<List>($"{UrlPaths.Lists}/{listWithChanges.Id}", cancellationToken, parameters);
×
UNCOV
73
        }
×
74

75
        /// <summary>
76
        /// Updates one or more specific fields on a List, such as name, position, etc.
77
        /// </summary>
78
        /// <param name="listId">The ID of the board to update.</param>
79
        /// <param name="valuesToUpdate">A collection of updates to apply to the list. <see cref="ListUpdate"/></param>
80
        /// <param name="cancellationToken">CancellationToken</param>
81
        /// <returns>The updated <see cref="List"/>.</returns>
82
        public async Task<List> UpdateListAsync(string listId, List<ListUpdate> valuesToUpdate, CancellationToken cancellationToken = default)
83
        {
84
            var parameters = valuesToUpdate.Select(x => x.ToQueryParameter()).ToList();
2✔
85
            return await _apiRequestController.Put<List>($"{UrlPaths.Lists}/{listId}", cancellationToken, parameters.ToArray());
1✔
86
        }
1✔
87

88
        /// <summary>
89
        /// Moves an entire list to another board.
90
        /// </summary>
91
        /// <param name="listId">The ID of the list to move</param>
92
        /// <param name="newBoardId">The ID of the board to move the list to</param>
93
        /// <param name="cancellationToken">Cancellation Token</param>
94
        /// <returns>The updated list after moving</returns>
95
        public async Task<List> MoveListToBoardAsync(string listId, string newBoardId, CancellationToken cancellationToken = default)
96
        {
97
            return await _apiRequestController.Put<List>($"{UrlPaths.Lists}/{listId}/idBoard", cancellationToken, new QueryParameter("value", newBoardId));
1✔
98
        }
1✔
99

100
        /// <summary>
101
        /// Retrieves a specific list (column) by its ID.
102
        /// </summary>
103
        /// <param name="listId">ID of the list to retrieve</param>
104
        /// <param name="cancellationToken">Cancellation Token</param>
105
        /// <returns>The requested list</returns>
106
        public async Task<List> GetListAsync(string listId, CancellationToken cancellationToken = default)
107
        {
108
            return await _apiRequestController.Get<List>(GetUrlBuilder.GetList(listId), cancellationToken);
7✔
109
        }
7✔
110

111
        /// <summary>
112
        /// Retrieves a specific list (column) by its ID, with additional options for selection.
113
        /// </summary>
114
        /// <param name="listId">ID of the list to retrieve</param>
115
        /// <param name="options">Options for retrieving the list</param>
116
        /// <param name="cancellationToken">Cancellation Token</param>
117
        /// <returns>The requested list</returns>
118
        public async Task<List> GetListAsync(string listId, GetListOptions options, CancellationToken cancellationToken = default)
119
        {
120
            return await _apiRequestController.Get<List>(GetUrlBuilder.GetList(listId), cancellationToken, options.GetParameters());
1✔
121
        }
1✔
122

123
        /// <summary>
124
        /// Retrieves all lists (columns) on a specific board.
125
        /// </summary>
126
        /// <param name="boardId">ID of the board (long or short version) to retrieve lists from</param>
127
        /// <param name="cancellationToken">Cancellation Token</param>
128
        /// <returns>List of lists (columns) on the board</returns>
129
        public async Task<List<List>> GetListsOnBoardAsync(string boardId, CancellationToken cancellationToken = default)
130
        {
131
            return await _apiRequestController.Get<List<List>>(GetUrlBuilder.GetListsOnBoard(boardId), cancellationToken);
43✔
132
        }
43✔
133

134
        /// <summary>
135
        /// Retrieves all lists (columns) on a specific board, with additional options for filtering and selection.
136
        /// </summary>
137
        /// <param name="boardId">ID of the board (long or short version) to retrieve lists from</param>
138
        /// <param name="options">Options for retrieving the lists</param>
139
        /// <param name="cancellationToken">Cancellation Token</param>
140
        /// <returns>List of lists (columns) on the board</returns>
141
        public async Task<List<List>> GetListsOnBoardAsync(string boardId, GetListOptions options, CancellationToken cancellationToken = default)
142
        {
143
            List<List> lists;
144
            options.AdjustFieldsBasedOnSelectedOptions();
8✔
145

146
            if (options.Filter.HasValue)
8!
147
            {
148
                lists = await _apiRequestController.Get<List<List>>($"{GetUrlBuilder.GetListsOnBoard(boardId)}/{options.Filter.GetJsonPropertyName()}", cancellationToken, options.GetParameters());
8✔
149
            }
150
            else
151
            {
152
                lists = await _apiRequestController.Get<List<List>>(GetUrlBuilder.GetListsOnBoard(boardId), cancellationToken, options.GetParameters());
×
153
            }
154

155
            // ReSharper disable once InvertIf
156
            if (options.IncludeBoard)
8✔
157
            {
158
                var board = await GetBoardAsync(boardId, new GetBoardOptions
1✔
159
                {
1✔
160
                    BoardFields = options.BoardFields
1✔
161
                }, cancellationToken);
1✔
162
                foreach (List list in lists)
4✔
163
                {
164
                    list.Board = board;
1✔
165
                }
166
            }
167

168
            if (options.IncludeCards != GetListOptionsIncludeCards.None)
8✔
169
            {
170
                foreach (List list in lists)
4✔
171
                {
172
                    list.Cards = FilterCards(list.Cards, options.CardsFilterConditions);
1✔
173
                    list.Cards = OrderCards(list.Cards, options.CardsOrderBy);
1✔
174
                }
175
            }
176

177
            return lists;
8✔
178
        }
8✔
179
    }
180
}
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