public void Delete() { Random random = new Random(); Guid id = random.NextGuid(); DHCPv6Listener listener = new DHCPv6Listener(); listener.Load(new DomainEvent[] { new DHCPv6ListenerCreatedEvent { Id = id, Address = random.GetIPv6Address().ToString(), } }); Assert.False(listener.IsDeleted); listener.Delete(); Assert.True(listener.IsDeleted); var @event = GetFirstEvent <DHCPListenerDeletedEvent>(listener); Assert.Equal(id, @event.Id); }
public async Task <Boolean> Handle(DeleteDHCPv6InterfaceListenerCommand request, CancellationToken cancellationToken) { _logger.LogDebug("Handle started"); if (await _storageEngine.CheckIfAggrerootExists <DHCPv6Listener>(request.Id) == false) { return(false); } DHCPv6Listener listener = await _storageEngine.GetAggregateRoot <DHCPv6Listener>(request.Id); listener.Delete(); if (await _storageEngine.Save(listener) == false) { return(false); } _interfaceEngine.CloseListener(listener); return(true); }