public async Task Should_Delete()
        {
            const int listId = 14;
            string    path   = $"/api/lists/{listId}";

            MockRestClient.Setup(m => m.DeleteAsync <DeleteListResponse>(It.Is <string>(a => a == path))).ReturnsAsync(new ApiResponse <DeleteListResponse>
            {
                UrlPath        = path,
                HttpStatusCode = HttpStatusCode.OK,
                Model          = new DeleteListResponse
                {
                    Code = "Success"
                }
            });

            ApiResponse <DeleteListResponse> response = await _listClient.DeleteAsync(listId).ConfigureAwait(false);

            Assert.NotNull(response);
            Assert.NotNull(response.Model);
            Assert.Equal("Success", response.Model.Code);
            Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode);
            Assert.Equal(path, response.UrlPath);

            MockRestClient.Verify(m => m.DeleteAsync <DeleteListResponse>(It.Is <string>(a => a == path)), Times.Once);
        }
Exemplo n.º 2
0
        public async Task Should_Register_Device()
        {
            const string path    = "/api/users/registerDeviceToken";
            var          request = new RegisterDeviceTokenRequest
            {
                Email  = "*****@*****.**",
                UserId = "*****@*****.**"
            };

            MockRestClient.Setup(m => m.PostAsync <RegisterDeviceTokenResponse>(It.Is <string>(a => a == path), It.IsAny <RegisterDeviceTokenRequest>())).ReturnsAsync(new ApiResponse <RegisterDeviceTokenResponse>
            {
                UrlPath        = path,
                HttpStatusCode = HttpStatusCode.OK,
                Model          = new RegisterDeviceTokenResponse
                {
                    Code = "Success"
                }
            });

            ApiResponse <RegisterDeviceTokenResponse> response = await _userClient.RegisterDeviceTokenAsync(request).ConfigureAwait(false);

            Assert.NotNull(response);
            Assert.NotNull(response.Model);
            Assert.Equal("Success", response.Model.Code);
            Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode);
            Assert.Equal(path, response.UrlPath);

            MockRestClient.Verify(m => m.PostAsync <RegisterDeviceTokenResponse>(It.Is <string>(a => a == path), It.IsAny <RegisterDeviceTokenRequest>()), Times.Once);
        }
        public async Task Should_Update_Email()
        {
            string path = "/api/users/updateEmail";

            var request = new UpdateEmailRequest
            {
                CurrentEmail = "*****@*****.**",
                NewEmail     = "*****@*****.**"
            };

            MockRestClient.Setup(m => m.PostAsync <UpdateUserResponse>(It.Is <string>(a => a == path), It.IsAny <UpdateEmailRequest>())).ReturnsAsync(new ApiResponse <UpdateUserResponse>
            {
                UrlPath        = path,
                HttpStatusCode = HttpStatusCode.OK,
                Model          = new UpdateUserResponse
                {
                    Code = "Success"
                }
            });

            ApiResponse <UpdateUserResponse> response = await _userClient.UpdateEmailAsync(request).ConfigureAwait(false);

            Assert.NotNull(response);
            Assert.NotNull(response.Model);
            Assert.Equal("Success", response.Model.Code);
            Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode);
            Assert.Equal(path, response.UrlPath);

            MockRestClient.Verify(m => m.PostAsync <UpdateUserResponse>(It.Is <string>(a => a == path), It.IsAny <UpdateEmailRequest>()), Times.Once);
        }
        public async Task Should_Create_List()
        {
            const string path   = "/api/lists";
            const string name   = "test_list";
            const int    listId = 14;

            MockRestClient.Setup(m => m.PostAsync <CreateListResponse>(It.Is <string>(a => a == path), It.Is <string>(a => a == name))).ReturnsAsync(new ApiResponse <CreateListResponse>
            {
                UrlPath        = path,
                HttpStatusCode = HttpStatusCode.OK,
                Model          = new CreateListResponse
                {
                    ListId = listId
                }
            });

            ApiResponse <CreateListResponse> response = await _listClient.CreateAsync(name).ConfigureAwait(false);

            Assert.NotNull(response);
            Assert.NotNull(response.Model);
            Assert.Equal(listId, response.Model.ListId);
            Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode);
            Assert.Equal(path, response.UrlPath);

            MockRestClient.Verify(m => m.PostAsync <CreateListResponse>(It.Is <string>(a => a == path), It.Is <string>(a => a == name)), Times.Once);
        }
