public void CanAddModule()
        {
            var config      = new MariCommandsOptions();
            var moduleCache = new ModuleCache(config);

            var commandMock1 = new Mock <ICommand>();

            commandMock1.SetupGet(a => a.Aliases).Returns(new List <string>
            {
                "testCmdAlias",
            });

            var command1 = commandMock1.Object;

            var commands = new List <ICommand>
            {
                command1,
            };

            var moduleMock = new Mock <IModule>();

            moduleMock.SetupGet(a => a.Commands).Returns(commands);
            moduleMock.SetupGet(a => a.Aliases).Returns(new List <string>
            {
                "testModuleAlias"
            });
            moduleMock.SetupGet(a => a.Submodules).Returns(new List <IModule>());

            var module = moduleMock.Object;

            commandMock1.SetupGet(a => a.Module).Returns(module);

            moduleCache.AddModule(module);
        }
        public async Task CalculateCorrectRemainingInput(string alias, string input)
        {
            var config     = new MariCommandsOptions();
            var comparison = StringComparison.Ordinal;

            config.Comparison = comparison;

            var moduleCache = new ModuleCache(config);

            var commandMock1 = new Mock <ICommand>();

            commandMock1.SetupGet(a => a.Aliases).Returns(new List <string>
            {
                alias,
            });

            var command1 = commandMock1.Object;

            var commands = new List <ICommand>
            {
                command1,
            };

            var moduleMock = new Mock <IModule>();

            moduleMock.SetupGet(a => a.Commands).Returns(commands);
            moduleMock.SetupGet(a => a.Aliases).Returns(new List <string>());
            moduleMock.SetupGet(a => a.Submodules).Returns(new List <IModule>());

            var module = moduleMock.Object;

            commandMock1.SetupGet(a => a.Module).Returns(module);

            moduleCache.AddModule(module);

            var matches = await moduleCache.SearchCommandsAsync(input);

            Assert.NotNull(matches);
            Assert.NotEmpty(matches);

            var remainingInput = string.Join(config.Separator,
                                             input
                                             .Split(config.Separator)
                                             .Where(a => !a.Equals(alias, comparison))
                                             .ToList());

            var match = matches.FirstOrDefault();

            Assert.True(remainingInput.Equals(match.RemainingInput, comparison));
        }
        public async Task CanFindCommandModuleWithIgnoreCaseAndOnceAlias(string moduleAlias, string alias, string input)
        {
            var config = new MariCommandsOptions();

            var comparison = StringComparison.InvariantCultureIgnoreCase;

            config.Comparison = comparison;

            var moduleCache = new ModuleCache(config);

            var commandMock1 = new Mock <ICommand>();

            commandMock1.SetupGet(a => a.Aliases).Returns(new List <string>
            {
                alias,
            });

            var command1 = commandMock1.Object;

            var commands = new List <ICommand>
            {
                command1,
            };

            var moduleMock = new Mock <IModule>();

            moduleMock.SetupGet(a => a.Commands).Returns(commands);
            moduleMock.SetupGet(a => a.Aliases).Returns(new List <string>
            {
                moduleAlias,
            });
            moduleMock.SetupGet(a => a.Submodules).Returns(new List <IModule>());

            var module = moduleMock.Object;

            commandMock1.SetupGet(a => a.Module).Returns(module);

            moduleCache.AddModule(module);

            var matches = await moduleCache.SearchCommandsAsync(input);

            Assert.NotNull(matches);
            Assert.NotEmpty(matches);
            Assert.True(input.Equals(matches.FirstOrDefault().Alias, comparison));
        }
        public void CanGetAllModules()
        {
            var config      = new MariCommandsOptions();
            var moduleCache = new ModuleCache(config);

            var commandMock1 = new Mock <ICommand>();

            commandMock1.SetupGet(a => a.Aliases).Returns(new List <string>
            {
                "testCmdAlias",
            });

            var command1 = commandMock1.Object;

            var commands = new List <ICommand>
            {
                command1,
            };

            var moduleMock = new Mock <IModule>();

            moduleMock.SetupGet(a => a.Commands).Returns(commands);
            moduleMock.SetupGet(a => a.Aliases).Returns(new List <string>
            {
                "testModuleAlias"
            });
            moduleMock.SetupGet(a => a.Submodules).Returns(new List <IModule>());

            var module = moduleMock.Object;

            commandMock1.SetupGet(a => a.Module).Returns(module);

            moduleCache.AddModule(module);

            var modules = moduleCache.GetAllModules();

            Assert.NotNull(modules);
            Assert.NotEmpty(modules);
            Assert.Equal(module, modules.FirstOrDefault());
        }
        public async Task CantFindCommandWithoutIgnoreCaseAndOnceAlias(string alias, string input)
        {
            var config = new MariCommandsOptions();

            config.Comparison = StringComparison.Ordinal;

            var moduleCache = new ModuleCache(config);

            var commandMock1 = new Mock <ICommand>();

            commandMock1.SetupGet(a => a.Aliases).Returns(new List <string>
            {
                alias,
            });

            var command1 = commandMock1.Object;

            var commands = new List <ICommand>
            {
                command1,
            };

            var moduleMock = new Mock <IModule>();

            moduleMock.SetupGet(a => a.Commands).Returns(commands);
            moduleMock.SetupGet(a => a.Aliases).Returns(new List <string>());
            moduleMock.SetupGet(a => a.Submodules).Returns(new List <IModule>());

            var module = moduleMock.Object;

            commandMock1.SetupGet(a => a.Module).Returns(module);

            moduleCache.AddModule(module);

            var matches = await moduleCache.SearchCommandsAsync(input);

            Assert.NotNull(matches);
            Assert.Empty(matches);
        }