title: Moq.MockVerificationException : The following setups were not matched:
body: <p>I got this error </p>
  
  <blockquote>
    <p>Test
    'EM.CoreTest.Services.UnitTestEventSevice.EventService_Return_10_Events'
    failed: Moq.MockVerificationException : The following setups were not
    matched: IPricePackRepository pricepack =>
    pricepack.Delete(It.Is(a => a.PP_EventID ==
    1))   at Moq.Mock.Verify()    Services\UnitTestEventSevice.cs(52,0): at
    EM.CoreTest.Services.UnitTestEventSevice.EventService_Return_10_Events()</p>
  </blockquote>
  
  <p>I am wondering why on that part raising an error because they have the same logic with the eventPersistenceMock. Please help me.</p>
  
  <pre><code> namespace EM.CoreTest.Services
      {
          [TestFixture]
          public class UnitTestEventSevice
          {
              [SetUp]
              public void StartUp()
              {
                  AutoMapperConfiguration.Configure();
              }
              [Test]
              public void EventService_Return_10_Events()
              {
                  var eventPersistenceMock = new Mock&lt;IEventRepository&gt;();
                  var pricepackPersistenceMock = new Mock&lt;IPricePackRepository&gt;();
                  var regformPersistenceMock = new Mock&lt;IRegFormRepository&gt;();
                  var attendeePersistenceMock = new Mock&lt;IAttendeeRepository&gt;();
                  var eventlists = GetEvents();
                  var pricepacks = GetPricepacks();
                  var currentevent = eventlists.ToList()[1];
                  eventPersistenceMock.Setup(r =&gt; r.GetAll()).Returns(eventlists);
                  eventPersistenceMock.Setup(u =&gt; u.Single(It.IsAny&lt;Func&lt;tbl_SBAem_Event, bool&gt;&gt;())).Returns(eventlists.Where(a =&gt; a.EventMngID == currentevent.EventMngID).Single());
                  eventPersistenceMock.Setup(r =&gt; r.Delete(currentevent)).Verifiable();
                  eventPersistenceMock.Setup(r =&gt; r.SaveChanges()).Verifiable();
  
                   pricepackPersistenceMock.Setup(pricepack =&gt; pricepack.GetAll()).Returns(pricepacks);
                   pricepackPersistenceMock.Setup(pricepack =&gt; pricepack.Delete(It.Is&lt;tbl_SBAem_PricePackages&gt;(a =&gt; a.PP_EventID == currentevent.EventMngID))).Verifiable();
                   pricepackPersistenceMock.Setup(pricepack =&gt; pricepack.SaveChanges()).Verifiable();
  
                   regformPersistenceMock.Setup(rgform =&gt; rgform.Delete(It.Is&lt;tbl_SBAem_RegForm&gt;(a =&gt; a.RF_EventID == currentevent.EventMngID))).Verifiable();
                   regformPersistenceMock.Setup(rgform =&gt; rgform.SaveChanges()).Verifiable();
  
                   attendeePersistenceMock.Setup(atnd =&gt; atnd.Delete(It.Is&lt;tbl_SBAem_Attendee&gt;(a =&gt; a.AT_RegID == currentevent.EventMngID))).Verifiable();
                   attendeePersistenceMock.Setup(atnd =&gt; atnd.SaveChanges()).Verifiable();
  
                  var eventservice = new EventService(eventPersistenceMock.Object,pricepackPersistenceMock.Object,regformPersistenceMock.Object,attendeePersistenceMock.Object);
  
                  Assert.AreEqual(eventservice.EventLists().Count, 10);
                  Assert.AreEqual(eventservice.CustomizedQuestions(1).EventMngID, 1);
                  Assert.IsTrue(eventservice.DeletePage(currentevent.EventMngID));
  
                  eventPersistenceMock.Verify();
                  pricepackPersistenceMock.Verify();    
                  regformPersistenceMock.Verify();
                  attendeePersistenceMock.Verify();
              }
  
              private IEnumerable&lt;tbl_SBAem_PricePackages&gt;  GetPricepacks()
              {
                  var listtblsbaemPricePackages = new List&lt;tbl_SBAem_PricePackages&gt;();
                  for (var i = 0; i &lt; 10; i++)
                  {
                      var tblsbaemPricePackages = new tbl_SBAem_PricePackages
                      {
                          PP_AID = 1
                      ,
                          PP_AccessLevel = "Access Level"
                      ,
                          PP_AttendeeCount = 50
                      ,
                          PP_Cost = (decimal?)34.45
                      ,
                          PP_Desc = "Pricepacks Description"
                      ,
                          PP_EnforceCount = 1
                      ,
                          PP_EventID = i
                      ,
                          PP_GID = 1
                      ,
                          PP_Name = "Name"
                      ,
                          PP_Tax = (decimal?)23.12
                      ,
                          PricePackageID = i
                      };
                      listtblsbaemPricePackages.Add(tblsbaemPricePackages);
                  }
                  return listtblsbaemPricePackages;
              }
  
              private IEnumerable&lt;tbl_SBAem_Event&gt; GetEvents()
              {
                  var listtblsbaemConfig = new List&lt;tbl_SBAem_Event&gt;();
                  for (var i = 0; i &lt; 10; i++)
                  {
                      var tblSbAemEvent = new tbl_SBAem_Event
                      {
                          EventMngID = i
                          ,
                          EM_AID = null
                          ,
                          EM_Agree1Name = "Rene agree"
                          ,
                          EM_Agree1Value = "Yes"
                          ,
                          EM_Agree2Name = "Tessa Agree"
                          ,
                          EM_Agree2Value = "Yes"
                          ,
                          EM_AllowSignup = null
                          ,
                          EM_BccNotify = "rene_florendo@yahoo.com.ph"
                          ,
                          EM_ChargeTiming = "10:00 am"
                          ,
                          EM_ContactEmail = "rene.florendo@codelean.com"
                          ,
                          EM_ContactName = "Rene Florendo"
                          ,
                          EM_ContactPhone = "1234567"
                          ,
                          EM_CurAttendee = null
                          ,
                          EM_Date = DateTime.Now
                          ,
                          EM_Description = "It's me rene"
                          ,
                          EM_EditStatus = null
                          ,
                          EM_EmailIntro = "Hey dear I am rene"
                          ,
                          EM_EmailMessage = "I love you"
                          ,
                          EM_GID = null
                          ,
                          EM_GuestPass = "guessPass"
                          ,
                          EM_GuestUser = "rene"
                          ,
                          EM_Image = "image1.png"
                          ,
                          EM_Instructions = "just me"
                          ,
                          EM_Link = "htpp://yahoo.com"
                          ,
                          EM_Location = "makati city"
                          ,
                          EM_MapLink = "http://google.com/image.png"
                          ,
                          EM_MaxAttendee = null
                          ,
                          EM_RegEnd = new DateTime(2012, 4, 16)
                          ,
                          EM_RegStart = new DateTime(2012, 4, 16)
                          ,
                          EM_ReqAddress = null
                          ,
                          EM_ReqEmail = 1
                          ,
                          EM_ReqOrg = 1
                          ,
                          EM_ReqPhone = 1
                          ,
                          EM_ReqPhone2 = 1
                          ,
                          EM_ReqTitle = 1
                          ,
                          EM_ShowShip = 1
                          ,
                          EM_SkipAttendee = 1
                          ,
                          EM_Time = "10:00 am"
                          ,
                          EM_Type = "Type A"
                          ,
                          EM_isTemplate = 1
                          ,
                          EM_name = "Name me"
                          ,
                          EM_opt1Name = "optName1"
                          ,
                          EM_opt1Values = "optValues1"
                          ,
                          EM_opt2Name = "optName2"
                          ,
                          EM_opt2Values = "optValues2"
                          ,
                          EM_opt3Name = "optName3"
                          ,
                          EM_opt3Values = "optValues3"
                          ,
                          EM_opt4Name = "optName4"
                          ,
                          EM_opt4Values = "optValues4"
                          ,
                          EM_opt5Name = "optName5"
                          ,
                          EM_opt5Values = "optValues5"
                          ,
                          EM_opt6Name = "optName6"
                          ,
                          EM_opt6Values = "optValues6"
                          ,
                          EM_reqAgree1 = null
                          ,
                          EM_reqAgree2 = null
                          ,
                          EM_reqOpt1 = 1
                          ,
                          EM_reqOpt2 = 1
                          ,
                          EM_reqOpt3 = 1
                          ,
                          EM_reqOpt4 = 1
                          ,
                          EM_reqOpt5 = 1
                          ,
                          EM_reqOpt6 = 1
  
                      };
                      listtblsbaemConfig.Add(tblSbAemEvent);
                  }
                  return listtblsbaemConfig;
              }
          }
      }
  </code></pre>