<commit_before>require_relative '../../../automated_init'

context "Write" do
  context "Substitute" do
    context "Batch" do
      context "Write" do
        stream_name = Controls::StreamName.example(category: 'testWriteBatchTelemetry')

        message_1 = Controls::Message.example(some_attribute: 'value_1')
        message_2 = Controls::Message.example(some_attribute: 'value_2')

        batch = [message_1, message_2]

        write = Write::Substitute.build

        write.(batch, stream_name, expected_version: 11, reply_stream_name: 'someReplyStreamName')

        context "Detection Interrogatives" do
          test "No block arguments" do
            assert(write.written?)
          end

          2.times do |i|
            context "Message #{i}" do
              test "Message block argument only" do
                assert(write.written? { |msg| msg == batch[i] })
              end
            end
          end

          test "Message and stream name block arguments" do
            assert(write.written? { |msg, stream| stream == stream_name })
          end

          test "Message, stream name, and expected_version block arguments" do
            assert(write.written? { |msg, stream, expected_version | expected_version == 11 })
          end

          test "Message, stream name, expected_version, and reply_stream_name block arguments" do
            assert(write.written? { |msg, stream, expected_version, reply_stream_name | reply_stream_name == 'someReplyStreamName' })
          end
        end

        context "Recorded Data" do
          test "No block arguments" do
            assert(write.writes.length == 2)
          end

          2.times do |i|
            context "Message #{i}" do
              test "Message block argument only" do
                assert(write.writes { |msg| msg == batch[i] }.length == 1 )
              end
            end
          end

          test "Message and stream name block arguments" do
            assert(write.writes { |msg, stream| stream == stream_name }.length == 2)
          end

          test "Message, stream name, and expected_version block arguments" do
            assert(write.writes { |msg, stream, expected_version | expected_version == 11 }.length == 2)
          end

          test "Message, stream name, expected_version, and reply_stream_name block arguments" do
            assert(write.writes { |msg, stream, expected_version, reply_stream_name | reply_stream_name == 'someReplyStreamName' }.length == 2)
          end
        end
      end<commit_msg>Writer substitute records batch messages<commit_after>require_relative '../../../automated_init'

context "Write" do
  context "Substitute" do
    context "Batch" do
      context "Write" do
        stream_name = Controls::StreamName.example(category: 'testWriteBatchTelemetry')

        message_1 = Controls::Message.example(some_attribute: 'value_1')
        message_2 = Controls::Message.example(some_attribute: 'value_2')

        batch = [message_1, message_2]

        write = Write::Substitute.build

        write.(batch, stream_name, expected_version: 11, reply_stream_name: 'someReplyStreamName')

        context "Detection Interrogatives" do
          test "No block arguments" do
            assert(write.written?)
          end

          2.times do |i|
            context "Message #{i}" do
              test "Message block argument only" do
                assert(write.written? { |msg| msg == batch[i] })
              end
            end
          end

          test "Message and stream name block arguments" do
            assert(write.written? { |msg, stream| stream == stream_name })
          end

          test "Message, stream name, and expected_version block arguments" do
            assert(write.written? { |msg, stream, expected_version | expected_version == 11 })
          end

          test "Message, stream name, expected_version, and reply_stream_name block arguments" do
            assert(write.written? { |msg, stream, expected_version, reply_stream_name | reply_stream_name == 'someReplyStreamName' })
          end
        end

        context "Recorded Data" do
          test "No block arguments" do
            assert(write.writes.length == 2)
          end

          2.times do |i|
            context "Message #{i}" do
              test "Message block argument only" do
                assert(write.writes { |msg| msg == batch[i] }.length == 1 )
              end
            end
          end

          test "Message and stream name block arguments" do
            assert(write.writes { |msg, stream| stream == stream_name }.length == 2)
          end

          test "Message, stream name, and expected_version block arguments" do
            assert(write.writes { |msg, stream, expected_version | expected_version == 11 }.length == 2)
          end

          test "Message, stream name, expected_version, and reply_stream_name block arguments" do
            assert(write.writes { |msg, stream, expected_version, reply_stream_name | reply_stream_name == 'someReplyStreamName' }.length == 2)
          end
        end

        context "Written Messages" do
          test "No block arguments" do
            assert(write.message_writes.length == 2)
          end

          2.times do |i|
            context "Message #{i}" do
              test "Message block argument only" do
                assert(write.message_writes { |msg| msg == batch[i] }.length == 1 )
              end
            end
          end

          test "Message and stream name block arguments" do
            assert(write.message_writes { |msg, stream| stream == stream_name }.length == 2)
          end

          test "Message, stream name, and expected_version block arguments" do
            assert(write.message_writes { |msg, stream, expected_version | expected_version == 11 }.length == 2)
          end

          test "Message, stream name, expected_version, and reply_stream_name block arguments" do
            assert(write.message_writes { |msg, stream, expected_version, reply_stream_name | reply_stream_name == 'someReplyStreamName' }.length == 2)
          end
        end
      end
{'fraction_non_alphanumeric': 0.0904823567497572, 'fraction_numerical': 0.007445775331822596, 'mean_word_length': 2.111278952668681, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3712', 'n_tokens_mistral': 1652, 'n_tokens_neox': 1575, 'n_words': 500}