public ApprenticeshipWithChangeOfPartyCreatedEventHandlerTestsFixture() { var autoFixture = new Fixture(); _event = autoFixture.Create <ApprenticeshipWithChangeOfPartyCreatedEvent>(); _apprenticeship = new Apprenticeship(); _apprenticeship.SetValue(x => x.Id, _event.ApprenticeshipId); _apprenticeship.SetValue(x => x.Cohort, new Cohort { AccountLegalEntity = new AccountLegalEntity() }); _changeOfPartyRequest = new Mock <ChangeOfPartyRequest>(); _changeOfPartyRequest.Setup(x => x.Id).Returns(_event.ChangeOfPartyRequestId); _changeOfPartyRequest.Setup(x => x.SetNewApprenticeship(_apprenticeship, _event.UserInfo, Party.Employer)); _db = new ProviderCommitmentsDbContext(new DbContextOptionsBuilder <ProviderCommitmentsDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .ConfigureWarnings(w => w.Throw(RelationalEventId.QueryClientEvaluationWarning)) .Options); _db.Apprenticeships.Add(_apprenticeship); _db.ChangeOfPartyRequests.Add(_changeOfPartyRequest.Object); _db.SaveChanges(); _messageHandlerContext = new Mock <IMessageHandlerContext>(); _handler = new ApprenticeshipWithChangeOfPartyCreatedEventHandler( new Lazy <ProviderCommitmentsDbContext>(() => _db), Mock.Of <ILogger <ApprenticeshipWithChangeOfPartyCreatedEventHandler> >()); }
public bool IsValidChangeOfPartyEvent(Apprenticeship apprenticeship, ApprenticeshipWithChangeOfPartyCreatedEvent changeOfPartyCreatedEvent) { return(apprenticeship.Id == changeOfPartyCreatedEvent.ApprenticeshipId && Command.ChangeOfPartyRequestId == changeOfPartyCreatedEvent.ChangeOfPartyRequestId); }