public void Get_Called_CallsBuildUriWithFieldId() { // Given _client.Setup(b => b.BuildUri(It.IsAny<string>(), It.Is<string>(s => s.Contains("321")))).Returns(new Uri("http://search")); var ticketResource = new TicketResource(_client.Object); // When ticketResource.Get(321); // Then _client.Verify(c => c.BuildUri(It.Is<string>(s => s.Contains("321")), "")); }
public void Put_Called_BuildsUri() { // Given var request = new TicketRequest { Item = new Ticket { Subject = "blah blah", Id = 123 } }; var ticketResource = new TicketResource(_client.Object); // When ticketResource.Put(request); // Then _client.Setup(b => b.BuildUri(It.IsAny<string>(), "")); }
public void GetAll_Called_CallsBuildUriWithFieldId() { // Given _client.Setup(b => b.BuildUri(It.IsAny<string>(), It.IsAny<string>())).Returns(new Uri("http://search")); var ticketResource = new TicketResource(_client.Object); // When ticketResource.GetAll(new List<long> { 321, 456, 789 }); // Then _client.Verify(c => c.BuildUri(It.Is<string>(s => s.Contains("/show_many")), It.IsAny<string>())); }
public ZendeskClient(Uri baseUri, ZendeskDefaultConfiguration configuration, ISerializer serializer = null, IHttpChannel httpChannel = null, ILogAdapter logger = null) :base(baseUri, configuration, serializer, httpChannel, logger) { Tickets = new TicketResource(this); TicketComments = new TicketCommentResource(this); Organizations = new OrganizationResource(this); Search = new SearchResource(this); Groups = new GroupsResource(this); AssignableGroups = new AssignableGroupResource(this); Users = new UserResource(this); UserIdentities = new UserIdentityResource(this); OrganizationMemberships = new OrganizationMembershipResource(this); }
public void GetAll_Called_ReturnsTicketResponse() { // Given var response = new TicketListResponse { Results = new List<Ticket> { new Ticket { Id = 1 } } }; _client.Setup(b => b.Get<TicketListResponse>(It.IsAny<Uri>())).Returns(response); var ticketResource = new TicketResource(_client.Object); // When var result = ticketResource.GetAll(new List<long> { 321, 456, 789 }); // Then Assert.That(result, Is.EqualTo(response)); }
public void Get_Called_ReturnsTicketResponse() { // Given var response = new TicketResponse { Item = new Ticket { Id = 1 }}; _client.Setup(b => b.Get<TicketResponse>(It.IsAny<Uri>())).Returns(response); var ticketResource = new TicketResource(_client.Object); // When var result = ticketResource.Get(321); // Then Assert.That(result, Is.EqualTo(response)); }
public void Get_Called_ReturnsTicketResponse() { // Given var response = new TicketResponse { Item = new Ticket { Id = 1 } }; _client.Setup(b => b.Get <TicketResponse>(It.IsAny <Uri>())).Returns(response); var ticketResource = new TicketResource(_client.Object); // When var result = ticketResource.Get(321); // Then Assert.That(result, Is.EqualTo(response)); }
public void Delete_Called_CallsDeleteOnClient() { // Given var response = new TicketResponse { Item = new Ticket { Id = 1 } }; _client.Setup(b => b.Get <TicketResponse>(It.IsAny <Uri>())).Returns(response); var ticketResource = new TicketResource(_client.Object); // When ticketResource.Delete(321); // Then _client.Verify(c => c.Delete(It.IsAny <Uri>())); }
public async Task <IActionResult> CreateTicket([FromBody] TicketResource ticketResource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var ticket = mapper.Map <TicketResource, Ticket>(ticketResource); ticket.CreationDate = DateTime.Now; repository.Add(ticket); await unitOfWork.CompleteAsync(); ticket = await repository.Get(ticket.Id); var result = mapper.Map <Ticket, TicketResource>(ticket); return(Ok(result)); }
public async void GetAsync_Called_ReturnsTicketResponse() { // Given var client = new Mock <IRestClient>(); var response = new TicketResponse { Item = new Ticket { Id = 1 } }; client.Setup(b => b.GetAsync <TicketResponse>(It.IsAny <Uri>(), It.IsAny <string>(), It.IsAny <string>())).Returns(TaskHelper.CreateTaskFromResult(response)); var ticketResource = new TicketResource(client.Object); // When var result = await ticketResource.GetAsync(321); // Then Assert.Equal(result, response); }
public async void DeleteAsync_Called_CallsDeleteOnClient() { // Given var client = new Mock <IRestClient>(); var response = new TicketResponse { Item = new Ticket { Id = 1 } }; client.Setup(b => b.GetAsync <TicketResponse>(It.IsAny <Uri>(), It.IsAny <string>(), It.IsAny <string>())).Returns(TaskHelper.CreateTaskFromResult(response)); var ticketResource = new TicketResource(client.Object); // When await ticketResource.DeleteAsync(321); // Then client.Verify(c => c.DeleteAsync <object>(It.IsAny <Uri>(), It.IsAny <object>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())); }
public ZendeskClient(Uri baseUri, ZendeskDefaultConfiguration configuration, ISerializer serializer = null, IHttpChannel httpChannel = null, ILogAdapter logger = null) : base(baseUri, configuration, serializer, httpChannel, logger) { Tickets = new TicketResource(this); TicketComments = new TicketCommentResource(this); RequestComments = new RequestCommentResource(this); Organizations = new OrganizationResource(this); Search = new SearchResource(this); Groups = new GroupsResource(this); AssignableGroups = new AssignableGroupResource(this); Users = new UserResource(this); UserIdentities = new UserIdentityResource(this); Upload = new UploadResource(this); TicketFields = new TicketFieldResource(this); TicketForms = new TicketFormResource(this); OrganizationMemberships = new OrganizationMembershipResource(this); Request = new RequestResource(this); SatisfactionRating = new SatisfactionRatingResource(this); }
public void Put_TicketHasNoId_ThrowsException() { // Given var response = new TicketResponse { Item = new Ticket { Subject = "blah blah" } }; var request = new TicketRequest { Item = new Ticket { Subject = "blah blah" } }; _client.Setup(b => b.Put <TicketResponse>(It.IsAny <Uri>(), request, "application/json")).Returns(response); var ticketResource = new TicketResource(_client.Object); // When, Then Assert.Throws <ArgumentException>(() => ticketResource.Put(request)); }
public void PutAsync_TicketHasNoId_ThrowsException() { // Given var response = new TicketResponse { Item = new Ticket { Subject = "blah blah" } }; var request = new TicketRequest { Item = new Ticket { Subject = "blah blah" } }; _client.Setup(b => b.PutAsync <TicketResponse>(It.IsAny <Uri>(), request, "application/json")).Returns(TaskHelper.CreateTaskFromResult(response)); var ticketResource = new TicketResource(_client.Object); // When, Then Assert.Throws <ArgumentException>(async() => await ticketResource.PutAsync(request)); }
public async void GetAllAsync_Called_ReturnsTicketResponse() { // Given var response = new TicketListResponse { Results = new List <Ticket> { new Ticket { Id = 1 } } }; _client.Setup(b => b.GetAsync <TicketListResponse>(It.IsAny <Uri>())).Returns(TaskHelper.CreateTaskFromResult(response)); var ticketResource = new TicketResource(_client.Object); // When var result = await ticketResource.GetAllAsync(new List <long> { 321, 456, 789 }); // Then Assert.That(result, Is.EqualTo(response)); }
public void GetAll_Called_ReturnsTicketResponse() { // Given var response = new TicketListResponse { Results = new List <Ticket> { new Ticket { Id = 1 } } }; _client.Setup(b => b.Get <TicketListResponse>(It.IsAny <Uri>())).Returns(response); var ticketResource = new TicketResource(_client.Object); // When var result = ticketResource.GetAll(new List <long> { 321, 456, 789 }); // Then Assert.That(result, Is.EqualTo(response)); }
public async void PostAsync_CalledWithTicket_ReturnsTicketReponse() { // Given var response = new TicketResponse { Item = new Ticket { Subject = "blah blah" } }; var request = new TicketRequest { Item = new Ticket { Subject = "blah blah" } }; _client.Setup(b => b.PostAsync <TicketResponse>(It.IsAny <Uri>(), request, "application/json")).Returns(TaskHelper.CreateTaskFromResult(response)); var ticketResource = new TicketResource(_client.Object); // When var result = await ticketResource.PostAsync(request); // Then Assert.That(result, Is.EqualTo(response)); }
public void Put_CalledWithTicket_ReturnsTicketReponse() { // Given var response = new TicketResponse { Item = new Ticket { Subject = "blah blah" } }; var request = new TicketRequest { Item = new Ticket { Subject = "blah blah", Id = 123 } }; _client.Setup(b => b.Put <TicketResponse>(It.IsAny <Uri>(), request, "application/json")).Returns(response); var ticketResource = new TicketResource(_client.Object); // When var result = ticketResource.Put(request); // Then Assert.That(result, Is.EqualTo(response)); }
public async void PutAsync_CalledWithTicket_ReturnsTicketReponse() { // Given var client = new Mock <IRestClient>(); var response = new TicketResponse { Item = new Ticket { Subject = "blah blah" } }; var request = new TicketRequest { Item = new Ticket { Subject = "blah blah", Id = 123 } }; client.Setup(b => b.PutAsync <TicketResponse>(It.IsAny <Uri>(), request, "application/json", It.IsAny <string>(), It.IsAny <string>())).Returns(TaskHelper.CreateTaskFromResult(response)); var ticketResource = new TicketResource(client.Object); // When var result = await ticketResource.PutAsync(request); // Then Assert.Equal(result, response); }
public void Put_TicketHasNoId_ThrowsException() { // Given var response = new TicketResponse { Item = new Ticket { Subject = "blah blah" } }; var request = new TicketRequest { Item = new Ticket { Subject = "blah blah" } }; _client.Setup(b => b.Put<TicketResponse>(It.IsAny<Uri>(), request, "application/json")).Returns(response); var ticketResource = new TicketResource(_client.Object); // When, Then Assert.Throws<ArgumentException>(() => ticketResource.Put(request)); }
public void Delete_Called_CallsDeleteOnClient() { // Given var response = new TicketResponse { Item = new Ticket { Id = 1 } }; _client.Setup(b => b.Get<TicketResponse>(It.IsAny<Uri>())).Returns(response); var ticketResource = new TicketResource(_client.Object); // When ticketResource.Delete(321); // Then _client.Verify(c => c.Delete(It.IsAny<Uri>())); }
public void Put_CalledWithTicket_ReturnsTicketReponse() { // Given var response = new TicketResponse { Item = new Ticket { Subject = "blah blah" } }; var request = new TicketRequest { Item = new Ticket { Subject = "blah blah", Id = 123 } }; _client.Setup(b => b.Put<TicketResponse>(It.IsAny<Uri>(), request, "application/json")).Returns(response); var ticketResource = new TicketResource(_client.Object); // When var result = ticketResource.Put(request); // Then Assert.That(result, Is.EqualTo(response)); }