public void Test0ArgCreatePlusDataSource_ReturnsNullForNoCredentials()
        {
            CredentialStoreMock.SetupGet(cs => cs.CurrentGoogleCredential).Returns(() => null);

            IGPlusDataSource result = _objectUnderTest.CreatePlusDataSource();

            Assert.IsNull(result);
        }
예제 #2
0
        public UserAccountViewModel(IUserAccount userAccount)
        {
            UserAccount = userAccount;

            AccountName = userAccount.AccountName;

            Task <Person> personTask;

            try
            {
                IDataSourceFactory dataSourceFactory = DataSourceFactory.Default;
                IGPlusDataSource   dataSource        = dataSourceFactory.CreatePlusDataSource(userAccount.GetGoogleCredential());
                personTask = dataSource.GetProfileAsync();
            }
            catch (Exception)
            {
                personTask = Task.FromResult <Person>(null);
            }


            // TODO: Show the default image while it is being loaded.
            ProfilePictureAsync = AsyncProperty.Create(personTask, x => x?.Image.Url);
            NameAsync           = AsyncProperty.Create(personTask, x => x?.DisplayName, Resources.UiLoadingMessage);
        }