예제 #1
0
        public async Task When_an_unrecognized_directive_is_encountered_it_is_forwarded_to_the_kernel_as_submitCode()
        {
            SubmitCode submitCommand = null;

            using var kernel = new CompositeKernel
                  {
                      new FakeKernel("csharp")
                      {
                          Handle = (command, context) =>
                          {
                              submitCommand = command as SubmitCode;
                              return(Task.CompletedTask);
                          }
                      }
                  };

            using var events = kernel.KernelEvents.ToSubscribedList();

            await kernel.SubmitCodeAsync("#!undefinedDirective");

            using var _ = new AssertionScope();

            submitCommand.Should().NotBeNull();
            submitCommand.Code.Should().Be("#!undefinedDirective");
        }
예제 #2
0
        public void When_created_in_the_same_context_then_child_commands_having_the_same_parent_also_have_the_same_token()
        {
            var parentCommand = new SubmitCode("123");

            string token1 = null;
            string token2 = null;

            using (KernelInvocationContext.Establish(parentCommand))
            {
                token1 = new SubmitCode("456").GetToken();
                token2 = new SubmitCode("456").GetToken();
            }

            token1.Should().Be(token2);
        }
예제 #3
0
        public void When_resent_then_child_commands_having_the_same_parent_have_repeatable_tokens()
        {
            var parentCommand = new SubmitCode("123");

            parentCommand.SetToken("the-token");

            string token1 = null;
            string token2 = null;

            using (KernelInvocationContext.Establish(parentCommand))
            {
                token1 = new SubmitCode("456").GetToken();
            }

            using (KernelInvocationContext.Establish(parentCommand))
            {
                token2 = new SubmitCode("456").GetToken();
            }

            token1.Should().Be(token2);
        }