Exemplo n.º 5
0
        public async Task Should_Retrieve_User()
        {
            const string userId = "*****@*****.**";
            string       path   = $"/api/users/byUserId/{userId}";

            MockRestClient.Setup(m => m.GetAsync <RetrieveUserResponse>(It.Is <string>(a => a == path))).ReturnsAsync(new ApiResponse <RetrieveUserResponse>
            {
                UrlPath        = path,
                HttpStatusCode = HttpStatusCode.OK,
                Model          = new RetrieveUserResponse
                {
                    User = new UserModel
                    {
                        Email  = userId,
                        UserId = userId
                    }
                }
            });

            ApiResponse <RetrieveUserResponse> response = await _userClient.GetByUserIdAsync(userId).ConfigureAwait(false);

            Assert.NotNull(response);
            Assert.NotNull(response.Model);
            Assert.NotNull(response.Model.User);
            Assert.Equal(userId, response.Model.User.Email);
            Assert.Equal(userId, response.Model.User.UserId);
            Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode);
            Assert.Equal(path, response.UrlPath);

            MockRestClient.Verify(m => m.GetAsync <RetrieveUserResponse>(It.Is <string>(a => a == path)), Times.Once);
        }
        public async Task Should_Retrieve_Users()
        {
            const int    listId = 14;
            const string users  = "[email protected]\[email protected]";
            string       path   = $"/api/lists/getUsers?listId={listId}";

            MockRestClient.Setup(m => m.GetContentAsync(It.Is <string>(a => a == path))).ReturnsAsync(new ApiResponse
            {
                UrlPath        = path,
                HttpStatusCode = HttpStatusCode.OK,
                Content        = users
            });

            ApiResponse <GetUsersResponse> response = await _listClient.GetUsersAsync(listId).ConfigureAwait(false);

            Assert.NotNull(response);
            Assert.NotNull(response.Model);
            Assert.NotNull(response.Model.UserIds);
            Assert.True(response.Model.UserIds.Any());
            Assert.Equal(2, response.Model.UserIds.Count());
            Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode);
            Assert.Equal(path, response.UrlPath);

            MockRestClient.Verify(m => m.GetContentAsync(It.Is <string>(a => a == path)), Times.Once);
        }
Exemplo n.º 7
0
        public void ShouldReturnHealthStatus()
        {
            var expected = new HealthStatus()
            {
                IsElasticsearchServerAvailable = true,
                IsMailServerAvailable          = true,
                IsMessageQueueServerAvailable  = true,
            };
            var content      = JsonConvert.SerializeObject(expected);
            var restResponse = new RestResponse()
            {
                Content = content
            };

            MockRestClient.Setup(x => x.Execute(It.Is <RestRequest>(y => y.Resource == HealthStatusName)))
            .Returns(restResponse);
            MockJsonConvert.Setup(x => x.DeserializeObject <HealthStatus>(content))
            .Returns(expected);

            var actual = Subject.GetHealthStatus();

            Assert.That(actual, Is.EqualTo(expected));
            MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource == HealthStatusName)), Times.Once);
            MockJsonConvert.Verify(x => x.DeserializeObject <HealthStatus>(content), Times.Once);
        }
        public async Task Should_Delete_User()
        {
            const string email = "*****@*****.**";
            string       path  = $"/api/users/{email}";

            MockRestClient.Setup(m => m.DeleteAsync <DeleteUserResponse>(It.Is <string>(a => a == path))).ReturnsAsync(new ApiResponse <DeleteUserResponse>
            {
                UrlPath        = path,
                HttpStatusCode = HttpStatusCode.OK,
                Model          = new DeleteUserResponse
                {
                    Code = "Success"
                }
            });

            ApiResponse <DeleteUserResponse> response = await _userClient.DeleteByEmailAsync(email).ConfigureAwait(false);

            Assert.NotNull(response);
            Assert.NotNull(response.Model);
            Assert.Equal("Success", response.Model.Code);
            Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode);
            Assert.Equal(path, response.UrlPath);

            MockRestClient.Verify(m => m.DeleteAsync <DeleteUserResponse>(It.Is <string>(a => a == path)), Times.Once);
        }
