예제 #1
0
        public void AllCommandNamesHaveStrings()
        {
            var stringsSource = new LocalFileStringsSource(
                responsesPath,
                commandsPath);
            var strings = new LocalBotStringsProvider(stringsSource);

            var culture = new CultureInfo("en-US");

            var isSuccess = true;

            foreach (var entry in CommandNameLoadHelper.LoadCommandNames(aliasesPath))
            {
                var commandName = entry.Value[0];

                var cmdStrings = strings.GetCommandStrings(culture.Name, commandName);
                if (cmdStrings is null)
                {
                    isSuccess = false;
                    TestContext.Out.WriteLine($"{commandName} doesn't exist in commands.en-US.yml");
                }
            }

            Assert.IsTrue(isSuccess);
        }
예제 #2
0
        public void AllCommandMethodsHaveNames()
        {
            var allAliases = CommandNameLoadHelper.LoadCommandNames(
                aliasesPath);

            var methodNames = GetCommandMethodNames();

            var isSuccess = true;

            foreach (var methodName in methodNames)
            {
                if (!allAliases.TryGetValue(methodName, out var _))
                {
                    TestContext.Error.WriteLine($"{methodName} is missing an alias.");
                    isSuccess = false;
                }
            }

            Assert.IsTrue(isSuccess);
        }
예제 #3
0
        public void NoObsoleteAliases()
        {
            var allAliases = CommandNameLoadHelper.LoadCommandNames(aliasesPath);

            var methodNames = GetCommandMethodNames()
                              .ToHashSet();

            var isSuccess = true;

            foreach (var item in allAliases)
            {
                var methodName = item.Key;

                if (!methodNames.Contains(methodName))
                {
                    TestContext.WriteLine($"'{methodName}' from aliases.yml doesn't have a matching command method.");
                    isSuccess = false;
                }
            }

            Assert.IsTrue(isSuccess);
        }