Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can return an interface to product instead of a concrete Product.</p> <p>Such as </p> <pre><code>public IProduct GetProduct(int id) { return _productRepository.GetProduct(id); } </code></pre> <p>And then verify the Owner property was not set:</p> <pre><code>Dep&lt;IProduct&gt;().AssertWasNotCalled(p =&gt; p.Owner = Arg.Is.Anything); </code></pre> <p>If you care about all the properties and or methods, then there is probably a pre-existing way with Rhino. Otherwise you can make an extension method that probably uses reflection such as: </p> <pre><code>Dep&lt;IProduct&gt;().AssertNoPropertyOrMethodWasCalled() </code></pre> <p>Our behaviour specifications are like so:</p> <pre><code>[Specification] public class When_product_service_has_get_product_called_with_any_id : ProductServiceSpecification { private int _productId; private IProduct _actualProduct; [It] public void Should_return_the_expected_product() { this._actualProduct.Should().Be.EqualTo(Dep&lt;IProduct&gt;()); } [It] public void Should_not_have_the_product_modified() { Dep&lt;IProduct&gt;().AssertWasNotCalled(p =&gt; p.Owner = Arg&lt;string&gt;.Is.Anything); // or write your own extension method: // Dep&lt;IProduct&gt;().AssertNoPropertyOrMethodWasCalled(); } public override void GivenThat() { var randomGenerator = new RandomGenerator(); this._productId = randomGenerator.Generate&lt;int&gt;(); Stub&lt;IProductRepository, IProduct&gt;(r =&gt; r.GetProduct(this._productId)); } public override void WhenIRun() { this._actualProduct = Sut.GetProduct(this._productId); } } </code></pre> <p>Enjoy.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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