Exemplo n.º 9
0
        public void It_should_not_call_unfuddle_to_update_ticket_for_states_it_is_in_or_past()
        {
            Card card2 = new Card()
            {
                Id = 2, ExternalSystemName = "Unfuddle", ExternalCardID = "2"
            };
            Card card4 = new Card()
            {
                Id = 4, ExternalSystemName = "Unfuddle", ExternalCardID = "4"
            };

            ((TestUnfuddle)TestItem).TestUpdateStateOfExternalItem(card2, _mapping.LaneToStatesMap[2], _mapping);
            ((TestUnfuddle)TestItem).TestUpdateStateOfExternalItem(card4, _mapping.LaneToStatesMap[2], _mapping);

            MockRestClient.Verify(
                x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("tickets/2") && y.Method == Method.GET)),
                Times.Exactly(3));
            MockRestClient.Verify(
                x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("tickets/2") && y.Method == Method.PUT)),
                Times.Exactly(2));

            MockRestClient.Verify(
                x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("tickets/4") && y.Method == Method.GET)),
                Times.Exactly(2));
            MockRestClient.Verify(
                x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("tickets/4") && y.Method == Method.PUT)),
                Times.Exactly(1));
        }
 public void It_should_call_leankit_to_create_card_if_existing_card_has_externalid_but_externalsystemname_does_not_match()
 {
     _mapping.Identity.LeanKit = 5;
     _mapping.Identity.Target  = "5";
     ((TestGitHubPulls)TestItem).Syncronize(_mapping);
     MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("/5/pulls") && y.Method == Method.GET)), Times.Exactly(1));
     MockLeanKitApi.Verify(x => x.AddCard(5, It.IsAny <Card>(), It.IsAny <string>()), Times.Exactly(1));
 }
 public void It_should_call_unfuddle_to_get_list_of_tickets()
 {
     _mapping.Identity.LeanKit = 1;
     _mapping.Identity.Target  = "1";
     ((TestUnfuddle)TestItem).Syncronize(_mapping);
     MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("projects/1/ticket_reports") && y.Method == Method.GET)), Times.Exactly(1));
     MockLeanKitApi.Verify(x => x.AddCard(1, It.IsAny <Card>(), It.IsAny <string>()), Times.Exactly(1));
 }
 public void It_should_call_leankit_multiple_times_to_create_card_if_there_are_multiple_tickets()
 {
     _mapping.Identity.LeanKit = 3;
     _mapping.Identity.Target  = "3";
     ((TestUnfuddle)TestItem).Syncronize(_mapping);
     MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("projects/3/ticket_reports") && y.Method == Method.GET)), Times.Exactly(1));
     MockLeanKitApi.Verify(x => x.AddCard(3, It.IsAny <Card>(), It.IsAny <string>()), Times.Exactly(3));
 }
 public void It_should_call_leankit_once_to_create_card_if_there_is_one_pullrequest()
 {
     _mapping.Identity.LeanKit = 2;
     _mapping.Identity.Target  = "2";
     ((TestGitHubPulls)TestItem).Syncronize(_mapping);
     MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("/2/pulls") && y.Method == Method.GET)), Times.Exactly(1));
     MockLeanKitApi.Verify(x => x.AddCard(2, It.IsAny <Card>(), It.IsAny <string>()), Times.Exactly(1));
 }
Exemplo n.º 14
0
 public void It_should_call_github_to_get_list_of_issues()
 {
     _mapping.Identity.LeanKit = 1;
     _mapping.Identity.Target  = "1";
     ((TestGitHubIssues)TestItem).Syncronize(_mapping);
     MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("/1/issues") && y.Method == Method.GET)), Times.Exactly(_mapping.QueryStates.Count));
     MockLeanKitApi.Verify(x => x.AddCard(1, It.IsAny <Card>(), It.IsAny <string>()), Times.Exactly(1));
 }
Exemplo n.º 15
0
 public void It_should_call_leankit_to_create_card_if_card_with_externalid_exists_but_different_externalsystemname()
 {
     _mapping.Identity.LeanKit = 5;
     _mapping.Identity.Target  = "5";
     ((TestGitHubIssues)TestItem).Syncronize(_mapping);
     MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("/5/issues") && y.Method == Method.GET)), Times.Exactly(_mapping.QueryStates.Count));
     MockLeanKitApi.Verify(x => x.AddCard(5, It.IsAny <Card>(), It.IsAny <string>()), Times.Exactly(1));
 }
