Exemplo n.º 1
0
 static DataAccessProviderFactory()
 {
     string providerName = ConfigurationManager.AppSettings["DataProvider"];
     string providerFactoryName = ConfigurationManager.AppSettings["DataProviderFactory"];
     activeProvider = Assembly.Load(providerName);
     activeDataProviderFactory = (IDataProviderFactory)activeProvider.CreateInstance(providerFactoryName);
 }
Exemplo n.º 2
0
 public ReportGenerator(IDataProviderFactory dataProviderFactory, PipelineType pipelineType, ILogger logger)
 {
     _logger             = logger;
     _dataProviders      = dataProviderFactory.GetPipelineDataProviders();
     _dataPostProcessors = dataProviderFactory.GetPostProcessors();
     _pipelineType       = pipelineType;
 }
Exemplo n.º 3
0
 static DataEnvironment()
 {
     _accessors  = DataAccessProvider.Instance;
     _providers  = DataProviderFactory.Instance;
     _populators = DataPopulatorProviderFactory.Instance;
     _drivers    = new NamedCollection <IDataDriver>(p => p.Name, StringComparer.OrdinalIgnoreCase);
     _filters    = new DataAccessFilterCollection();
 }
Exemplo n.º 4
0
 public ListViewModel(IDataProviderFactory providerFactory, IServiceManager serviceManager)
 {
     ProviderFactory   = providerFactory;
     NavigationService = serviceManager.NavigationService;
     MessageService    = serviceManager.MessageService;
     DialogService     = serviceManager.DialogService;
     LogService        = serviceManager.LogService;
 }
