public async Task GetSortedActiveProjectsAsyncTestSuccess()
        {
            var responses = new[]
            {
                new ListProjectsResponse
                {
                    Projects = new List <Project> {
                        s_someProject, s_disabledProject
                    },
                    NextPageToken = "2"
                },
                new ListProjectsResponse
                {
                    Projects = new List <Project> {
                        s_aProject
                    },
                    NextPageToken = null
                }
            };
            CloudResourceManagerService service = GetMockedService(
                (CloudResourceManagerService s) => s.Projects, p => p.List(), responses);
            var dataSource = new ResourceManagerDataSource(null, init => service, null);

            IList <Project> projects = await dataSource.GetSortedActiveProjectsAsync();

            Assert.AreEqual(2, projects.Count);
            Assert.AreEqual(s_aProject, projects[0]);
            Assert.AreEqual(s_someProject, projects[1]);
        }
        /// <summary>
        /// Return a list of projects. Returns empty list if no item is found.
        /// </summary>
        private async Task <IList <Project> > GetProjectsAsync()
        {
            ResourceManagerDataSource resourceManager = DataSourceFactories.CreateResourceManagerDataSource();

            if (resourceManager == null)
            {
                return(new List <Project>());
            }

            IsReady = false;
            try
            {
                var projects = await resourceManager.GetSortedActiveProjectsAsync();

                if (!projects.Any())
                {
                    UserPromptUtils.OkPrompt(
                        message: Resources.CsrNoProjectMessage,
                        title: Resources.CsrConnectSectionTitle);
                }
                return(projects);
            }
            finally
            {
                IsReady = true;
            }
        }
        public async Task GetSortedActiveProjectsAsyncTestException()
        {
            // Empty response list triggers GoogleApiException.
            var responses = new ListProjectsResponse[0];
            CloudResourceManagerService service = GetMockedService(
                (CloudResourceManagerService s) => s.Projects, p => p.List(), responses);
            var dataSource = new ResourceManagerDataSource(null, init => service, null);

            await dataSource.GetSortedActiveProjectsAsync();
        }