Exemplo n.º 16
0
 public void It_should_call_leankit_multiple_times_to_create_card_if_there_are_multiple_issues()
 {
     _mapping.Identity.LeanKit = 3;
     _mapping.Identity.Target  = "3";
     ((TestGitHubIssues)TestItem).Syncronize(_mapping);
     MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("/3/issues") && y.Method == Method.GET)), Times.Exactly(_mapping.QueryStates.Count));
     MockLeanKitApi.Verify(x => x.AddCard(3, It.IsAny <Card>(), It.IsAny <string>()), Times.Exactly(3));
 }
 public void It_should_not_call_leankit_to_create_card_if_card_with_externalid_already_exists()
 {
     _mapping.Identity.LeanKit = 4;
     _mapping.Identity.Target  = "4";
     ((TestUnfuddle)TestItem).Syncronize(_mapping);
     MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("projects/4/ticket_reports") && y.Method == Method.GET)), Times.Exactly(1));
     MockLeanKitApi.Verify(x => x.AddCard(4, It.IsAny <Card>(), It.IsAny <string>()), Times.Never());
 }
 public void It_should_call_leankit_create_card_if_card_with_externalid_exists_but_has_different_externalsystemname()
 {
     _mapping.Identity.LeanKit = 5;
     _mapping.Identity.Target  = "5";
     ((TestUnfuddle)TestItem).Syncronize(_mapping);
     MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("projects/5/ticket_reports") && y.Method == Method.GET)), Times.Exactly(1));
     MockLeanKitApi.Verify(x => x.AddCard(5, It.IsAny <Card>(), It.IsAny <string>()), Times.Exactly(1));
 }
Exemplo n.º 19
0
        public void It_should_call_github_to_update_issue_if_issue_state_is_not_end_state()
        {
            Card card = new Card()
            {
                Id = 1, ExternalSystemName = "GitHub", ExternalCardID = "1|1"
            };

            ((TestGitHubIssues)TestItem).TestUpdateStateOfExternalItem(card, _mapping.LaneToStatesMap[2], _mapping);
            MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("issues/1") && y.Method == Method.GET)), Times.Exactly(1));
            MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("issues/1") && y.Method == Method.PATCH)), Times.Exactly(1));
        }
        public void It_should_not_call_github_to_update_pull_if_github_does_not_have_matching_issue()
        {
            Card card = new Card()
            {
                Id = 3, ExternalSystemName = "GitHub", ExternalCardID = "3|3"
            };

            ((TestGitHubPulls)TestItem).TestUpdateStateOfExternalItem(card, _mapping.LaneToStatesMap[2], _mapping);
            MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("pulls/3") && y.Method == Method.GET)), Times.Exactly(1));
            MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("pulls/3") && y.Method == Method.PATCH)), Times.Never());
        }
Exemplo n.º 21
0
        public void It_should_not_call_github_to_update_issue_if_externalsytemname_does_not_match()
        {
            Card card = new Card()
            {
                Id = 4, ExternalSystemName = "GitHubby", ExternalCardID = "4|4"
            };

            ((TestGitHubIssues)TestItem).TestUpdateStateOfExternalItem(card, _mapping.LaneToStatesMap[2], _mapping);
            MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("issues/4") && y.Method == Method.GET)), Times.Never());
            MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("issues/4") && y.Method == Method.PATCH)), Times.Never());
        }
        public void It_should_call_unfuddle_to_update_ticket_for_each_state_of_workflow()
        {
            Card card = new Card()
            {
                Id = 1, ExternalSystemName = "Unfuddle", ExternalCardID = "1"
            };

            ((TestUnfuddle)TestItem).TestUpdateStateOfExternalItem(card, _mapping.LaneToStatesMap[2], _mapping);
            MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("tickets/1") && y.Method == Method.GET)), Times.Exactly(4));
            MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("tickets/1") && y.Method == Method.PUT)), Times.Exactly(3));
        }
        public void It_should_not_call_unfuddle_to_update_ticket_if_externalsystemname_does_not_match()
        {
            Card card = new Card()
            {
                Id = 4, ExternalSystemName = "Unfuddlest", ExternalCardID = "4"
            };

            ((TestUnfuddle)TestItem).TestUpdateStateOfExternalItem(card, _mapping.LaneToStatesMap[2], _mapping);
            MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("tickets/4") && y.Method == Method.GET)), Times.Never());
            MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("tickets/4") && y.Method == Method.PUT)), Times.Never());
        }
        public void It_should_not_call_unfuddle_to_update_ticket_state_is_already_end_state()
        {
            Card card = new Card()
            {
                Id = 2, ExternalSystemName = "Unfuddle", ExternalCardID = "2"
            };

            ((TestUnfuddle)TestItem).TestUpdateStateOfExternalItem(card, _mapping.LaneToStatesMap[2], _mapping);
            MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("tickets/2") && y.Method == Method.GET)), Times.Exactly(1));
            MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("tickets/2") && y.Method == Method.PUT)), Times.Never());
        }
