public async Task <IActionResult> Delete(string id, CancellationToken ct) { var deleteExistingAccountCommand = new DeleteExistingAccountCommand(Guid.Parse(id)); await _commandProcessor.SendAsync(deleteExistingAccountCommand, false, ct); return(Ok()); }
public async Task When_deleting_a_record() { using (var uow = new AccountContext(_options)) { var id = Guid.NewGuid(); var account = new Account() { AccountId = id, Name = new Name { FirstName = "Jack", LastName = "Torrance" }, Addresses = new List <Address> { new Address("Overlook Hotel", AddressType.Billing, "CO", "80517") }, ContactDetails = new ContactDetails { Email = "*****@*****.**", TelephoneNumber = "666-6666" }, CardDetails = new CardDetails { CardNumber = "4104231121998973", CardSecurityCode = "517" }, }; var repository = new AccountRepositoryAsync(new EFUnitOfWork(uow)); await repository.AddAsync(account); //create delete command var deleteCommand = new DeleteExistingAccountCommand(id); //delete the account var handler = new DeleteExistingAccountCommandHandlerAsync(_options); await handler.HandleAsync(deleteCommand); //assert var savedAccount = await repository.GetAsync(id); Assert.IsNull(savedAccount); } }