Exemplo n.º 5
0
        static DataAccessProviderFactory()
        {
            string providerName        = ConfigurationManager.AppSettings["DataProvider"];
            string providerFactoryName = ConfigurationManager.AppSettings["DataProviderFactory"];

            //activeProvider = Assembly.Load(providerName);
            activeProvider            = Assembly.GetCallingAssembly();
            activeDataProviderFactory = (IDataProviderFactory)activeProvider.CreateInstance(providerFactoryName);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of <see cref="DataService"/>
        /// that is used provided <see cref="IDataProviderFactory"/>
        /// to create and use <see cref="IDataProvider"/>.
        /// </summary>
        /// <param name="dataProviderFactory"></param>
        public DataService(IDataProviderFactory dataProviderFactory)
        {
            if (dataProviderFactory == null)
            {
                throw new ArgumentNullException(SR.Get(SRID.DataProviderFactoryCannotBeNull));
            }

            providerFactory = dataProviderFactory;
        }
        public async Task AcquireRedditAuthorizationTokenAsync_WhenStateIsEmpty_ThrowsArgumentNullException()
        {
            string clientId    = Guid.NewGuid().ToString("D");
            string state       = string.Empty;
            Uri    redirectUri = new Uri($"http://localhost/{Guid.NewGuid().ToString("D")}");

            IDataProviderFactory sut = CreateSut();

            await sut.AcquireRedditAuthorizationTokenAsync(clientId, state, redirectUri);
        }
        public async Task AcquireRedditAuthorizationTokenAsync_WhenRedirectUrlIsNull_ThrowsArgumentNullException()
        {
            string    clientId    = Guid.NewGuid().ToString("D");
            string    state       = Guid.NewGuid().ToString("D");
            const Uri redirectUri = null;

            IDataProviderFactory sut = CreateSut();

            await sut.AcquireRedditAuthorizationTokenAsync(clientId, state, redirectUri);
        }
        public async Task RenewRedditAccessTokenAsync_WhenRefreshTokenIsWhitespaces_ThrowsArgumentNullException()
        {
            string       clientId     = Guid.NewGuid().ToString("D");
            string       clientSecret = Guid.NewGuid().ToString("D");
            const string refreshToken = "  ";

            IDataProviderFactory sut = CreateSut();

            await sut.RenewRedditAccessTokenAsync(clientId, clientSecret, refreshToken);
        }
Exemplo n.º 10
0
        public OrderItemsViewModel(IDataProviderFactory providerFactory, IServiceManager serviceManager)
        {
            ProviderFactory = providerFactory;

            OrderItemList = new OrderItemListViewModel(ProviderFactory, serviceManager);
            OrderItemList.PropertyChanged += OnListPropertyChanged;

            OrderItemDetails              = new OrderItemDetailsViewModel(ProviderFactory, serviceManager);
            OrderItemDetails.ItemDeleted += OnItemDeleted;
        }
        public async Task RenewRedditAccessTokenAsync_WhenClientSecretIsEmpty_ThrowsArgumentNullException()
        {
            string clientId     = Guid.NewGuid().ToString("D");
            string clientSecret = string.Empty;
            string refreshToken = Guid.NewGuid().ToString("D");

            IDataProviderFactory sut = CreateSut();

            await sut.RenewRedditAccessTokenAsync(clientId, clientSecret, refreshToken);
        }
Exemplo n.º 12
0
        public ProductsViewModel(IDataProviderFactory providerFactory, IServiceManager serviceManager)
        {
            ProviderFactory = providerFactory;

            ProductList = new ProductListViewModel(ProviderFactory, serviceManager);
            ProductList.PropertyChanged += OnListPropertyChanged;

            ProductDetails              = new ProductDetailsViewModel(ProviderFactory, serviceManager);
            ProductDetails.ItemDeleted += OnItemDeleted;
        }
        public async Task RenewRedditAccessTokenAsync_WhenCalled_ThrowsUnauthorizedAccessException()
        {
            string clientId     = Guid.NewGuid().ToString("D");
            string clientSecret = Guid.NewGuid().ToString("D");
            string refreshToken = Guid.NewGuid().ToString("D");

            IDataProviderFactory sut = CreateSut();

            await sut.RenewRedditAccessTokenAsync(clientId, clientSecret, refreshToken);
        }
        public CustomersViewModel(IDataProviderFactory providerFactory, IServiceManager serviceManager)
        {
            ProviderFactory = providerFactory;

            CustomerList = new CustomerListViewModel(ProviderFactory, serviceManager);
            CustomerList.PropertyChanged += OnListPropertyChanged;

            CustomerDetails              = new CustomerDetailsViewModel(ProviderFactory, serviceManager);
            CustomerDetails.ItemDeleted += OnItemDeleted;
            CustomerOrders = new OrderListViewModel(ProviderFactory, serviceManager);
        }
Exemplo n.º 15
0
 public Analysis(IDataProviderFactory providers, Func <AnalysisMember, bool> startFilter, Func <AnalysisMember, bool> conclusionsFilter)
 {
     this.Providers            = providers;
     this.StartFilter          = startFilter;
     this.ConclusionsFilter    = conclusionsFilter;
     this.isAnalysisStarted    = false;
     this.analysisMemberNames  = new Lazy <Dictionary <AnalysisMember, string> >(new Func <Dictionary <AnalysisMember, string> >(this.PopulateAnalysisMemberNames), true);
     this.totalConclusionRules = new Lazy <int>(() => this.Rules.Where(this.ConclusionsFilter).Count <AnalysisMember>(), true);
     this.RootAnalysisMember   = new RootAnalysisMember(this);
     this.progressUpdateLock   = new object();
 }
        public async Task GetRedditAccessTokenAsync_WhenCalled_ThrowsUnauthorizedAccessException()
        {
            string clientId     = Guid.NewGuid().ToString("D");
            string clientSecret = Guid.NewGuid().ToString("D");
            string code         = Guid.NewGuid().ToString("D");
            Uri    redirectUri  = new Uri($"http://localhost/{Guid.NewGuid().ToString("D")}");

            IDataProviderFactory sut = CreateSut();

            await sut.GetRedditAccessTokenAsync(clientId, clientSecret, code, redirectUri);
        }
 public ModelGeneratorFacade(
     ITemplateOutputEngine templateOutputEngine,
     IRenderEngine renderEngine,
     IDataProviderFactory dataProviderFactory,
     ILoggerFactory loggerFactory
     ) : base(loggerFactory)
 {
     _dataProviderFactory  = dataProviderFactory;
     _templateOutputEngine = templateOutputEngine;
     _renderEngine         = renderEngine;
 }
        public async Task GetRedditAccessTokenAsync_WhenClientSecretIsEmpty_ThrowsArgumentNullException()
        {
            string clientId     = Guid.NewGuid().ToString("D");
            string clientSecret = string.Empty;
            string code         = Guid.NewGuid().ToString("D");
            Uri    redirectUri  = new Uri($"http://localhost/{Guid.NewGuid().ToString("D")}");

            IDataProviderFactory sut = CreateSut();

            await sut.GetRedditAccessTokenAsync(clientId, clientSecret, code, redirectUri);
        }
        public async Task GetKnownNsfwSubredditsAsync_WhenCalled_ReturnsSortedKnownNsfwSubreddits()
        {
            IDataProviderFactory sut = CreateSut();

            IEnumerable <IRedditKnownSubreddit> result = await sut.GetKnownNsfwSubredditsAsync();

            for (int i = 1; i < result.Count(); i++)
            {
                Assert.IsTrue(result.ElementAt(i - 1).Rank <= result.ElementAt(i).Rank);
            }
        }
        public async Task GetRedditAccessTokenAsync_WhenRedirectUriIsNull_ThrowsArgumentNullException()
        {
            string    clientId     = Guid.NewGuid().ToString("D");
            string    clientSecret = Guid.NewGuid().ToString("D");
            string    code         = Guid.NewGuid().ToString("D");
            const Uri redirectUri  = null;

            IDataProviderFactory sut = CreateSut();

            await sut.GetRedditAccessTokenAsync(clientId, clientSecret, code, redirectUri);
        }
        public async Task GetKnownNsfwSubredditsAsync_WhenCalled_AssertNextWasCalledOnRandomizerForEachKnownNsfwSubreddit()
        {
            IDataProviderFactory sut = CreateSut();

            await sut.GetKnownNsfwSubredditsAsync();

            _randomizerMock.Verify(m => m.Next(
                                       It.Is <int>(value => value == 0),
                                       It.Is <int>(value => value == 1000)),
                                   Times.Exactly(NumberOfKnownNsfwSubreddits));
        }
Exemplo n.º 22
0
        public static async Task Seed(IUnitOfWork unitOfWork, IDataProviderFactory dataProviderFactory)
        {
            var rateRepository = unitOfWork.GetRepository <Rate>();

            if (rateRepository.GetAll.Any())
            {
                return;
            }

            await PopulateRateData(rateRepository, dataProviderFactory);

            unitOfWork.SaveChanges();
        }
 public GeneratorFacade(
     IContextFactory contextFactory,
     IDataProviderFactory dataProviderFactory,
     IModelGeneratorFacade modelGeneratorFacade,
     IResourceOutputEngine resourceOutputEngine,
     ILoggerFactory loggerFactory
     ) : base(loggerFactory)
 {
     _contextFactory       = contextFactory;
     _dataProviderFactory  = dataProviderFactory;
     _modelGeneratorFacade = modelGeneratorFacade;
     _resourceOutputEngine = resourceOutputEngine;
     Context = _contextFactory.Create();
 }
Exemplo n.º 24
0
        public NewsRepository(IDataProviderFactory dataProviderFactory, IExceptionHandler exceptionHandler)
        {
            if (dataProviderFactory == null)
            {
                throw new ArgumentNullException(nameof(dataProviderFactory));
            }
            if (exceptionHandler == null)
            {
                throw new ArgumentNullException(nameof(exceptionHandler));
            }

            _dataProviderFactory = dataProviderFactory;
            _exceptionHandler    = exceptionHandler;
        }
Exemplo n.º 25
0
        public RedditAccessTokenProviderFactory(IConfiguration configuration, IDataProviderFactory dataProviderFactory)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }
            if (dataProviderFactory == null)
            {
                throw new ArgumentNullException(nameof(dataProviderFactory));
            }

            _configuration       = configuration;
            _dataProviderFactory = dataProviderFactory;
        }
