# `Cyclium.Test.SynthesizerCase`
[🔗](https://github.com/Cyclium/cyclium_ex/blob/main/lib/cyclium/test/synthesizer_case.ex#L1)

Test helpers for verifying synthesizer contract compliance and
a `FakeSynthesizer` for use in strategy tests.

## Usage

    defmodule MyApp.Synthesizers.ProcurementTest do
      use ExUnit.Case, async: true
      use Cyclium.Test.SynthesizerCase

      test "synthesizer returns valid response" do
        prompt_ctx = %{system: "You are a helpful assistant", messages: []}
        episode_ctx = Cyclium.Test.StrategyCase.build_episode_ctx()

        assert_valid_synthesize(MySynthesizer, prompt_ctx, episode_ctx)
      end
    end

## FakeSynthesizer

For strategy tests that need a controllable synthesizer:

    # In test setup
    Cyclium.Test.FakeSynthesizer.start_link()
    Cyclium.Test.FakeSynthesizer.set_response(%{"answer" => "42"})

    # Strategy calls synthesize/2 and gets the canned response

# `assert_valid_estimate_tokens`
*macro* 

Assert that `synthesizer.estimate_tokens/1` returns a non-negative integer.

# `assert_valid_synthesize`
*macro* 

Assert that `synthesizer.synthesize/2` returns a valid response shape.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
