public async Task Notebook_parser_server_does_nothing_with_garbage_input_and_skips_to_the_next_line_to_process()
        {
            var validRequest = new NotebookParseRequest(
                "the-id",
                serializationType: DocumentSerializationType.Dib,
                defaultLanguage: "csharp",
                rawData: Array.Empty <byte>());

            var requestJson = string.Concat(
                "this is a request that can't be handled in any meaninful way, including returning an error",
                "\n",
                validRequest.ToJson(),
                "\n");

            var asyncEnumerator = GetResponseObjectsEnumerable(requestJson).GetAsyncEnumerator();

            var result = await asyncEnumerator.GetNextAsync();

            result
            .Should()
            .BeOfType <NotebookParseResponse>()
            .Which
            .Id
            .Should()
            .Be("the-id");
        }
        public async Task Notebook_parser_server_takes_request_until_newline_and_returns_response_on_a_single_line(string newline)
        {
            var request = new NotebookParseRequest(
                "the-id",
                serializationType: DocumentSerializationType.Dib,
                defaultLanguage: "csharp",
                rawData: Encoding.UTF8.GetBytes("#!csharp\nvar x = 1;"));
            var requestJson = request.ToJson();

            var asyncEnumerator = GetResponseObjectsEnumerable(requestJson + newline).GetAsyncEnumerator();

            var response = await asyncEnumerator.GetNextAsync();

            response
            .Should()
            .BeOfType <NotebookParseResponse>()
            .Which
            .Should()
            .BeEquivalentTo(new NotebookParseResponse(
                                "the-id",
                                document: new InteractiveDocument(new List <InteractiveDocumentElement>()
            {
                new InteractiveDocumentElement("csharp", "var x = 1;")
            })));
        }
        public async Task Notebook_parser_server_can_handle_repeated_requests_with_different_newlines(string newline)
        {
            var request1 = new NotebookParseRequest(
                "the-id",
                serializationType: DocumentSerializationType.Dib,
                defaultLanguage: "csharp",
                rawData: Encoding.UTF8.GetBytes("#!csharp\nvar x = 1;"));
            var request2 = new NotebookSerializeRequest(
                "the-second-id",
                serializationType: DocumentSerializationType.Dib,
                defaultLanguage: "csharp",
                newLine: "\n",
                document: new InteractiveDocument(new List <InteractiveDocumentElement>()
            {
                new InteractiveDocumentElement("fsharp", "let y = 2")
            }));
            var fullRequestText = string.Concat(
                request1.ToJson(),
                newline,
                request2.ToJson(),
                newline);

            var asyncEnumerator = GetResponseObjectsEnumerable(fullRequestText).GetAsyncEnumerator();

            var result1 = await asyncEnumerator.GetNextAsync();

            result1
            .Should()
            .BeOfType <NotebookParseResponse>()
            .Which
            .Id
            .Should()
            .Be("the-id");

            var result2 = await asyncEnumerator.GetNextAsync();

            result2
            .Should()
            .BeOfType <NotebookSerializeResponse>()
            .Which
            .Id
            .Should()
            .Be("the-second-id");
        }