public async Task Delete_Method_Removes_Specified_Order_From_Context() { var order = OrdersSeed.Orders.Value.FirstOrDefault(); Assert.NotNull(order); var orderNew = OrderNew.From(order); var orderId = OrderId.FromString(orderNew.OrderId); using (var scope = this._repoScopeCreate()) { await scope.Repository.Create(orderNew); } using (var scope = this._repoScopeCreate()) { await scope.Repository.Delete(orderId); } using (var scope = this._repoScopeCreate()) { var deleted = await scope.Repository.Get(orderId); Assert.Null(deleted); } }
public async Task Create_Method_Adds_Provided_Order_To_Context() { var order = OrdersSeed.Orders.Value.FirstOrDefault(); Assert.NotNull(order); using (var scope = this._repoScopeCreate()) { var orderNew = OrderNew.From(order); var created = await scope.Repository.Create(orderNew); Assert.NotNull(created); Assert.True(created.OrderId == orderNew.OrderId); Assert.True(created.CustomerName == orderNew.CustomerName); Assert.True(created.PostCode == orderNew.PostCode); Assert.True(created.HouseNumber == orderNew.HouseNumber); Assert.True(created.Price == orderNew.Price); } using (var scope = this._repoScopeCreate()) { var saved = await scope.Repository.Get(OrderId.FromString(order.OrderId)); Assert.NotNull(saved); } }
public async Task Delete_Method_Throws_If_Order_With_Specified_OrderId_Does_Not_Exist() { using (var scope = this._repoScopeCreate()) { var orderId = OrderId.FromString("SAL246363"); var ex = await Assert.ThrowsAsync <OrderDoesNotExistException>(() => scope.Repository.Delete(orderId)); Assert.True(ex.OrderId == orderId.Value); } }
public async Task Delete_Method_Calls_Delete_Method_Of_IOrdersRepository_In_Order_To_Execute_A_Call() { var order = OrdersSeed.Orders.Value.FirstOrDefault(); Assert.NotNull(order); var orderId = OrderId.FromString(order.OrderId); await Service.Delete(orderId); this.Repository.Verify(repository => repository.Delete(orderId), Times.Once); this.Repository.VerifyNoOtherCalls(); }
public async Task <IActionResult> GetIssues([FromRoute] OrderIdQuery query, [FromQuery] Paging paging) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var orderId = OrderId.FromString(query.OrderId); var results = await this._jiraSearchService.SearchIssuesByOrderId(orderId, paging); return(Ok(results)); }
public async Task GetIssues_Returns_Empty_List_If_There_Are_No_Issue_With_Specified_OrderId() { var orderId = OrderId.FromString("TST2312312").Value; var uri = $"{Routes.IssuesByOrderId(orderId)}"; var response = await this.Client.GetAsync(uri); Assert.True(response.IsSuccessStatusCode); var result = await response.GetFromBody <PagingResult <JiraShortIssue> >(); Assert.NotNull(result); Assert.True(result.Items.Count == 0); }
public async Task SearchIssuesByOrderId_Throws_Jira_Exception_When_HttpContent_Contains_Invalid_Json() { var issueRecord = JiraIssuesSeed.Records.Value.FirstOrDefault(); Assert.NotNull(issueRecord); var client = new HttpClient(new InvalidJsonHandler()) { BaseAddress = Settings.RestApiUri }; var service = new JiraSearchIssuesService(client); var orderId = OrderId.FromString(issueRecord.OrderId); await Assert.ThrowsAsync <JiraException>(() => service.SearchIssuesByOrderId(orderId)); }
public async Task SearchIssuesByOrderId_Throws_Jira_Exception_When_HttpResponse_Has_Non_OK_Status_Code() { var issueRecord = JiraIssuesSeed.Records.Value.FirstOrDefault(); Assert.NotNull(issueRecord); var client = new HttpClient(new ErrorStatusCodeHandler()) { BaseAddress = Settings.RestApiUri }; var service = new JiraSearchIssuesService(client); var orderId = OrderId.FromString(issueRecord.OrderId); await Assert.ThrowsAsync <JiraException>(() => service.SearchIssuesByOrderId(orderId)); }
public async Task Update_Method_Throws_If_Order_With_Specified_OrderId_Does_Not_Exist() { var order = OrdersSeed.Orders.Value.FirstOrDefault(); Assert.NotNull(order); var orderId = OrderId.FromString(order.OrderId); var orderUpdate = OrderUpdate.From(order); using (var scope = this._repoScopeCreate()) { var ex = await Assert.ThrowsAsync <OrderDoesNotExistException>(() => scope.Repository.Update(orderId, orderUpdate)); Assert.True(ex.OrderId == orderId.Value); } }
public async Task SearchIssuesByOrderId_Returns_Paginated_List_Jira_Issue_When_Executed_Successfully() { var issueRecord = JiraIssuesSeed.Records.Value.FirstOrDefault(); Assert.NotNull(issueRecord); var client = new HttpClient(new JiraSearchIssuesHandler()) { BaseAddress = Settings.RestApiUri }; var service = new JiraSearchIssuesService(client); var orderId = OrderId.FromString(issueRecord.OrderId); var result = await service.SearchIssuesByOrderId(orderId); Assert.NotNull(result); Assert.True(result.Items.Count == issueRecord.Issues.Count); }
public async Task Update_Method_Updates_Specified_Order_And_Returns_Updated_Order() { var order = OrdersSeed.Orders.Value.FirstOrDefault(); Assert.NotNull(order); var orderNew = OrderNew.From(order); var orderId = OrderId.FromString(orderNew.OrderId); using (var scope = this._repoScopeCreate()) { await scope.Repository.Create(orderNew); } using (var scope = this._repoScopeCreate()) { var orderUpdate = OrderUpdate.From(order, update => update.CustomerName = "New Top Customer"); var updated = await scope.Repository.Update(orderId, orderUpdate); Assert.NotNull(updated); Assert.True(updated.OrderId == orderId.Value); Assert.True(updated.CustomerName == orderUpdate.CustomerName); } }
public async Task Update_Method_Throws_If_No_OrderUpdate_Specified() { await Assert.ThrowsAsync <ArgumentNullException>(() => Service.Update(orderId: OrderId.FromString("SAL2312412"), order: null)); }
public async Task Update_Method_Throws_If_No_OrderUpdate_Provided() { using (var scope = this._repoScopeCreate()) { await Assert.ThrowsAsync <ArgumentNullException>(() => scope.Repository.Update(OrderId.FromString("SAL3414214"), null)); } }