Ejemplo n.º 1
0
        public async Task <ActionResult> Delete(int id)
        {
            var cmd = new DeleteApiKey(id);
            await _commandBus.ExecuteAsync(cmd);

            return(RedirectToAction("Deleted"));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Delete(int id)
        {
            var cmd = new DeleteApiKey(id);
            await _messageBus.SendAsync(this.ClaimsUser(), cmd);

            return(RedirectToAction("Deleted"));
        }
        public async Task should_be_able_to_delete_key_by_ApiKey()
        {
            var cmd = new DeleteApiKey(_existingEntity.GeneratedKey);

            var sut = new DeleteApiKeyHandler(_uow);
            await sut.ExecuteAsync(cmd);

            var count = _uow.ExecuteScalar("SELECT cast(count(*) as int) FROM ApiKeys WHERE Id = @id", new { id = _existingEntity.Id });

            count.Should().Be(0);
        }
Ejemplo n.º 4
0
        public async Task Should_be_able_to_delete_key_by_id()
        {
            var cmd     = new DeleteApiKey(_existingEntity.Id);
            var context = Substitute.For <IMessageContext>();

            using (var uow = CreateUnitOfWork())
            {
                var sut = new DeleteApiKeyHandler(uow);
                await sut.HandleAsync(context, cmd);

                var count = uow.ExecuteScalar("SELECT cast(count(*) as int) FROM ApiKeys WHERE Id = @id",
                                              new { id = _existingEntity.Id });
                count.Should().Be(0);
                uow.SaveChanges();
            }
        }