public void Init() { _efContext = EFContextFactory.CreateInMemoryEFContext(); _mapperMock = new Mock <IMapper>(); _regionsService = new RegionsService(_efContext, _mapperMock.Object); }
public void Setup() { LoggerMock = new Mock <ILogger>(); ApprovalServiceMock = new Mock <IApprovalService>(); AmqSettingsMock = new Mock <IOptions <AmqSettings> >(); AmqSettingsMock.SetupGet(o => o.Value).Returns(new AmqSettings()); EFContext = EFContextFactory.CreateInMemoryEFContext(); _technicalFeeService = new Mock <ITechnicalFeeService>(); RevisionPermissionService = new Mock <ICostStageRevisionPermissionService>(); CostStageRevisionService = new Mock <ICostStageRevisionService>(); CostBuilderMock = new Mock <ICostBuilder>(); var costBuilders = new EditableList <Lazy <ICostBuilder, PluginMetadata> > { new Lazy <ICostBuilder, PluginMetadata>( () => CostBuilderMock.Object, new PluginMetadata { BuType = BuType.Pg }) }; var userServiceMock = new Mock <IUserService>(); var configuration = new MapperConfiguration(config => config.AddProfiles( typeof(AdminProfile), typeof(SupportingDocumentProfile) ) ); var mapper = new Mapper(configuration); ActivityLogServiceMock = new Mock <IActivityLogService>(); _eventServiceMock = new Mock <IEventService>(); CostApprovalService = new CostApprovalService(ApprovalServiceMock.Object, _technicalFeeService.Object, EFContext, costBuilders, userServiceMock.Object, ActivityLogServiceMock.Object, _eventServiceMock.Object, RevisionPermissionService.Object, CostStageRevisionService.Object ); User = new UserIdentity { Email = "UserName", AgencyId = Guid.NewGuid(), Id = Guid.NewGuid() }; Service = new CostStageRevisionService( LoggerMock.Object, mapper, EFContext, new[] { new Lazy <ICostBuilder, PluginMetadata>( () => CostBuilderMock.Object, new PluginMetadata { BuType = BuType.Pg }) } ); }
public void Init() { _userIdentity = new UserIdentity { Id = Guid.NewGuid(), BuType = BuType.Pg }; _identityUser = new CostUser { Id = _userIdentity.Id }; _efContext = EFContextFactory.CreateInMemoryEFContext(); _efContext.CostUser.Add(_identityUser); _efContext.SaveChanges(); _costServiceMock = new Mock <ICostService>(); _eventServiceMock = new Mock <IEventService>(); _pgUserService = new Mock <IPgUserService>(); _pluginUserServices = new[] { new Lazy <IPgUserService, PluginMetadata>(() => _pgUserService.Object, new PluginMetadata { BuType = BuType.Pg }) }; _activityLogServiceMock = new Mock <IActivityLogService>(); _emailNotificationServiceMock = new Mock <IEmailNotificationService>(); _mapper = new Mapper(new MapperConfiguration(m => { m.AddProfile <UserProfile>(); })); _costOwnerService = new CostOwnerService(_efContext, _costServiceMock.Object, _eventServiceMock.Object, _pluginUserServices, _activityLogServiceMock.Object, _emailNotificationServiceMock.Object, _mapper); }
public void Setup() { LoggerMock = new Mock <ILogger>(); _efContext = EFContextFactory.CreateInMemoryEFContext(); CostStageRevisionServiceMock = new Mock <ICostStageRevisionService>(); StageServiceMock = new Mock <IStageService>(); costBuilderMock = new Mock <ICostBuilder>(); var costbuilder = new List <Lazy <ICostBuilder, PluginMetadata> > { new Lazy <ICostBuilder, PluginMetadata>( () => costBuilderMock.Object, new PluginMetadata { BuType = BuType.Pg }) }; PgPaymentService = new Mock <IPaymentService>(); PgPaymentService.Setup(x => x.CalculatePaymentAmount(It.IsAny <Guid>(), It.IsAny <bool>())).ReturnsAsync((PaymentAmountResult)null); PgPaymentService.Setup(x => x.GetPaymentAmount(It.IsAny <Guid>(), It.IsAny <bool>())).ReturnsAsync((PaymentAmountResult)null); CostStageService = new CostStageService( _efContext, LoggerMock.Object, CostStageRevisionServiceMock.Object, StageServiceMock.Object, costbuilder ); }
protected async Task SetupOnce() { Elasticsearch = await new Elasticsearch().Ready(); ElasticClient = new ElasticClient(new ConnectionSettings(Elasticsearch.Url)); AppSettingsOptionsMock = new Mock <IOptions <AppSettings> >(); AppSettingsOptionsMock.Setup(o => o.Value).Returns(new AppSettings { AdminUser = "******" }); EFContext = EFContextFactory.CreateInMemoryEFContext(); MapperMock = new Mock <IMapper>(); LoggerMock = new Mock <ILogger>(); CostSearchBuilderMock = new Mock <ICostSearchBuilder>(); ElasticSearchIndexService = new ElasticSearchIndexService( new[] { new Lazy <ICostSearchBuilder, PluginMetadata>(() => CostSearchBuilderMock.Object, new PluginMetadata { BuType = BuType.Pg }) }, LoggerMock.Object, EFContext, MapperMock.Object, ElasticClient, AppSettingsOptionsMock.Object ); await OneTimeSetup(); await CreateIndexes(); }
public void Init() { _loggerMock = new Mock <ILogger>(); _userServiceMock = new Mock <IUserService>(); _mapperMock = new Mock <IMapper>(); _efContext = EFContextFactory.CreateInMemoryEFContext(); _appSettingsMock = new Mock <IOptions <AppSettings> >(); _permissionServiceMock = new Mock <IPermissionService>(); _activityLogServiceMock = new Mock <IActivityLogService>(); _eventServiceMock = new Mock <IEventService>(); _pgUserServiceMock = new Mock <IPgUserService>(); _elasticSearchServiceMock = new Mock <IElasticSearchService>(); _gdamClientMock = new Mock <IGdamClient>(); _agencyServiceMock = new Mock <IAgencyService>(); _userService = new UserService( _mapperMock.Object, _permissionServiceMock.Object, _loggerMock.Object, _appSettingsMock.Object, _efContext, _elasticSearchServiceMock.Object, new[] { new Lazy <IPgUserService, PluginMetadata>( () => _pgUserServiceMock.Object, new PluginMetadata { BuType = BuType.Pg }) }, _activityLogServiceMock.Object, _agencyServiceMock.Object, _gdamClientMock.Object); _handlerMock = new A5UserLoginHandler(_loggerMock.Object, _userServiceMock.Object); _handler = new A5UserLoginHandler(_loggerMock.Object, _userService); }
public void Setup() { var approvalServiceMock = new Mock <IApprovalService>(); var amqSettingsMock = new Mock <IOptions <AmqSettings> >(); amqSettingsMock.SetupGet(o => o.Value).Returns(new AmqSettings()); _efContext = EFContextFactory.CreateInMemoryEFContext(); var technicalFeeService = new Mock <ITechnicalFeeService>(); var revisionPermissionService = new Mock <ICostStageRevisionPermissionService>(); var costStageRevisionService = new Mock <ICostStageRevisionService>(); _costBuilderMock = new Mock <ICostBuilder>(); var costBuilders = new EditableList <Lazy <ICostBuilder, PluginMetadata> > { new Lazy <ICostBuilder, PluginMetadata>( () => _costBuilderMock.Object, new PluginMetadata { BuType = BuType.Pg }) }; var userServiceMock = new Mock <IUserService>(); var activityLogServiceMock = new Mock <IActivityLogService>(); var eventServiceMock = new Mock <IEventService>(); _target = new CostApprovalService(approvalServiceMock.Object, technicalFeeService.Object, _efContext, costBuilders, userServiceMock.Object, activityLogServiceMock.Object, eventServiceMock.Object, revisionPermissionService.Object, costStageRevisionService.Object ); }
public void Init() { _appSettingsOptionsMock = new Mock <IOptions <AppSettings> >(); _appSettingsOptionsMock.Setup(s => s.Value).Returns(new AppSettings { GdnHost = "http://gdn.com", GdamCoreHost = "http://gdam.com" }); _efContext = EFContextFactory.CreateInMemoryEFContext(); _gdamClientMock = new Mock <IGdamClient>(); _mapperMock = new Mock <IMapper>(); _activityLogServiceMock = new Mock <IActivityLogService>(); _eventServiceMock = new Mock <IEventService>(); _costStageRevisionServiceMock = new Mock <ICostStageRevisionService>(); _costStageServiceMock = new Mock <ICostStageService>(); _supportingDocumentsService = new SupportingDocumentsService( _appSettingsOptionsMock.Object, _efContext, _gdamClientMock.Object, _mapperMock.Object, _activityLogServiceMock.Object, _eventServiceMock.Object, _costStageRevisionServiceMock.Object, _costStageServiceMock.Object ); }
public void Init() { _efContext = EFContextFactory.CreateInMemoryEFContext(); var dictionary = new Dictionary { Name = Constants.DictionaryNames.MediaType, DictionaryEntries = new[] { Constants.MediaType.Digital, Constants.MediaType.InStore, Constants.MediaType.NA, Constants.MediaType.NotForAir, Constants.MediaType.OutOfHome, Constants.MediaType.PRInfluencer, Constants.MediaType.Radio, Constants.MediaType.StreamingAudio, Constants.MediaType.Tv, Constants.MediaType.Cinema, Constants.MediaType.DirectToCustomer, Constants.MediaType.Multiple } .Select(i => new DictionaryEntry { Key = i }) .ToList() }; _efContext.Dictionary.Add(dictionary); _efContext.SaveChanges(); _costStageRevisionServiceMock = new Mock <ICostStageRevisionService>(); _service = new PgMediaTypesService(_efContext, _costStageRevisionServiceMock.Object); }
public void Init() { _efContext = EFContextFactory.CreateInMemoryEFContext(); _costStageRevisionServiceMock = new Mock <ICostStageRevisionService>(); _pgCostUserRoleService = new PgCostUserRoleService(_efContext, _costStageRevisionServiceMock.Object); }
public void Init() { _efContext = EFContextFactory.CreateInMemoryEFContext(); _efContextMock = new Mock <EFContext>(); _mapperMock = new Mock <IMapper>(); _dictionaryService = new DictionaryService(_efContext, _eventServiceMock.Object, _mapperMock.Object); _dictionaryServiceMock = new DictionaryService(_efContextMock.Object, _eventServiceMock.Object, _mapperMock.Object); }
public void Setup() { _efContext = EFContextFactory.CreateInMemoryEFContext(); _loggerMock = new Mock <ILogger>(); _mapperMock = new Mock <IMapper>(); _gdamClientMock = new Mock <IGdamClient>(); _brandService = new BrandService(_loggerMock.Object, _efContext, _gdamClientMock.Object, _mapperMock.Object); _jsonTestReader = new JsonTestReader(); }
public void Init() { _efContext = EFContextFactory.CreateInMemoryEFContext(); _costStageRevisionServicee = new Mock <ICostStageRevisionService>(); _costService = new PgCostService(_efContext, _costStageRevisionServicee.Object); gbpId = Guid.NewGuid(); eurId = Guid.NewGuid(); usdId = Guid.NewGuid(); }
public void Setup() { EFContext = EFContextFactory.CreateInMemoryEFContext(); _costStatusServiceMock = new Mock <ICostStatusService>(); PermissionServiceMock = new Mock <ICostStageRevisionPermissionService>(); LoggerMock = new Mock <ILogger>(); _eventServiceMock = new Mock <IEventService>(); _policyExceptionsServiceMock = new Mock <IPolicyExceptionsService>(); _activityLogServiceMock = new Mock <IActivityLogService>(); User = new UserIdentity { Email = "*****@*****.**", AgencyId = Guid.NewGuid(), Id = Guid.NewGuid() }; CostUser = new CostUser { Id = User.Id, Email = User.Email, ParentId = User.AgencyId }; var brandUser = new UserIdentity { Email = "*****@*****.**", AgencyId = Guid.NewGuid(), Id = Guid.NewGuid() }; var brandCostUser = new CostUser { Id = brandUser.Id, Email = brandUser.Email, ParentId = brandUser.AgencyId }; EFContext.CostUser.AddRange(CostUser, brandCostUser); EFContext.SaveChanges(); var pgPaymentService = new Mock <IPaymentService>(); pgPaymentService.Setup(x => x.CalculatePaymentAmount(It.IsAny <Guid>(), It.IsAny <bool>())).ReturnsAsync((PaymentAmountResult)null); ApprovalService = new ApprovalService( EFContext, _costStatusServiceMock.Object, PermissionServiceMock.Object, LoggerMock.Object, _eventServiceMock.Object, _policyExceptionsServiceMock.Object, _activityLogServiceMock.Object ); }
public void Init() { _mapper = new Mock <IMapper>(); _costStageRevisionServiceMock = new Mock <ICostStageRevisionService>(); _moduleServiceMock = new Mock <IModuleService>(); _elasticSearchServiceMock = new Mock <IElasticSearchService>(); _efContext = EFContextFactory.CreateInMemoryEFContext(); _appsettings = new Mock <IOptions <AppSettings> >(); _appsettings.Setup(a => a.Value).Returns(new AppSettings { AdminUser = "******", CostsAdminUserId = "dcc8c610-5eb5-473f-a5f7-b7d5d3ee9b55" }); _logger = new Mock <ILogger>(); _permissionServiceMock = new Mock <IPermissionService>(); _activityLogServiceMock = new Mock <IActivityLogService>(); _eventServiceMock = new Mock <IEventService>(); _agencyServiceMock = new Mock <IAgencyService>(); _pgAgencyServiceMock = new Mock <IPgAgencyService>(); _gdamClientMock = new Mock <IGdamClient>(); _pgUserService = new PgUserService( _efContext, _mapper.Object, _permissionServiceMock.Object, _logger.Object, _costStageRevisionServiceMock.Object, _activityLogServiceMock.Object, _eventServiceMock.Object, _pgAgencyServiceMock.Object ); _userService = new UserService( _mapper.Object, _permissionServiceMock.Object, _logger.Object, _appsettings.Object, _efContext, _elasticSearchServiceMock.Object, new[] { new Lazy <IPgUserService, PluginMetadata>( () => _pgUserService, new PluginMetadata { BuType = BuType.Pg }) }, _activityLogServiceMock.Object, _agencyServiceMock.Object, _gdamClientMock.Object ); }
public void Init() { _elasticSearchServiceMock = new Mock <IElasticSearchService>(); _efContext = EFContextFactory.CreateInMemoryEFContext(); _optionsMock = new Mock <IOptions <AppSettings> >(); _optionsMock.Setup(o => o.Value).Returns(new AppSettings()); _efContext.Currency.Add(new Currency { DefaultCurrency = true, Symbol = "$", Code = "USD" }); _efContext.SaveChanges(); _projectDataService = new ProjectDataService(_elasticSearchServiceMock.Object, _efContext, _optionsMock.Object); }
public void Init() { _efContextMock = new Mock <EFContext>(); _efContextMemory = EFContextFactory.CreateInMemoryEFContext(); _dictionaryServiceMock = new Mock <IDictionaryService>(); _moduleServiceMock = new Mock <IModuleService>(); _gdamClientMock = new Mock <IGdamClient>(); _loggerPsMock = new Mock <ILogger>(); _elasticSearchServiceMock = new Mock <IElasticSearchService>(); _mapperMock = new Mock <IMapper>(); _appSettingsMock = new Mock <IOptions <AppSettings> >(); _appSettingsMock.Setup(a => a.Value).Returns(new AppSettings { AdminUser = "******", CostsAdminUserId = "dcc8c610-5eb5-473f-a5f7-b7d5d3ee9b55", BrandPrefix = new[] { "brand" } }); _permissionServiceMock = new Mock <IPermissionService>(); var databaseFacadeMock = new Mock <DatabaseFacade>(_efContextMock.Object); var dbContextTransactionMock = new Mock <IDbContextTransaction>(); databaseFacadeMock.Setup(d => d.CurrentTransaction).Returns(dbContextTransactionMock.Object); _efContextMock.Setup(s => s.Database).Returns(databaseFacadeMock.Object); _projectService = new ProjectService( _loggerPsMock.Object, _efContextMock.Object, _mapperMock.Object, _dictionaryServiceMock.Object, _moduleServiceMock.Object, _appSettingsMock.Object, _gdamClientMock.Object, _elasticSearchServiceMock.Object ); _projectServiceEfMemory = new ProjectService( _loggerPsMock.Object, _efContextMemory, _mapperMock.Object, _dictionaryServiceMock.Object, _moduleServiceMock.Object, _appSettingsMock.Object, _gdamClientMock.Object, _elasticSearchServiceMock.Object ); _jsonReader = new JsonTestReader(); }
public void Init() { _abstractTypeServiceMock = new Mock <IAbstractTypesService>(); _dictionaryServiceMock = new Mock <IDictionaryService>(); _regionServiceMock = new Mock <IRegionsService>(); _efContext = EFContextFactory.CreateInMemoryEFContext(); _mapperMock = new Mock <IMapper>(); _featureService = new Mock <IFeatureService>(); _pgVendorRuleBuilder = new PgVendorRuleBuilder( _abstractTypeServiceMock.Object, _dictionaryServiceMock.Object, _regionServiceMock.Object, _efContext, _mapperMock.Object, _featureService.Object ); }
public void Setup() { _efContext = EFContextFactory.CreateInMemoryEFContext(); _currencyServiceMock = new Mock <ICurrencyService>(); _mapperMock = new Mock <IMapper>(); _eventServiceMock = new Mock <IEventService>(); _vendorRuleBuilderMock = new Mock <IVendorRuleBuilder>(); var vendorRuleBuilders = new List <Lazy <IVendorRuleBuilder, PluginMetadata> > { new Lazy <IVendorRuleBuilder, PluginMetadata>(() => _vendorRuleBuilderMock.Object, new PluginMetadata { BuType = BuType.Pg }) }; _service = new VendorsService(_currencyServiceMock.Object, _mapperMock.Object, _efContext, vendorRuleBuilders, _eventServiceMock.Object); }
public void Setup() { _efContext = EFContextFactory.CreateInMemoryEFContext(); _elasticSettingsMock = new Mock <IOptions <ElasticSearchSettings> >(); _appSettingsMock = new Mock <IOptions <AppSettings> >(); _appSettingsMock.Setup(a => a.Value).Returns(new AppSettings { ElasticBatchSize = 1000 }); _elasticClientMock = new Mock <IElasticClient>(); _elasticSettingsMock.Setup(a => a.Value).Returns(new ElasticSearchSettings { Nodes = "http://localhost:9222", IsLogged = true, DefaultIndex = "costs", DefaultSearchSize = 50 }); _permissionServiceMock = new Mock <IPermissionService>(); _mapperMock = new Mock <IMapper>(); _logger = new Mock <ILogger>(); _costSearchBuilderMock = new Mock <ICostSearchBuilder>(); _costViewDetailsMock = new Mock <ICostViewDetails>(); _elasticSearchService = new ElasticSearchService( new List <Lazy <ICostSearchBuilder, PluginMetadata> > { new Lazy <ICostSearchBuilder, PluginMetadata>(() => _costSearchBuilderMock.Object, new PluginMetadata { BuType = BuType.Pg }) }, _logger.Object, _permissionServiceMock.Object, _efContext, _mapperMock.Object, _elasticClientMock.Object, new List <Lazy <ICostViewDetails, PluginMetadata> > { new Lazy <ICostViewDetails, PluginMetadata>(() => _costViewDetailsMock.Object, new PluginMetadata { BuType = BuType.Pg }) } ); }
public void Setup() { _efContext = EFContextFactory.CreateInMemoryEFContext(); _eventService = new Mock <IEventService>(); _activityLogService = new Mock <IActivityLogService>(); _mediaTypeServiceMock = new Mock <IMediaTypesService>(); _service = new ExpectedAssetService(_efContext, _eventService.Object, _activityLogService.Object, _mediaTypeServiceMock.Object); _assetId = Guid.NewGuid(); _costId = Guid.NewGuid(); _costStageRevisionId = Guid.NewGuid(); var cost = new Cost { CostNumber = "Test101", Id = _costId }; _asset = GetExistingAsset(_assetId, cost); _assetSaveModel = GetAssetSaveModel(); _mediaTypeServiceMock.Setup(s => s.GetMediaTypesByCostStageRevision( It.IsAny <UserIdentity>(), It.IsAny <Guid>() )).ReturnsAsync(new[] { new DictionaryEntry { Id = _assetSaveModel.MediaTypeId ?? Guid.Empty } }); _userIdentity = new UserIdentity { Id = Guid.NewGuid(), IpAddress = "127.0.0.1", Email = "*****@*****.**" }; _efContext.ExpectedAsset.Add(_asset); _efContext.Cost.Add(cost); _efContext.SaveChanges(); }
public void Init() { _efContext = EFContextFactory.CreateInMemoryEFContext(); _customDataServiceMock = new Mock <ICustomObjectDataService>(); _mapperMock = new Mock <IMapper>(); _approvalServiceMock = new Mock <IApprovalService>(); _emailNotificationServiceMock = new Mock <IEmailNotificationService>(); _costActionServiceMock = new Mock <ICostActionService>(); _eventServiceMock = new Mock <IEventService>(); _pgPaymentServiceMock = new Mock <IPgPaymentService>(); _activityLogServiceMock = new Mock <IActivityLogService>(); _costId = Guid.NewGuid(); _brandApproverId = Guid.NewGuid(); _cost = new Cost { Id = _costId, CostNumber = CostNumber, LatestCostStageRevisionId = Guid.NewGuid() }; var brandApprover = new CostUser { Id = _brandApproverId, Email = ApprovalMemberModel.BrandApprovalUserEmail }; _efContext.Cost.Add(_cost); _efContext.CostUser.Add(brandApprover); _efContext.SaveChanges(); _consumer = new PgPurchaseOrderResponseConsumer( _efContext, _customDataServiceMock.Object, _mapperMock.Object, _approvalServiceMock.Object, _emailNotificationServiceMock.Object, _costActionServiceMock.Object, _eventServiceMock.Object, _pgPaymentServiceMock.Object, _activityLogServiceMock.Object ); }
public void Init() { _aclClientMock = new Mock <IAclClient>(); _appSettingsMock = new Mock <IOptions <AppSettings> >(); EFContext = EFContextFactory.CreateInMemoryEFContext(); _aclUtilServiceMock = new Mock <IAclUtilService>(); _loggerMock = new Mock <ILogger>(); _pluginUserServicesMock = new Mock <IEnumerable <Lazy <IPgUserService, PluginMetadata> > >(); _appSettingsMock.Setup(a => a.Value).Returns(new AppSettings { CostsAdminUserId = xUserId.ToString() }); _sut = new PermissionService( _aclClientMock.Object, _appSettingsMock.Object, EFContext, _aclUtilServiceMock.Object, _loggerMock.Object, _pluginUserServicesMock.Object ); }
public void Setup() { EFContext = EFContextFactory.CreateInMemoryEFContext(); PgStageBuilderMock = new Mock <IStageBuilder>(); RuleServiceMock = new Mock <IRuleService>(); PermissionServiceMock = new Mock <IPermissionService>(); PurchaseOrderServiceMock = new Mock <IPgPurchaseOrderService>(); CostTemplateServiceMock = new Mock <ICostTemplateService>(); CostServiceMock = new Mock <ICostService>(); _mapper = new Mapper(new MapperConfiguration(m => { m.AddProfile <UserProfile>(); m.AddProfile <SupportingDocumentProfile>(); m.AddProfile <CostModelProfile>(); m.AddProfile <CostSearchProfile>(); })); CostViewDetails = new PgCostViewDetails(_mapper, EFContext, PermissionServiceMock.Object, new[] { new Lazy <IStageBuilder, PluginMetadata>(() => PgStageBuilderMock.Object, new PluginMetadata { BuType = BuType.Pg }) }, RuleServiceMock.Object, PurchaseOrderServiceMock.Object, CostTemplateServiceMock.Object, CostServiceMock.Object); CostId = Guid.NewGuid(); RevisionId = Guid.NewGuid(); CurrencyUsdId = Guid.NewGuid(); UserIdentity = new UserIdentity() { Id = Guid.NewGuid() }; SetupData(); }
public void Init() { _costSearchBuilderMock = new Mock <ICostSearchBuilder>(); _costSearchBuilderMock.Setup(b => b.GetIndexDescriptors()).Returns(new[] { new IndexDescriptor { Alias = Constants.ElasticSearchIndices.CostsIndexName } }); var searchBuilders = new List <Lazy <ICostSearchBuilder, PluginMetadata> > { new Lazy <ICostSearchBuilder, PluginMetadata>(() => _costSearchBuilderMock.Object, new PluginMetadata { BuType = BuType.Pg }) }; _logger = new Mock <ILogger>(); _efContext = EFContextFactory.CreateInMemoryEFContext(); _mapperMock = new Mock <IMapper>(); _elasticClientMock = new Mock <IElasticClient>(); _appSettingsMock = new Mock <IOptions <AppSettings> >(); _appSettingsMock.Setup(a => a.Value).Returns(new AppSettings { ElasticBatchSize = 1000, AdminUser = "******" }); _elasticBultResponseMock = new Mock <IBulkResponse>(); _elasticSearchIndexService = new ElasticSearchIndexService( searchBuilders, _logger.Object, _efContext, _mapperMock.Object, _elasticClientMock.Object, _appSettingsMock.Object ); }
public void Init() { EFContext = EFContextFactory.CreateInMemoryEFContext(); LoggerAsMock = new Mock <ILogger>(); AppSettings = new Mock <IOptions <AppSettings> >(); AppSettings.Setup(a => a.Value).Returns(new AppSettings { AdminUser = "******", CostsAdminUserId = "77681eb0-fc0d-44cf-83a0-36d51851e9ae" }); PermissionServiceMock = new Mock <IPermissionService>(); PgUserServiceMock = new Mock <IPgUserService>(); PluginAgencyServiceMock = new Mock <IPluginAgencyService>(); UserServices = new EditableList <Lazy <IPgUserService, PluginMetadata> > { new Lazy <IPgUserService, PluginMetadata>( () => PgUserServiceMock.Object, new PluginMetadata { BuType = BuType.Pg }) }; PluginAgencyServices = new List <Lazy <IPluginAgencyService, PluginMetadata> > { new Lazy <IPluginAgencyService, PluginMetadata>( () => PluginAgencyServiceMock.Object, new PluginMetadata { BuType = BuType.Pg }) }; AgencyService = new AgencyService( EFContext, LoggerAsMock.Object, PermissionServiceMock.Object, UserServices, PluginAgencyServices, AppSettings.Object); JsonReader = new JsonTestReader(); }
public async Task Init() { _costSearchBuilderMock = new Mock <ICostSearchBuilder>(); _loggerMock = new Mock <ILogger>(); _mapperMock = new Mock <IMapper>(); _appSettingsMock = new Mock <IOptions <AppSettings> >(); _efContext = EFContextFactory.CreateInMemoryEFContext(); _pluginMetadataServices = new[] { new Lazy <ICostSearchBuilder, PluginMetadata>(() => _costSearchBuilderMock.Object, new PluginMetadata { BuType = BuType.Pg }) }; _elasticsearch = new Elasticsearch(); await _elasticsearch.Ready(); _elasticClient = new ElasticClient(new ConnectionSettings(_elasticsearch.Url)); _elasticSearchIndexService = new ElasticSearchIndexService( _pluginMetadataServices, _loggerMock.Object, _efContext, _mapperMock.Object, _elasticClient, _appSettingsMock.Object); }
public void Setup() { PgStageBuilderMock = new Mock <IPgStageBuilder>(); RuleServiceMock = new Mock <IRuleService>(); CostStageRevisionServiceMock = new Mock <ICostStageRevisionService>(); AgencyServiceMock = new Mock <IAgencyService>(); ProjectServiceMock = new Mock <IProjectService>(); EFContext = EFContextFactory.CreateInMemoryEFContext(); var currencyService = new Mock <IPgCurrencyService>(); PgLedgerMaterialCodeServiceMock = new Mock <IPgLedgerMaterialCodeService>(); CostLineItemServiceMock = new Mock <ICostLineItemService>(); CostNumberGeneratorServiceMock = new Mock <ICostNumberGeneratorService>(); CostTemplateVersionServiceMock = new Mock <ICostTemplateVersionService>(); PermissionServiceMock = new Mock <IPermissionService>(); _pgCostServiceMock = new Mock <IPgCostService>(); _pgPaymentServiceMock = new Mock <IPgPaymentService>(); _exchangeRateServiceMock = new Mock <IExchangeRateService>(); _pgTotalsBuilder = new PgCostSectionTotalsBuilder(); CostBuilder = new PgCostBuilder(PgStageBuilderMock.Object, RuleServiceMock.Object, CostStageRevisionServiceMock.Object, AgencyServiceMock.Object, ProjectServiceMock.Object, EFContext, CostNumberGeneratorServiceMock.Object, currencyService.Object, PgLedgerMaterialCodeServiceMock.Object, CostLineItemServiceMock.Object, CostTemplateVersionServiceMock.Object, PermissionServiceMock.Object, _pgCostServiceMock.Object, _pgTotalsBuilder, _pgPaymentServiceMock.Object, _exchangeRateServiceMock.Object ); }
public void Setup() { _aclClientMock = new Mock <IAclClient>(); _eventServiceMock = new Mock <IEventService>(); _efContext = EFContextFactory.CreateInMemoryEFContext(); _aclSettingsMock = new Mock <IOptions <AclSettings> >(); _appSettingsMock = new Mock <IOptions <AppSettings> >(); _loggerMock = new Mock <ILogger>(); _pluginUserServicesMock = new Mock <IEnumerable <Lazy <IPgUserService, PluginMetadata> > >(); _aclClientMock.Setup(a => a.Access).Returns(new Access(new AccessApi(new RequestHelper("http://localhost:9999/")), new FunctionHelper())); _aclClientMock.Setup(a => a.Get).Returns(new Get(new GetApi(new RequestHelper("http://localhost:9999/")), new FunctionHelper())); _aclClientMock.Setup(a => a.Batch).Returns(new Batch(new BatchApi(new RequestHelper("http://localhost:9999/")))); _aclSettingsMock.Setup(a => a.Value).Returns(new AclSettings { AclDb = "http://localhost:8529", AclUrl = "http://localhost:7777" }); _appSettingsMock.Setup(a => a.Value).Returns(new AppSettings { CostsAdminUserId = "77681eb0-fc0d-44cf-83a0-36d51851e9ae" }); _aclUtilService = new AclUtilService( _aclSettingsMock.Object, _aclClientMock.Object, _appSettingsMock.Object, _loggerMock.Object, _efContext, _eventServiceMock.Object, _mapperMock.Object ); _permissionService = new PermissionService( _aclClientMock.Object, _appSettingsMock.Object, _efContext, _aclUtilService, _loggerMock.Object, _pluginUserServicesMock.Object ); }
public void Setup() { _efContext = EFContextFactory.CreateInMemoryEFContext(); _httpServiceMock = new Mock <IHttpService>(); _adIdSettings.Url = "https://demo.ad-id.org/adid_services/{0}"; _adIdSettings.UserName = "******"; _adIdSettings.Password = "******"; _adIdSettings.BankId = "100000"; _adIdSettings.Advertiser = "PROCTER & GAMBLE"; _adIdSettings.FallbackBrandPrefix = "PGZZ"; _appSettingsMock.Setup(s => s.Value).Returns(_adIdSettings); _user = new UserIdentity { Email = "*****@*****.**", AgencyId = Guid.NewGuid(), Id = Guid.NewGuid(), BuType = BuType.Pg }; var videoId = Guid.NewGuid(); var videoContentType = new DictionaryEntry { Id = videoId, Key = "Video" }; var contentTypeMediums = new List <ContentTypeAdidMedium> { new ContentTypeAdidMedium { Id = Guid.NewGuid(), DictionaryEntry = videoContentType, DictionaryEntryId = videoId, MediaType = "Video", Medium = "TV -ALL", MediumValue = "1" }, new ContentTypeAdidMedium { Id = Guid.NewGuid(), MediaType = "Audio", Medium = "Radio -ALL", MediumValue = "43" }, new ContentTypeAdidMedium { Id = Guid.NewGuid(), MediaType = "Internet Display", Medium = "Other - Other", MediumValue = "161" }, new ContentTypeAdidMedium { Id = Guid.NewGuid(), MediaType = "Print", Medium = "ALL - Print", MediumValue = "56" } }; var agency = new Agency { Labels = new[] { "GID_100000" } }; var parent = new AbstractType { Agency = agency }; _brand = new Brand { AdIdPrefix = "1ADC" }; var project = new Project { Brand = _brand }; var cost = new Cost { Id = _costId, Parent = parent, Project = project }; _efContext.AddRange(new object[] { agency, parent, cost, _brand, project, videoContentType }); _efContext.ContentTypeAdidMedium.AddRange(contentTypeMediums); _efContext.SaveChanges(); //Unable to mock HttpContent.ReadAsStringAsync() and so Ad-Id service cannot be fully tested. _httpContentMock = new Mock <HttpContent>(); _httpResponseMessage = new HttpResponseMessage { Content = _httpContentMock.Object, StatusCode = HttpStatusCode.OK }; _httpServiceMock.Setup(h => h.PostAsync(It.IsAny <Uri>(), It.IsAny <FormUrlEncodedContent>())) .ReturnsAsync(_httpResponseMessage); _target = new AdIdService(_appSettingsMock.Object, _efContext, _activityLogMock.Object, _httpServiceMock.Object); }