Exemplo n.º 26
0
        public void RegisterDataProviderFactory(IDataProviderFactory factory)
        {
            if (factory == null)
            {
                throw new ArgumentNullException("factory cannot be null");
            }

            if (dataProviders.Exists(o => o == factory))
            {
                throw new ArgumentException("factory has been already registered");
            }

            dataProviders.Add(factory);
        }
Exemplo n.º 27
0
        public async Task InitializeAsync(IDataProviderFactory providerFactory)
        {
            using (var dataProvider = providerFactory.CreateDataProvider())
            {
                CountryCodes = await dataProvider.GetCountryCodesAsync();

                OrderStatus = await dataProvider.GetOrderStatusAsync();

                PaymentTypes = await dataProvider.GetPaymentTypesAsync();

                Shippers = await dataProvider.GetShippersAsync();

                TaxTypes = await dataProvider.GetTaxTypesAsync();
            }
        }
Exemplo n.º 28
0
        public async Task BuildNewsProvidersAsync_WhenCalled_ReturnsNewsProviders()
        {
            IDataProviderFactory sut = CreateSut();

            IEnumerable <INewsProvider> newsProviders = await sut.BuildNewsProvidersAsync();

            Assert.IsNotNull(newsProviders);
            Assert.AreEqual(5, newsProviders.Count());

            AssertNewsProvider(newsProviders.ElementAt(0), "DR", "https://www.dr.dk/nyheder/service/feeds/allenyheder");
            AssertNewsProvider(newsProviders.ElementAt(1), "TV 2 Lorry", "https://www.tv2lorry.dk/rss");
            AssertNewsProvider(newsProviders.ElementAt(2), "Børsen", "https://borsen.dk/rss");
            AssertNewsProvider(newsProviders.ElementAt(3), "Computerworld", "https://www.computerworld.dk/rss/all");
            AssertNewsProvider(newsProviders.ElementAt(4), "Version2", "https://www.version2.dk/it-nyheder/rss");
        }
        public async Task AcquireRedditAuthorizationTokenAsync_WhenStateShouldBeEscaped_ReturnsUriForAcquiringRedditAuthorization()
        {
            string clientId    = Guid.NewGuid().ToString("D");
            string state       = $"{Guid.NewGuid().ToString("D")}&{Guid.NewGuid().ToString("D")}";
            Uri    redirectUri = new Uri($"http://localhost/{Guid.NewGuid().ToString("D")}");

            const string scope       = "identity privatemessages mysubreddits read";
            Uri          expectedUri = new Uri($"https://www.reddit.com/api/v1/authorize?client_id={Uri.EscapeDataString(clientId)}&response_type=code&state={Uri.EscapeDataString(state)}&redirect_uri={redirectUri.AbsoluteUri}&duration=permanent&scope={Uri.EscapeDataString(scope)}");

            IDataProviderFactory sut = CreateSut();

            Uri result = await sut.AcquireRedditAuthorizationTokenAsync(clientId, state, redirectUri);

            Assert.IsNotNull(result);
            Assert.AreEqual(expectedUri.AbsoluteUri, result.AbsoluteUri);
        }
        private async Task GetKnownNsfwSubredditsAsync_WhenCalled_ExpectKnownNsfwSubredditsContainsName(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            IDataProviderFactory sut = CreateSut();

            IEnumerable <IRedditKnownSubreddit> knownNsfwSubreddits = await sut.GetKnownNsfwSubredditsAsync();

            Assert.IsNotNull(knownNsfwSubreddits);
            Assert.AreEqual(NumberOfKnownNsfwSubreddits, knownNsfwSubreddits.Count());

            IRedditKnownSubreddit knownNsfwSubreddit = knownNsfwSubreddits.SingleOrDefault(m => string.Compare(m.Name, name, false) == 0);

            Assert.IsNotNull(knownNsfwSubreddit);
            Assert.IsTrue(knownNsfwSubreddit.Rank >= _minRank && knownNsfwSubreddit.Rank <= _maxRank);
        }
Exemplo n.º 31
0
        public void Configure(
            IApplicationBuilder app,
            IConfiguration configuration,
            IHostingEnvironment hostingEnvironment,
            ILoggerFactory loggerFactory,
            IDataProviderFactory dataProviderFactory,
            IUnitOfWork unitOfWork)
        {
            loggerFactory.AddConsole(configuration.GetSection("Logging"));

            if (hostingEnvironment.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            ApplicationDbInitializer.Seed(unitOfWork, dataProviderFactory).Wait();

            app.ConfigureSwagger();
            app.UseStatusCodePages();
            app.UseMvc();
        }