Note that there are some explanatory texts on larger screens.

plurals
  1. POKung foo invocations strike multiple times, how to know what called the method from a test?
    primarykey
    data
    text
    <p>OK - so I have this test. I wrote it expecting it would fail because my OnSaveCommand does call my adapters Save method yet. But to my surprise it failed saying "Invocation was performed more than once on the mock". I am totally confused. I am not called it at all <em>goink</em>. My problem is I don't know how to tell what is called it? If I where running the code I would throw in a break point and just look at the call stack when it gets called but that doesn't really work here because it's a mock of course. </p> <p>I tried to look at the moq quickstart for some ideas but the truth is I am just stumped. The first part of the test publishes an event that causes the DiscountsForSelectedCompany list to get populated, I can see that all that happens, then I execute the save command right? Then I get the error. Like I said, I am stumped - if someone could point me in the right direction that would be awesome. </p> <pre><code>[Test] public void SaveCommand_Will_Call_Adapter_SaveDiscounts_For_All_Edited_Discounts() { eventAggregator.GetEvent&lt;SetCompanyIdEvent&gt;().Publish(182); vm.DiscountsForSelectedCompany.Single(x =&gt; x.Id == 1).IsEdited = true; mockVariablePricingAdapter.Setup(x =&gt; x.SaveDiscounts( It.Is&lt;List&lt;DisplayCompanyDiscount&gt;&gt;(a =&gt; a.First().Id == 1)) ).Verifiable(); vm.SaveCommand.Execute(); mockVariablePricingAdapter.Verify(x =&gt; x.SaveDiscounts(It.Is&lt;List&lt;DisplayCompanyDiscount&gt;&gt;(a =&gt; a.First().Id == 1)), Times.Once()); } </code></pre> <p>Thanks!</p> <p>EIDT! WHOO - HEY!!! I changed the "Times.Once()" to "Times.AtLeastOnec()" and sure enough if fails saying "Invocation was not performed on the mock:" - Does anyone know about this? Is it a bug? </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.
 

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