Esempio n. 1
0
    public async Task AddBlackhole(string s)
    {
        var prefix = Networking.Models.AddressPrefix.Parse(s);

        // see if already exists
        var exists = await _sut.GetBlackholesAsync().AnyAsync(b => b == prefix);

        // if so, remove it
        if (exists)
        {
            await _sut.DeleteBlackholeAsync(prefix);
        }

        // Assert it was removed
        Assert.False(await _sut.GetBlackholesAsync().AnyAsync(b => b == prefix));

        // add it
        await _sut.AddBlackholeAsync(prefix);

        await Task.Delay(millisecondsDelay : 500);

        var a = await _sut.GetBlackholesAsync().ToListAsync();

        // Assert it was added
        Assert.True(await _sut.GetBlackholesAsync().AnyAsync(b => b == prefix));

        // delete it
        await _sut.DeleteBlackholeAsync(prefix);

        // Assert it was deleted
        Assert.False(await _sut.GetBlackholesAsync().AnyAsync(b => b == prefix));

        // if it existed previously, put it back
        if (exists)
        {
            await _sut.AddBlackholeAsync(prefix);
        }
    }