title: Verifying a mocked method uses specific CancellationTokenSouce which is also mocked
body: <p>Im trying to verify that a specific CancellationTokenSource is used as an actual parameter in a method call.</p>
  
  <pre><code>        public void DataVerification(Object sender, EventArgs e)
          {
              _entity.PopulateEntityDataVerificationStage(_view.DataTypeInputs, _view.ColumnNameInputs, _view.InitialRow, _view.FinalRow, _view.CurrencyPair, _view.CsvFilePath, _view.ErrorLogFilePath);
  
              //...
  
              CancellationTokenSource tempCsvFileVerificationCancellation = new CancellationTokenSource();
  
              _source.Source = tempCsvFileVerificationCancellation;
  
             //Want to verify that TempCsvFileVerificationCancellation.Token is passed into the following method.
              _verify.SetupCsvFileVerification(_entity, tempCsvFileVerificationCancellation.Token);
  
             //...
          } 
  </code></pre>
  
  <p>The following is my test:</p>
  
  <pre><code>    [Test]
      public void DataVerification_SetupCsvFileVerification_CorrectInputs()
      {
          Mock&lt;IMainForm&gt; view = new Mock&lt;IMainForm&gt;();
  
          Mock&lt;IUserInputEntity&gt; entity = new Mock&lt;IUserInputEntity&gt;();
  
          Mock&lt;ICsvFileVerification&gt; verify = new Mock&lt;ICsvFileVerification&gt;();
          verify.Setup(x =&gt; x.SetupCsvFileVerification(It.IsAny&lt;UserInputEntity&gt;(), It.IsAny&lt;CancellationToken&gt;()));
  
          CancellationTokenSource cts = new CancellationTokenSource();
  
          Mock&lt;ICancellationTokenSource&gt; source = new Mock&lt;ICancellationTokenSource&gt;();
          source.SetupSet(x =&gt; x.Source = It.IsAny&lt;CancellationTokenSource&gt;()).Callback&lt;CancellationTokenSource&gt;(value =&gt; cts = value);
          source.SetupGet(x =&gt; x.Source).Returns(cts);
          source.SetupGet(x =&gt; x.Token).Returns(cts.Token);
  
          MainPresenter presenter = new MainPresenter(view.Object, entity.Object, verify.Object, source.Object);
  
          presenter.DataVerification(new object(), new EventArgs());
  
          verify.Verify(x =&gt; x.SetupCsvFileVerification(entity.Object, source.Object.Token));
      }
  </code></pre>
  
  <p>The error message is as follows:</p>
  
  <p>Expected invocation on the mock at least once, but was never performed: x => x.SetupCsvFileVerification(.entity.Object, (Object).source.Object.Token)
  No setups configured.</p>
  
  <p>The class represented by source is as follows:</p>
  
  <pre><code>public interface ICancellationTokenSource
  {
      void Cancel();
  
      CancellationTokenSource Source { get; set; }
  
      CancellationToken Token { get; }
  }
  
  public class CancellationTokenSourceWrapper : ICancellationTokenSource
  {
      private CancellationTokenSource _source;
  
      public CancellationTokenSourceWrapper(CancellationTokenSource source)
      {
          _source = source;
      }
  
      public CancellationTokenSource Source
      {
          get
          {
              return _source;
          }
          set
          {
              _source = value;
          }
      }
  
  
      public CancellationToken Token 
      {
          get
          {
              return Source.Token;
          }
      }
  
      public void Cancel()
      {
          _source.Cancel();
      }
  }
  </code></pre>
  
  <p>When i step through the unit test, cts does get assigned the value of TempCsvFileVerificationCancellation. The Token property in source, returns Source.Token. Im at a loss as to what i have done wrong.</p>
  
  <p>Any pointers/assistance would be appreciated.</p>
  
  <p>Thanks</p>
  
  <p><strong>EDIT</strong></p>
  
  <p><a href="https://imgur.com/REwi4" rel="nofollow noreferrer"><img src="https://i.imgur.com/REwi4.jpg" alt="" title="Hosted by imgur.com" /></a></p>