示例#1
0
        public AdventureReposistoryBase(IOptions <AdventureSampleConfig> config, IDistributedCache cache)
        {
            if (config == null)
            {
                throw new ArgumentException("config cannot be null");
            }

            if (config.Value == null)
            {
                throw new ArgumentException("config.Value cannot be null");
            }

            _adventureConfig = config.Value;


            if (cache == null)
            {
                throw new ArgumentNullException("cache cannot be null");
            }

            _cache = cache;


            if (string.IsNullOrWhiteSpace(_adventureConfig.ConfigContainerName))
            {
                throw new Exception("ConfigContainerName missing from configuration");
            }
            _configContainerName = _adventureConfig.ConfigContainerName;
        }
        private IServiceProvider GetTestProvider(string imageRoot)
        {
            AdventureSampleConfig checkerConfig = new AdventureSampleConfig();

            var serviceProvider = new Mock <IServiceProvider>();


            IOptions <AdventureSampleConfig> mockConfig = Options.Create(new AdventureSampleConfig());


            serviceProvider
            .Setup(x => x.GetService(typeof(IOptions <AdventureSampleConfig>)))
            .Returns(mockConfig);

            ILogger <AdventureSampleProcessor> adventureLogger = Mock.Of <ILogger <AdventureSampleProcessor> >();

            serviceProvider
            .Setup(x => x.GetService(typeof(ILogger <AdventureSampleProcessor>)))
            .Returns(adventureLogger);


            //ISqsService sqsService = Mock.Of<ISqsService>();
            //serviceProvider
            //    .Setup(x => x.GetService(typeof(ISqsService)))
            //    .Returns(sqsService);


            IAdventureRepository advRep = Mock.Of <IAdventureRepository>();

            ICurrentNodeRepository curRep = Mock.Of <ICurrentNodeRepository>();

            IMediaLinkProcessor mediaLinker = Mock.Of <IMediaLinkProcessor>();

            // IAdventureSampleProcessor adventureProcessor = new AdventureSampleProcessor(mockConfig, emailLogger, userManager, progMan, sqsService);

            IAdventureSampleProcessor adventureProcessor = new AdventureSampleProcessor(adventureLogger, advRep, curRep, mediaLinker);

            serviceProvider
            .Setup(x => x.GetService(typeof(IAdventureSampleProcessor)))
            .Returns(adventureProcessor);

            return(serviceProvider.Object);

            //public EmailProcessor(IOptions<EmailCheckerConfig> emailCheckerConfig,
            //                        ILogger<EmailProcessor> logger,
            //                        IAlexaUserDataManager userDataManager,
            //                        IProgressiveResponseManager progMan,
            //                        ISqsService sqsService
            //                      )
        }
示例#3
0
        public BlobMediaLinkProcessor(IOptions <AdventureSampleConfig> adventureOptions)
        {
            if (adventureOptions == null)
            {
                throw new ArgumentNullException("adventureOptions is null");
            }

            if (adventureOptions.Value == null)
            {
                throw new ArgumentNullException("adventureOptions not set");
            }

            AdventureSampleConfig advConfig = adventureOptions.Value;

            if (string.IsNullOrWhiteSpace(advConfig.MediaContainerName))
            {
                throw new ArgumentException("ConfigBucket must be set");
            }

            _containerName = advConfig.MediaContainerName;

            if (string.IsNullOrWhiteSpace(advConfig.MediaContainerAccountName))
            {
                throw new ArgumentException("MediaContainerAccountName must be set");
            }

            _mediaContainerAccountName = advConfig.MediaContainerAccountName;

            _localStoreServer = advConfig.LocalStoreServer;

            if (string.IsNullOrWhiteSpace(advConfig.MediaPath))
            {
                throw new ArgumentException("ConfigPath must be set");
            }


            string rootPath = advConfig.MediaPath;

            _configRootPath = rootPath[rootPath.Length - 1] == '/' ? rootPath : string.Concat(rootPath, '/');
        }