Mysterious Random Number

I’m working on Hyperia Forex in C#. While debugging I noticed when a test script is started there is a random number assigned to the parameter value. I can’t figure out where this random number is coming from. Anybody know?

The unit tests don’t seem to use random values. Can you share what you’re seeing (using a codeblock, not a screenshot) that makes you think there are random values?

Here is the first test script in HyperiaForexTests… In debug mode I’ll put a break on the line var amount1. I’ll then look at the value parameter and it will be between 0 and 1. If I run the test again a different number is assigned. I thought the Task(1) attribute might generate it. I thought the project or solution properties might be generating the number, but no luck. I did notice the main() method is auto generated. Any ideas?

[Property]
[Task(1)]
public void Equality_with_same_currency(decimal value)
{
    var amount1 = new CurrencyAmount(value, "HD");
    var amount2 = new CurrencyAmount(value, "HD");

    Assert.True(amount1 == amount2);
}

Yup. FsCheck Properties lets you say “give me a random number for this test”.

Thanks for pointing me in the right direction. This also explains why each test is run 100 times.

@mthanson8333 Shameless plug: you might find this blog post of mine interesting: Property-based testing

1 Like