Skip to content

Controlling comparison

Josh Hiles edited this page Dec 22, 2023 · 1 revision

Scientist compares control and candidate values using ==. To override this behavior, use Compare to define how to compare observed values instead:

public IUser GetCurrentUser(string hash)
{
    return Scientist.Science<IUser>("get-current-user", experiment =>
    {
        experiment.Compare((x, y) => x.Name == y.Name);

        experiment.Use(() => LookupUser(hash));
        experiment.Try(() => RetrieveUser(hash));
    });
}