このエラーが発生しました
テスト 'EM.CoreTest.Services.UnitTestEventSevice.EventService_Return_10_Events' が失敗しました: Moq.MockVerificationException : 次の設定が一致しませんでした: IPricePackRepository pricepack => pricepack.Delete(It.Is(a => a.PP_EventID == 1)) at Moq .Mock.Verify() Services\UnitTestEventSevice.cs(52,0): EM.CoreTest.Services.UnitTestEventSevice.EventService_Return_10_Events() で
eventPersistenceMock と同じロジックを持っているため、なぜその部分でエラーが発生するのか疑問に思っています。私を助けてください。
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<IEventRepository>();
var pricepackPersistenceMock = new Mock<IPricePackRepository>();
var regformPersistenceMock = new Mock<IRegFormRepository>();
var attendeePersistenceMock = new Mock<IAttendeeRepository>();
var eventlists = GetEvents();
var pricepacks = GetPricepacks();
var currentevent = eventlists.ToList()[1];
eventPersistenceMock.Setup(r => r.GetAll()).Returns(eventlists);
eventPersistenceMock.Setup(u => u.Single(It.IsAny<Func<tbl_SBAem_Event, bool>>())).Returns(eventlists.Where(a => a.EventMngID == currentevent.EventMngID).Single());
eventPersistenceMock.Setup(r => r.Delete(currentevent)).Verifiable();
eventPersistenceMock.Setup(r => r.SaveChanges()).Verifiable();
pricepackPersistenceMock.Setup(pricepack => pricepack.GetAll()).Returns(pricepacks);
pricepackPersistenceMock.Setup(pricepack => pricepack.Delete(It.Is<tbl_SBAem_PricePackages>(a => a.PP_EventID == currentevent.EventMngID))).Verifiable();
pricepackPersistenceMock.Setup(pricepack => pricepack.SaveChanges()).Verifiable();
regformPersistenceMock.Setup(rgform => rgform.Delete(It.Is<tbl_SBAem_RegForm>(a => a.RF_EventID == currentevent.EventMngID))).Verifiable();
regformPersistenceMock.Setup(rgform => rgform.SaveChanges()).Verifiable();
attendeePersistenceMock.Setup(atnd => atnd.Delete(It.Is<tbl_SBAem_Attendee>(a => a.AT_RegID == currentevent.EventMngID))).Verifiable();
attendeePersistenceMock.Setup(atnd => 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<tbl_SBAem_PricePackages> GetPricepacks()
{
var listtblsbaemPricePackages = new List<tbl_SBAem_PricePackages>();
for (var i = 0; i < 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<tbl_SBAem_Event> GetEvents()
{
var listtblsbaemConfig = new List<tbl_SBAem_Event>();
for (var i = 0; i < 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;
}
}
}