Ejemplo n.º 1
0
        public async void GetToken_WithInvalidToken_MustResultEmpty()
        {
            var identity = IdentityBuilder.Create().Build();
            var token    = new OneDriveToken(identity);

            var expected = false;
            var actual   = await token.RefreshTokenAsync();

            Assert.Equal(expected, actual);
        }
        public async void RefreshTokenAsync_WithNullAccounts_MustResultFalse()
        {
            var identity = IdentityBuilder.Create().WithGetAccounts(accounts: null).Build();
            var token    = new OneDriveToken(identity);

            var expected = false;
            var actual   = await token.RefreshTokenAsync();

            Assert.Equal(expected, actual);
        }
        public async void RefreshTokenAsync_WithValidAccount_ButFailedAuth_MustResultFalse()
        {
            var identity = IdentityBuilder.Create().WithGetAccounts("Dummy Username").Build();
            var token    = new OneDriveToken(identity);

            var expected = false;
            var actual   = await token.RefreshTokenAsync();

            Assert.Equal(expected, actual);
        }
        public async void RefreshTokenAsync_WithException_MustResultFalse()
        {
            var ex       = new Exception("Just a test exception");
            var identity = IdentityBuilder.Create().WithGetAccounts(ex).Build();
            var token    = new OneDriveToken(identity);

            var expected = false;
            var actual   = await token.RefreshTokenAsync();

            Assert.Equal(expected, actual);
        }
        public async void RefreshTokenAsync_WithValidAccount_AndSuccessAuth_MustResultTrue()
        {
            var account  = IdentityBuilder.GetAccount("Dummy Username");
            var identity = IdentityBuilder
                           .Create()
                           .WithScopes(new string[] { "Dummy Scope" })
                           .WithGetAccounts(new IAccount[] { account })
                           .WithAcquireTokenSilent(account, "Dummy AccessCode", DateTimeOffset.UtcNow, new string[] { "Dummy Scope" })
                           .Build();
            var token = new OneDriveToken(identity);

            var expected = true;
            var actual   = await token.RefreshTokenAsync();

            Assert.Equal(expected, actual);
        }