Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think you can get away with returning <code>IEnumerable&lt;ChangeItem&gt;</code> in your interface. It seems like <a href="http://msdn.microsoft.com/en-us/library/dd633880%28v=exchg.80%29" rel="nofollow">ChangeCollection</a> is just an implementation of <code>IEnumerable&lt;T&gt;</code>.</p> <pre><code>public interface IEwsIntegration { IEnumerable&lt;ItemChange&gt; GetItems(); } </code></pre> <p>Then you can simply return a list in your setup</p> <pre><code>ewsMock.Setup(e =&gt; e.GetItems()).Returns(new List&lt;ItemChange&gt;()); </code></pre> <p><strong>Update:</strong></p> <p>Since you have to use properties defined only on the concrete class, you have to create an adapter.</p> <p>First create an interface with the members from the concrete class.</p> <pre><code>public interface IChangeCollection&lt;T&gt; : IEnumerable&lt;T&gt; { bool MoreChangesAvailable { get; } string SyncState { get; } } </code></pre> <p>Make sure you return this type from your interface:</p> <pre><code>public interface IEwsIntegration { IChangeCollection&lt;ItemChange&gt; GetItems(); } </code></pre> <p>Then you have to create an implementation of <code>IChangeCollection&lt;T&gt;</code> which will simply direct calls to an instance of ChangeCollection.</p> <pre><code>public class ChangeCollectionAdapter&lt;T&gt; : IChangeCollection&lt;T&gt; { private readonly ChangeCollection _changeCollection; public ChangeCollectionAdapter(ChangeCollection changeCollection) { _changeCollection = changeCollection; } public bool MoreChangesAvailable { get { return _changeCollection.MoreChangesAvailable; } } //other members } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload