Skip to content

Conversation

@arialdomartini
Copy link
Contributor

@arialdomartini arialdomartini commented Mar 24, 2025

Here's the C# sample code for the documentation of model-based testing.

This fixes #651.

The xUnit test included in StatefulTesting.cs fails as expected and shrinks the result, just like its equivalent F# counterpart does:

System.Exception: Falsifiable, after 2 tests (7 shrinks) (5300258228397282807,4958061799022127411)

System.Exception
Falsifiable, after 2 tests (7 shrinks) (5300258228397282807,4958061799022127411)
Last step was invoked with size of 3 and seed of (10627190116743403733,17882348317831933203):
Label of failing property: Inc: model = 4, actual = 3
Original:
(3, Setup Counter)
inc -> 4
dec -> 3
inc -> 4
dec -> 3
inc -> 4
dec -> 3
dec -> 2
dec -> 1
inc -> 2
inc -> 3
Nothing
Shrunk:
(3, Setup Counter)
inc -> 4
Nothing
with exception:
System.Exception: Expected true, got false.

The PR includes both the C# code in examples/CSharp.DocSnippets/StatefulTesting.cs and the reference in the narrative page docs/StatefulTestingNew.fsx.

@arialdomartini arialdomartini changed the title Sample code for C# Sample C# code for Model-base testing Mar 24, 2025
@kurtschelfthout kurtschelfthout merged commit 6c5eae9 into fscheck:master Mar 25, 2025
1 check passed
@kurtschelfthout
Copy link
Member

Fantastic thank you.

Btw for some reason I can't seem to publish the docs anymore from my laptop. I'm trying to fix - as soon as I do I'll update the site!

@kurtschelfthout
Copy link
Member

Fantastic thank you.

Btw for some reason I can't seem to publish the docs anymore from my laptop. I'm trying to fix - as soon as I do I'll update the site

Your changes are live now!

@arialdomartini arialdomartini deleted the model-based-testing-csharp branch March 26, 2025 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Model-based testing examples in C#?

2 participants