Skip to content
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.

Commit

Permalink
Development - Add Functional Tests for API + Removed Unused Endpoints (
Browse files Browse the repository at this point in the history
…#95)

* Refactoring.

* #93 - Functional tests for products controller.

* #93 - Functional tests for products controller (GetById)

* #93 - Functional tests for products controller (Create)

* #93 - Functional tests for products controller (Update)

* Remove misleading comments.

* #93 - Functional tests for products controller (Delete)

* #93 - Functional tests for customers controller

* #93 - Functional tests for categories controller

* Refactoring - removed unused employee manager code.
  • Loading branch information
jasongt committed Mar 31, 2019
1 parent c029d6b commit 8618a44
Show file tree
Hide file tree
Showing 41 changed files with 634 additions and 476 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,11 @@ public class CreateCustomerCommand : IRequest
public class Handler : IRequestHandler<CreateCustomerCommand, Unit>
{
private readonly NorthwindDbContext _context;
private readonly INotificationService _notificationService;
private readonly IMediator _mediator;

public Handler(
NorthwindDbContext context,
INotificationService notificationService,
IMediator mediator)
public Handler(NorthwindDbContext context, IMediator mediator)
{
_context = context;
_notificationService = notificationService;
_mediator = mediator;
}

Expand All @@ -67,7 +62,7 @@ public async Task<Unit> Handle(CreateCustomerCommand request, CancellationToken

await _context.SaveChangesAsync(cancellationToken);

await _mediator.Publish(new CustomerCreated { CustomerId = entity.CustomerId });
await _mediator.Publish(new CustomerCreated { CustomerId = entity.CustomerId }, cancellationToken);

return Unit.Value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public async Task<Unit> Handle(DeleteCustomerCommand request, CancellationToken
var hasOrders = _context.Orders.Any(o => o.CustomerId == entity.CustomerId);
if (hasOrders)
{
// TODO: Add functional test for this behaviour.
throw new DeleteFailureException(nameof(Customer), request.Id, "There are existing orders associated with this customer.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public UpdateCustomerCommandHandler(NorthwindDbContext context)
public async Task<Unit> Handle(UpdateCustomerCommand request, CancellationToken cancellationToken)
{
var entity = await _context.Customers
.SingleAsync(c => c.CustomerId == request.Id, cancellationToken);
.SingleOrDefaultAsync(c => c.CustomerId == request.Id, cancellationToken);

if (entity == null)
{
Expand Down

This file was deleted.

This file was deleted.

14 changes: 0 additions & 14 deletions Northwind.Application/Employees/Models/EmployeeManagerModel.cs

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion Northwind.Application/Northwind.Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dapper" Version="1.60.1" />
<PackageReference Include="FluentValidation" Version="8.1.3" />
<PackageReference Include="MediatR" Version="6.0.0" />
<PackageReference Include="AutoMapper" Version="8.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public async Task<Unit> Handle(DeleteProductCommand request, CancellationToken c
var hasOrders = _context.OrderDetails.Any(od => od.ProductId == entity.ProductId);
if (hasOrders)
{
// TODO: Add functional test for this behaviour.
throw new DeleteFailureException(nameof(Product), request.Id, "There are existing orders associated with this product.");
}

Expand Down
Loading

0 comments on commit 8618a44

Please sign in to comment.