Exemplo n.º 25
0
        public void It_should_not_call_github_to_update_issue_if_no_identified_properties_change()
        {
            Card card = new Card();

            card.ExternalCardID     = "4|4";
            card.ExternalSystemName = "GitHub";
            card.Description        = "Issue 4";
            card.Title = "Issue 4";

            ((TestGitHubIssues)TestItem).TestCardUpdated(card, new List <string>(), _mapping);
            MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("issues/4") && y.Method == Method.GET)), Times.Exactly(1));
            MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("issues/4") && y.Method == Method.PATCH)), Times.Never());
        }
Exemplo n.º 26
0
        public void It_should_not_call_github_to_update_issue_if_externalsystemname_does_not_match()
        {
            Card card = new Card();

            card.ExternalCardID     = "5|5";
            card.ExternalSystemName = "GitHubber";
            card.Description        = "Issue 5";
            card.Title = "Issue 5";

            ((TestGitHubIssues)TestItem).TestCardUpdated(card, new List <string>(), _mapping);
            MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("issues/5") && y.Method == Method.GET)), Times.Never());
            MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("issues/5") && y.Method == Method.PATCH)), Times.Never());
        }
        public void It_should_not_call_unfuddle_to_update_ticket_externalsystemname_does_not_match()
        {
            Card card = new Card();

            card.ExternalCardID     = "5";
            card.ExternalSystemName = "Unfuddlest";
            card.Description        = "Ticket 5";
            card.Title = "Ticket 5";

            ((TestUnfuddle)TestItem).TestCardUpdated(card, new List <string>(), _mapping);
            MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("tickets/5") && y.Method == Method.GET)), Times.Never());
            MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("tickets/5") && y.Method == Method.PUT)), Times.Never());
        }
        public void It_should_not_call_unfuddle_to_update_ticket_if_no_identified_properties_change()
        {
            Card card = new Card();

            card.ExternalCardID     = "4";
            card.ExternalSystemName = "Unfuddle";
            card.Description        = "Ticket 4";
            card.Title = "Ticket 4";

            ((TestUnfuddle)TestItem).TestCardUpdated(card, new List <string>(), _mapping);
            MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("tickets/4") && y.Method == Method.GET)), Times.Exactly(1));
            MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("tickets/4") && y.Method == Method.PUT)), Times.Never());
        }
        public void It_should_work_properly_with_spaces_between_states()
        {
            _mapping.LaneToStatesMap[2] = new List <string> {
                "accpted > resolved > closed"
            };
            Card card = new Card()
            {
                Id = 3, ExternalSystemName = "Unfuddle", ExternalCardID = "3"
            };

            ((TestUnfuddle)TestItem).TestUpdateStateOfExternalItem(card, _mapping.LaneToStatesMap[2], _mapping);
            MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("tickets/3") && y.Method == Method.GET)), Times.Exactly(4));
            MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("tickets/3") && y.Method == Method.PUT)), Times.Exactly(3));
        }
Exemplo n.º 30
0
        public void ShouldQueryTheHealthStatusEndpointAndReturnStatusCodeWhenPinging()
        {
            var restResponse = new RestResponse()
            {
                StatusCode = HttpStatusCode.OK
            };

            MockRestClient.Setup(x => x.Execute(It.Is <RestRequest>(y => y.Resource == HealthStatusName))).Returns(restResponse);

            var actual = Subject.Ping();

            MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource == HealthStatusName)), Times.Once);
            Assert.That(actual, Is.TypeOf(typeof(HttpStatusCode)));
        }