public async Task CanRemove(SliceFixture fixture) { // Arrange var createCommand = new Create.Command { Name = "Some role" }; await fixture.SendAsync(createCommand); var addedRole = await fixture.ExecuteDbContextAsync(db => db .Roles .FirstOrDefaultAsync(r => r.Name == createCommand.Name)); var removeCommand = new Remove.Command { RoleId = addedRole.Id }; // Act await fixture.SendAsync(removeCommand); // Assert var roleAfterDeletion = await fixture.ExecuteDbContextAsync(db => db .Roles .FirstOrDefaultAsync(r => r.Id == removeCommand.RoleId)); roleAfterDeletion.ShouldBeNull(); }
public async Task CanRemove(SliceFixture fixture) { // Arrange var category = new Category { Name = "Category" }; await fixture.InsertAsync(category); // Act var removeCommand = new Remove.Command { Id = category.Id, Name = category.Name, ProductsInCategoryCount = 0 }; await fixture.SendAsync(removeCommand); // Assert var areThereCategoriesInTheDb = await fixture .ExecuteDbContextAsync(db => db .Categories .AnyAsync()); areThereCategoriesInTheDb.ShouldBeFalse(); }
public async Task SuccessfullRemoveSetsSuccessMessage(SliceFixture fixture) { // Arrange var category = AddCategoryToDatabase(fixture); var controller = fixture.GetController <CategoryController>(); // Act var removeCommand = new Remove.Command { Id = category.Id }; await controller.Remove(removeCommand); // Assert controller.TempData .ShouldContainSuccessMessage(SuccessMessages.SuccessfullyRemovedCategory(removeCommand.Name)); }
public async Task SuccessfullRemoveSetsSuccessMessage(SliceFixture fixture) { // Arrange var product = AddProductToDatabase(fixture); var controller = fixture.GetController <ProductController>(); // Act var removeCommand = new Remove.Command { ProductId = product.Id }; await controller.Remove(removeCommand); // Assert controller.TempData .ShouldContainSuccessMessage(SuccessMessages.SuccessfullyRemovedProduct(removeCommand.ProductId)); }
public async Task SuccessfullRemovalSetsSuccessMessage(SliceFixture fixture) { // Arrange var controller = fixture.GetController <RoleController>(); var role = AddRoleToDb(fixture); // Act var removeCommand = new Remove.Command { RoleId = role.Id }; await controller.Remove(removeCommand); // Assert controller.TempData .ShouldContainSuccessMessage(SuccessMessages.SuccessfullyDeletedRole(role.Id)); }
public async Task CanRemoveProduct(SliceFixture fixture) { // Arrange var category = new Category { Name = "Category" }; await fixture.InsertAsync(category); var createCommand = new Create.Command { Name = "Product", Description = "Description", Price = 12.00m, Category = category, }; await fixture.SendAsync(createCommand); var product = await fixture .ExecuteDbContextAsync(db => db .Products .FirstOrDefaultAsync(p => p.Name == createCommand.Name)); // Act var command = new Remove.Command() { ProductId = product.Id }; await fixture.SendAsync(command); var productInDb = await fixture .ExecuteDbContextAsync(db => db .Products .FirstOrDefaultAsync(p => p.Id == product.Id)); productInDb.ShouldBeNull(); }
public async Task <IActionResult> Remove([FromRoute] Remove.Command command) { await _mediator.Send(command); return(NoContent()); }
[Authorize(Policy = "DropTicketReq")] //Requirements for dropping ticket: Either the manager OR assignee public async Task <ActionResult <Unit> > Remove(Guid id, Remove.Command command) { command.Id = id; return(await _mediator.Send(command)); }