/// <summary> /// Constructor tests setup /// </summary> public GetServiceStep3Tests() { var unitOfWorkMockSetup = new Mock <IUnitOfWorkWritable>(); var translationManagerMockSetup = new Mock <ITranslationEntity>(); var serviceClassRepositoryMockSetup = new Mock <IServiceClassRepository>(); var organizationRepositoryMockSetup = new Mock <IOrganizationNameRepository>(); var publishingStatusTypeRepositoryMockSetup = new Mock <IPublishingStatusTypeRepository>(); var serviceRepositoryMockSetup = new Mock <IServiceRepository>(); var ontologyTermRepositoryMockSetup = new Mock <IOntologyTermRepository>(); var lifeEventRepositoryMockSetup = new Mock <ILifeEventRepository>(); var keywordRepositoryMockSetup = new Mock <IKeywordRepository>(); var targetGroupRepositoryMockSetup = new Mock <ITargetGroupRepository>(); logger = new Mock <ILogger <ServiceService> >().Object; var unitOfWorkMock = unitOfWorkMockSetup.Object; unitOfWorkMockSetup.Setup(uw => uw.CreateRepository <IServiceClassRepository>()).Returns(serviceClassRepositoryMockSetup.Object); unitOfWorkMockSetup.Setup(uw => uw.CreateRepository <IOrganizationNameRepository>()).Returns(organizationRepositoryMockSetup.Object); unitOfWorkMockSetup.Setup(uw => uw.CreateRepository <IServiceRepository>()).Returns(serviceRepositoryMockSetup.Object); unitOfWorkMockSetup.Setup(uw => uw.CreateRepository <IPublishingStatusTypeRepository>()).Returns(publishingStatusTypeRepositoryMockSetup.Object); unitOfWorkMockSetup.Setup(uw => uw.CreateRepository <IOntologyTermRepository>()).Returns(ontologyTermRepositoryMockSetup.Object); unitOfWorkMockSetup.Setup(uw => uw.CreateRepository <ILifeEventRepository>()).Returns(lifeEventRepositoryMockSetup.Object); unitOfWorkMockSetup.Setup(uw => uw.CreateRepository <IKeywordRepository>()).Returns(keywordRepositoryMockSetup.Object); unitOfWorkMockSetup.Setup(uw => uw.CreateRepository <ITargetGroupRepository>()).Returns(targetGroupRepositoryMockSetup.Object); unitOfWorkMockSetup.Setup(uw => uw.ApplyIncludes(It.IsAny <IQueryable <ServiceVersioned> >(), It.IsAny <Func <IQueryable <ServiceVersioned>, IQueryable <ServiceVersioned> > >(), It.IsAny <bool>())).Returns((Func <IQueryable <ServiceVersioned>, Func <IQueryable <ServiceVersioned>, IQueryable <ServiceVersioned> >, IQueryable <ServiceVersioned> >)((i, j) => i)); contextManager = new TestContextManager(unitOfWorkMock, unitOfWorkMock); }
public LockingManagerTests() { var service = new ServiceVersioned() { Id = Guid.NewGuid() }; servicesDbSet = new List <ServiceVersioned>() { service }; lockingDbSet = new List <Locking>(); unitOfWorkMockSetup = new Mock <IUnitOfWorkWritable>(); publishingStatusCache = new Mock <IPublishingStatusCache>(); publishingStatusCache.Setup(i => i.Get(It.IsAny <PublishingStatus>())).Returns <PublishingStatus>(j => j.ToString().GetGuid()); publishingStatusCache.Setup(i => i.Get(It.IsAny <string>())).Returns <string>(j => j.GetGuid()); serviceRepositoryMockSetup = new Mock <IServiceVersionedRepository>(); serviceRepositoryMockSetup.Setup(i => i.All()).Returns(servicesDbSet.AsQueryable()); serviceRepositoryMockSetup.Setup(i => i.Add(It.IsAny <ServiceVersioned>())).Returns <ServiceVersioned>(i => { servicesDbSet.Add(i); return(i); }); lockingRepositoryMockSetup = new Mock <ILockingRepository>(); lockingRepositoryMockSetup.Setup(i => i.All()).Returns(lockingDbSet.AsQueryable()); lockingRepositoryMockSetup.Setup(i => i.Add(It.IsAny <Locking>())).Returns <Locking>(i => { lockingDbSet.Add(i); return(i); }); lockingRepositoryMockSetup.Setup(i => i.Remove(It.IsAny <Locking>())).Callback <Locking>(i => { lockingDbSet.Remove(i); }); userIdentificationMockSetup = new Mock <IUserIdentification>(); unitOfWorkMockSetup.Setup(uw => uw.CreateRepository <IServiceVersionedRepository>()).Returns(serviceRepositoryMockSetup.Object); unitOfWorkMockSetup.Setup(uw => uw.CreateRepository <ILockingRepository>()).Returns(lockingRepositoryMockSetup.Object); userIdentificationMockSetup.Setup(ui => ui.UserName).Returns("TestUser"); userIdentificationMock = userIdentificationMockSetup.Object; unitOfWorkMock = unitOfWorkMockSetup.Object; contextManager = new TestContextManager(unitOfWorkMock, unitOfWorkMock); RegisterDbSet(servicesDbSet, unitOfWorkMockSetup); RegisterDbSet(lockingDbSet, unitOfWorkMockSetup); }