title: FsCheck lazy generators
body: <p>I have issues with generation of data within my tests.</p>
  
  <pre><code>    testProperty "calculate Operation against different operations should increase major" &lt;| fun  operationIdApi operationIdClient summaryApi summaryClient descriptionApi descriptionClient   -&gt; 
      ( notAllEqual [
              fun () -&gt; assessEquality &lt;| StringEquals(operationIdApi, operationIdClient)
              fun () -&gt; assessEquality &lt;| StringEquals(summaryApi , summaryClient)
              fun () -&gt; assessEquality &lt;| StringEquals(descriptionApi, descriptionClient)
          ]) ==&gt; lazy (
          let operationClient = createOpenApiOperation operationIdClient summaryClient descriptionClient
          let operationAPI = createOpenApiOperation operationIdApi summaryApi descriptionApi
          let actual = calculate operationAPI operationClient
          Expect.equal actual (Fact.Semver.IncreaseMajor) "return IncreaseMajor"
      )
  </code></pre>
  
  <p>The code that is actually tested is :</p>
  
  <pre><code> semver {
              if operationAPI.OperationId&lt;&gt; operationClient.OperationId then yield! IncreaseMajor
              if operationAPI.Summary &lt;&gt; operationClient.Summary then yield! IncreaseMajor
          }
  </code></pre>
  
  <p>The test should fail when the data produced is same OperationId, same summary and different description.
  But it does not and it led me to create my own generator or at least try to do so:</p>
  
  <p>I wanted my test to be written like this :</p>
  
  <pre><code>testProperty "calculate Operation against different operations should increase major" &lt;| fun  (operationId:ElementSet&lt;string&gt;)  (summary:ElementSet&lt;string&gt;)   -&gt; 
  </code></pre>
  
  <p>Therefore I create a type accordingly:</p>
  
  <pre><code>type ElementSet&lt;'a&gt; =
      | Same of 'a
      | Different 
  </code></pre>
  
  <p>and a generator for this type :</p>
  
  <pre><code>let setGen&lt;'a&gt; =
      Gen.oneof [
              gen { 
                  let! v = Arb.generate&lt;'a&gt;
                  return Same(v)
              }
              gen { return Different}
      ]
  
  type ElementSetGenerator =
      static member ElementSet() = 
          Arb.fromGen setGen&lt;'a&gt;
  
  do Arb.register&lt;ElementSetGenerator&gt;() |&gt; ignore
  </code></pre>
  
  <p>I was then trying to extract the data to construct my object :</p>
  
  <pre><code>let createOpenApiOperation operationId summary=
  let pi  = OpenApiOperation(OperationId=operationId.Get, Summary=summary.Get)    
  pi
  </code></pre>
  
  <p>The Get method did not exist yet so I was about to implement it by adding a member to my ElementSet&lt;'a>:</p>
  
  <pre><code>type ElementSet&lt;'a&gt; =
      | Same of 'a
      | Different 
      with member this.Get = 
          match this with
              | Same s -&gt; s
              | Different -&gt;  Arb.generate&lt;'a&gt;// some random generation here 
  </code></pre>
  
  <p>And this is where I am stuck. I would love to get some randomness here when I extract data. I wonder if this is the correct way to do so, or if I should have answered the problem earlier?</p>
  
  <p>Thanks for your inputs.</p>