mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2024-10-02 20:13:13 +00:00
188d957057
- added config/aliases.yml which contains mapping of command method names to command names + aliases - first alias is treated as a command name, while the following ones are treated as aliases - command strings' keys aren now using command name as keys (first entry in config/aliases.yml), and not command method name - command strings are now .yml files in config/strings/commands/commands.LANG.yml (actual localization is not yet implemented, but is trivial to add) - removed obsolete command strings and aliases for commands which no longer exist and added tests to check for them - added tests which will make sure commands.yml and aliases.yml files have entries for all commands - some commands are slightly renamed to be more consistent with other commands in their group/bot - removed (commented out) leftover yttrackmodule which had no commands
79 lines
No EOL
2.1 KiB
C#
79 lines
No EOL
2.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using NadekoBot.Core.Services;
|
|
using NUnit.Framework;
|
|
|
|
namespace Nadeko.Tests
|
|
{
|
|
public class GroupGreetTests
|
|
{
|
|
private GreetGrouper<int> _grouper;
|
|
|
|
[SetUp]
|
|
public void Setup()
|
|
{
|
|
_grouper = new GreetGrouper<int>();
|
|
}
|
|
|
|
[Test]
|
|
public void CreateTest()
|
|
{
|
|
var created = _grouper.CreateOrAdd(0, 5);
|
|
|
|
Assert.True(created);
|
|
}
|
|
|
|
[Test]
|
|
public void CreateClearTest()
|
|
{
|
|
_grouper.CreateOrAdd(0, 5);
|
|
_grouper.ClearGroup(0, 5, out var items);
|
|
|
|
Assert.AreEqual(0, items.Count());
|
|
}
|
|
|
|
[Test]
|
|
public void NotCreatedTest()
|
|
{
|
|
_grouper.CreateOrAdd(0, 5);
|
|
var created = _grouper.CreateOrAdd(0, 4);
|
|
|
|
Assert.False(created);
|
|
}
|
|
|
|
[Test]
|
|
public void ClearAddedTest()
|
|
{
|
|
_grouper.CreateOrAdd(0, 5);
|
|
_grouper.CreateOrAdd(0, 4);
|
|
_grouper.ClearGroup(0, 5, out var items);
|
|
|
|
var list = items.ToList();
|
|
|
|
Assert.AreEqual(1, list.Count, $"Count was {list.Count}");
|
|
Assert.AreEqual(4, list[0]);
|
|
}
|
|
|
|
[Test]
|
|
public async Task ClearManyTest()
|
|
{
|
|
_grouper.CreateOrAdd(0, 5);
|
|
|
|
// add 15 items
|
|
await Task.WhenAll(Enumerable.Range(10, 15)
|
|
.Select(x => Task.Run(() => _grouper.CreateOrAdd(0, x))));
|
|
|
|
// get 5 at most
|
|
_grouper.ClearGroup(0, 5, out var items);
|
|
var list = items.ToList();
|
|
Assert.AreEqual(5, list.Count, $"Count was {list.Count}");
|
|
|
|
// try to get 15, but there should be 10 left
|
|
_grouper.ClearGroup(0, 15, out items);
|
|
list = items.ToList();
|
|
Assert.AreEqual(10, list.Count, $"Count was {list.Count}");
|
|
}
|
|
}
|
|
} |