private void Test_Get_Current_Project_Without_Persisted_Id()
        {
            var tracker       = GetTracker();
            var returnProject = new PivotalProject {
                Id = 1, Name = "Project 1", Public = true
            };
            var response = CreateResponse(returnProject);

            FakeHttpService.Setup(x => x.GetAsync(It.IsAny <string>())).Returns(Task.FromResult(response));

            var project = tracker.GetCurrentProjectAsync(1);

            Assert.NotNull(project);
        }
        public void Test_PivotalTracker_Authentication_Sets_ApiToken()
        {
            var tracker    = GetTracker();
            var returnUser = new PivotalUser
            {
                Username = "******",
                ApiToken = "MyToken"
            };
            var response = CreateResponse(returnUser);

            FakeHttpService.Setup(x => x.AuthorizeAsync(It.IsAny <string>(), It.IsAny <string>())).Returns(Task.FromResult(response));
            var auth = tracker.AuthorizeAsync("test", "test").Result;

            Assert.Equal(returnUser.ApiToken, tracker.ApiToken);
        }
        private void Test_Search_By_Query()
        {
            var tracker       = GetTracker();
            var returnStories = new PivotalSearchModel {
                Query = "label: \"my label\""
            };
            var response = CreateResponse(returnStories);

            FakeHttpService.Setup(x => x.GetAsync(It.IsAny <string>())).Returns(Task.FromResult(response));

            var query         = "label: \"my label\"";
            var searchStories = tracker.SearchByQueryAsync(1, query);

            Assert.Equal(query, searchStories.Result.Query);
        }
        public void Test_PivotalTracker_Authentication_With_Credentials_Returns_User()
        {
            var tracker    = GetTracker();
            var returnUser = new PivotalUser
            {
                Username = "******",
                ApiToken = "MyToken"
            };
            var response = CreateResponse(returnUser);

            FakeHttpService.Setup(x => x.AuthorizeAsync(It.IsAny <string>(), It.IsAny <string>())).Returns(Task.FromResult(response));
            tracker.AuthorizeAsync("testUser", "testPassword");
            FakeHttpService.Setup(x => x.GetAsync(It.IsAny <string>())).Returns(Task.FromResult(response));

            var user = tracker.GetUserAsync().Result;

            Assert.Equal(user.ApiToken, returnUser.ApiToken);
        }
        public void Test_Get_User_Returns_User()
        {
            var tracker    = GetTracker();
            var returnUser = new PivotalUser
            {
                Email    = "*****@*****.**",
                Id       = 27,
                Initials = "TU",
                Name     = "Test User",
                Username = "******"
            };
            var response = CreateResponse(returnUser);

            FakeHttpService.Setup(x => x.GetAsync(It.IsAny <string>())).Returns(Task.FromResult(response));

            var user = tracker.GetUserAsync().Result;

            Assert.Equal(returnUser.Id, user.Id);
        }
        public void Test_Get_Projects_Returns_Projects()
        {
            var tracker        = GetTracker();
            var returnProjects = new List <PivotalProject>
            {
                new PivotalProject {
                    Id = 1, Name = "Project 1", Public = true
                },
                new PivotalProject {
                    Id = 2, Name = "Project 2", Public = false
                },
                new PivotalProject {
                    Id = 3, Name = "Project 3", Public = false
                }
            };
            var response = CreateResponse(returnProjects);

            FakeHttpService.Setup(x => x.GetAsync(It.IsAny <string>())).Returns(Task.FromResult(response));

            var projects = tracker.GetProjectsAsync().Result;

            Assert.Equal(3, projects.Count);
        }
        private void Test_Get_Project_Stories()
        {
            var tracker       = GetTracker();
            var returnStories = new List <PivotalStory>
            {
                new PivotalStory {
                    Id = 1, Name = "Story 1"
                },
                new PivotalStory {
                    Id = 2, Name = "Story 2"
                },
                new PivotalStory {
                    Id = 3, Name = "Story 3"
                },
            };
            var response = CreateResponse(returnStories);

            FakeHttpService.Setup(x => x.GetAsync(It.IsAny <string>())).Returns(Task.FromResult(response));

            var stories = tracker.GetProjectStoriesAsync(1);

            Assert.NotNull(stories);
        }