Ejemplo n.º 1
0
        public async Task TestExtractCommandsByAttribute()
        {
            var commands = CommandTreeBuilder.ExtractCommandsFromClass <CommandFake>().ToArray();
            var patterns = commands.Select(c => c.pattern).ToArray();

            Assert.Contains("1", patterns);
            Assert.Contains("2", patterns);
            Assert.Contains("3", patterns);
            Assert.Contains("4", patterns);
            Assert.Contains("5", patterns);

            var testInstance = new CommandFake();

            foreach (var(pattern, metadata) in commands)
            {
                Assert.NotNull(metadata.DelegateGetter);

                var action = metadata.DelegateGetter(testInstance);

                Assert.NotNull(action);

                await action(null);
            }

            Assert.True(testInstance.EAsyncWithArg);
            Assert.True(testInstance.EAsyncWithoutArg);
            Assert.True(testInstance.ESyncWithArg);
            Assert.True(testInstance.ESyncWithoutArg);
            Assert.True(testInstance.EMenuItem);
        }