示例#1
0
        public async Task TestCache()
        {
            var       username  = Environment.GetEnvironmentVariable("jira_test_username");
            var       password  = Environment.GetEnvironmentVariable("jira_test_password");
            LoginInfo loginInfo = null;

            if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
            {
                loginInfo = await _jiraApi.StartSessionAsync(username, password);
            }
            var me = await _jiraApi.WhoAmIAsync();

            Assert.Equal(me.Name, username);

            var avatar = await _avatarCache.GetOrCreateAsync(me.Avatars);

            Assert.NotNull(avatar);
            Assert.True(avatar.Width > 0);

            avatar = await _avatarCache.GetAsync(me.Avatars);

            Assert.NotNull(avatar);
            Assert.True(avatar.Width > 0);

            // when changing the size, the value is no longer available.
            _avatarCache.AvatarSize = AvatarSizes.Small;
            avatar = await _avatarCache.GetAsync(me.Avatars);

            Assert.Null(avatar);

            if (loginInfo != null)
            {
                await _jiraApi.EndSessionAsync();
            }
        }
示例#2
0
        public async Task TestSession()
        {
            var username = Environment.GetEnvironmentVariable("jira_test_username");
            var password = Environment.GetEnvironmentVariable("jira_test_password");

            if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
            {
                await _jiraApi.StartSessionAsync(username, password);
            }
            var me = await _jiraApi.WhoAmIAsync();

            Assert.Equal(me.Name, username);
            await _jiraApi.EndSessionAsync();

            // WhoAmI should give an exception if there is no login
            await Assert.ThrowsAsync <Exception>(async() => await _jiraApi.WhoAmIAsync());
        }