private DataAccess.Services.OrganizationService Arrange(List <OrganizationVersioned> list = null) { var organizationList = list ?? _organizationList; var publishedOrganization = organizationList.Where(o => o.PublishingStatusId == PublishedId).FirstOrDefault(); var id = publishedOrganization.Id; var rootId = publishedOrganization.UnificRootId; unitOfWorkMockSetup.Setup(uw => uw.ApplyIncludes( It.IsAny <IQueryable <OrganizationVersioned> >(), It.IsAny <Func <IQueryable <OrganizationVersioned>, IQueryable <OrganizationVersioned> > >(), It.IsAny <bool>() )).Returns((IQueryable <OrganizationVersioned> orgList, Func <IQueryable <OrganizationVersioned>, IQueryable <OrganizationVersioned> > func, bool applyfilters) => { return(orgList); }); var unitOfWork = unitOfWorkMockSetup.Object; var contextManager = new TestContextManager(unitOfWork, unitOfWork); var serviceUtilities = new ServiceUtilities(UserIdentification, LockingManager, contextManager, UserOrganizationService, VersioningManager, UserInfoService, UserOrganizationChecker); translationManagerMockSetup.Setup(t => t.Translate <OrganizationVersioned, VmOpenApiOrganizationVersionBase>(It.IsAny <OrganizationVersioned>())) .Returns((OrganizationVersioned org) => { if (org == null) { return(null); } return(new VmOpenApiOrganizationVersionBase { Id = org.UnificRootId, Modified = org.Modified, PublishingStatus = TypeCache.GetByValue <PublishingStatusType>(org.PublishingStatusId) }); }); var translationManagerMock = translationManagerMockSetup.Object; VersioningManagerMock.Setup(s => s.GetVersionId <OrganizationVersioned>(unitOfWork, rootId, PublishingStatus.Published, true)).Returns(id); // repositories OrganizationRepoMock.Setup(g => g.All()).Returns(organizationList.AsQueryable()); OrganizationNameRepoMock.Setup(m => m.All()).Returns(Enumerable.Empty <OrganizationName>().AsQueryable()); var serviceNameRepoMock = new Mock <IServiceNameRepository>(); unitOfWorkMockSetup.Setup(uw => uw.CreateRepository <IServiceNameRepository>()).Returns(serviceNameRepoMock.Object); var organizationServiceRepoMock = new Mock <IOrganizationServiceRepository>(); unitOfWorkMockSetup.Setup(uw => uw.CreateRepository <IOrganizationServiceRepository>()).Returns(organizationServiceRepoMock.Object); var serviceRepoMock = new Mock <IServiceVersionedRepository>(); unitOfWorkMockSetup.Setup(uw => uw.CreateRepository <IServiceVersionedRepository>()).Returns(serviceRepoMock.Object); var serviceProducerRepoMock = new Mock <IServiceProducerOrganizationRepository>(); unitOfWorkMockSetup.Setup(uw => uw.CreateRepository <IServiceProducerOrganizationRepository>()).Returns(serviceProducerRepoMock.Object); return(new DataAccess.Services.OrganizationService(contextManager, translationManagerMock, TranslationManagerVModel, Logger, OrganizationLogic, serviceUtilities, DataUtils, CommonService, AddressService, PublishingStatusCache, LanguageCache, VersioningManager, UserOrganizationChecker, CacheManager.TypesCache)); }