示例#1
0
        public void Directives_may_be_prefixed_with_percent()
        {
            var kernel = new CompositeKernel();

            kernel
            .Invoking(k => k.AddDirective(new Command("%hello")))
            .Should()
            .NotThrow();
        }
示例#2
0
        public void Directives_may_not_begin_with_(string value)
        {
            var kernel = new CompositeKernel();

            kernel
            .Invoking(k => k.AddDirective(new Command($"{value}hello")))
            .Should()
            .Throw <ArgumentException>()
            .Which
            .Message
            .Should()
            .Be("Directives must begin with # or %");
        }
        public void Directives_with_duplicate_aliases_are_not_allowed()
        {
            using var kernel = new CompositeKernel();

            kernel.AddDirective(new Command("#dupe"));

            kernel.Invoking(k =>
                            k.AddDirective(new Command("#dupe")))
            .Should()
            .Throw <ArgumentException>()
            .Which
            .Message
            .Should()
            .Be("Alias \'#dupe\' is already in use.");
        }
        public void cannot_add_duplicated_named_kernels()
        {
            using var kernel = new CompositeKernel
                  {
                      new CSharpKernel()
                  };

            kernel.Invoking(k => k.Add(new CSharpKernel()))
            .Should()
            .Throw <ArgumentException>()
            .Which
            .Message
            .Should()
            .Be("Alias '#!csharp' is already in use.");
        }
示例#5
0
        public void cannot_add_duplicated_named_kernels()
        {
            using var kernel = new CompositeKernel
                  {
                      new CSharpKernel()
                  };

            kernel.Invoking(k => k.Add(new CSharpKernel()))
            .Should()
            .Throw <ArgumentException>()
            .Which
            .Message
            .Should()
            .Be("Kernel \"csharp\" already registered (Parameter 'kernel')");
        }
        public void Directives_may_not_have_aliases_that_begin_with_(string value)
        {
            using var kernel = new CompositeKernel();

            var command = new Command("#!this-is-fine");

            command.AddAlias($"{value}hello");

            kernel
            .Invoking(k =>
            {
                kernel.AddDirective(command);
            })
            .Should()
            .Throw <ArgumentException>()
            .Which
            .Message
            .Should()
            .Be($"Invalid directive name \"{value}hello\". Directives must begin with \"#\".");
        }