public async Task <IEnumerable <TasksGroupResource> > ListGroupsAsync()
        {
            mLogger.LogDebug("Requesting groups");

            IEnumerable <ITasksGroup> groups = await mTasksGroupService.ListAsync().ConfigureAwait(false);

            IEnumerable <TasksGroupResource> taskGroupResources = mMapper
                                                                  .Map <IEnumerable <ITasksGroup>, IEnumerable <TasksGroupResource> >(groups);

            mLogger.LogDebug($"Found {taskGroupResources.Count()} groups");

            return(taskGroupResources);
        }
Exemple #2
0
        private async Task <ITasksGroup> GetSpecificGroup(string groupNameOrId)
        {
            mLogger.LogDebug($"Requesting all tasks from group id {groupNameOrId}");

            IEnumerable <ITasksGroup> taskGroups = await mTasksGroupService.ListAsync().ConfigureAwait(false);

            ITasksGroup group = taskGroups.SingleOrDefault(group => group.ID.Equals(groupNameOrId));

            if (group != null)
            {
                return(group);
            }

            mLogger.LogTrace($"Could not find tasks by id {groupNameOrId}, searching by name");
            return(taskGroups.SingleOrDefault(group => group.Name.Equals(groupNameOrId)));
        }
Exemple #3
0
        public async Task ListTasksOfSpecificGroupAsync_groupNotFound_EmptyListReturned()
        {
            ITasksGroupService tasksGroupService = A.Fake <ITasksGroupService>();

            A.CallTo(() => tasksGroupService.ListAsync()).Returns(new List <ITasksGroup>());

            using TestServer testServer        = ApiTestHelper.BuildTestServerWithFakes(tasksGroupService);
            using HttpClient httpClient        = testServer.CreateClient();
            using HttpResponseMessage response = await httpClient.GetAsync($"{MainRoute}/some-id").ConfigureAwait(false);

            string stringResponse = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

            IEnumerable <WorkTaskResource> workTaskResources =
                JsonConvert.DeserializeObject <IEnumerable <WorkTaskResource> >(stringResponse);

            Assert.Empty(workTaskResources);
        }
Exemple #4
0
        public async Task ListTasksOfSpecificGroupAsync_SuccessStatusCode()
        {
            const string groupId    = "some-id";
            ITasksGroup  tasksGroup = A.Fake <ITasksGroup>();

            A.CallTo(() => tasksGroup.ID).Returns(groupId);

            ITasksGroupService tasksGroupService = A.Fake <ITasksGroupService>();

            A.CallTo(() => tasksGroupService.ListAsync()).Returns(new List <ITasksGroup>());

            using TestServer testServer        = ApiTestHelper.BuildTestServerWithFakes(tasksGroupService);
            using HttpClient httpClient        = testServer.CreateClient();
            using HttpResponseMessage response = await httpClient.GetAsync($"{MainRoute}/{groupId}").ConfigureAwait(false);

            response.EnsureSuccessStatusCode();
        }