Example #1
0
        [UsedImplicitly]         // by ninject
        public GuiLoader(
            Loader loader,
            CardRepository repo,
            PriceRepository priceRepo,
            NewsService newsService,
            DownloaderSubsystem downloaderSubsystem,
            DeckListModel deckListModel,
            DeckSearcher deckSearcher,
            DeckIndexUpdateSubsystem deckIndexUpdateSubsystem)
        {
            _loader    = loader;
            _repo      = repo;
            _priceRepo = priceRepo;

            _loader.AddTask(newsService.FetchNews);
            _loader.AddTask(token => downloaderSubsystem.CalculateProgress());
            _loader.AddTask(async token =>
            {
                deckListModel.Load();
                if (deckSearcher.IsIndexSaved)
                {
                    deckSearcher.LoadIndexes();
                    await _priceRepo.IsLoadingPriceComplete.Wait(token);
                }
                else
                {
                    await _priceRepo.IsLoadingPriceComplete.Wait(token);
                    deckSearcher.LoadIndexes();
                }

                deckIndexUpdateSubsystem.SubscribeToEvents();
                deckListModel.FillCardNames();
                deckListModel.SubscribeToEvents();
            });
        }
Example #2
0
 public static void Init(TestContext context)
 {
     _mockFileReader = new Mock <IFileReader>();
     _mockFileReader.Setup(m => m.GetLines(It.IsAny <string>())).Returns(new String[] { "Meat=12.56",
                                                                                        "Fruit=5.60" });
     _repository = new PriceRepository(@"c:\temp\prices.txt", _mockFileReader.Object);
 }
Example #3
0
        public async Task LoadSelectedProduct()
        {
            Prices = await PriceRepository.GetProductDetailsAsync(SelectedProduct.Id);

            SelectedProduct.Prices.Clear();
            SelectedProduct.Prices.AddRange(Prices);
        }
        public void Initialize(string username, string[] servers, ILoggerFactory loggerFactory = null, string authToken = null)
        {
            _loggerFactory = loggerFactory ?? new DebugLoggerFactory();
            _log           = _loggerFactory.Create(typeof(ReactiveTrader));
            var concurrencyService = new ConcurrencyService();

            _serviceClientContainer = new WampServiceClientContainer(servers[0], username, concurrencyService, _loggerFactory);

            // TODO: Make the Async Connection better
            _serviceClientContainer.ConnectAsync().Wait();

            var referenceDataServiceClient = new ReferenceDataServiceClient(_serviceClientContainer.Reference, _loggerFactory);
            var executionServiceClient     = new ExecutionServiceClient(_serviceClientContainer.Execution);
            var blotterServiceClient       = new BlotterServiceClient(_serviceClientContainer.Blotter, _loggerFactory);
            var pricingServiceClient       = new PricingServiceClient(_serviceClientContainer.Pricing, _loggerFactory);

            PricingServiceClient = pricingServiceClient;
            PriceLatencyRecorder = new PriceLatencyRecorder();

            var tradeFactory              = new TradeFactory();
            var executionRepository       = new ExecutionRepository(executionServiceClient, tradeFactory, concurrencyService);
            var priceFactory              = new PriceFactory(executionRepository, PriceLatencyRecorder);
            var priceRepository           = new PriceRepository(pricingServiceClient, priceFactory, _loggerFactory);
            var currencyPairUpdateFactory = new CurrencyPairUpdateFactory(priceRepository);

            TradeRepository = new TradeRepository(blotterServiceClient, tradeFactory);
            ReferenceData   = new ReferenceDataRepository(referenceDataServiceClient, currencyPairUpdateFactory);
        }
Example #5
0
 public UnitOfWork(FxContext context)
 {
     _context = context;
     Price    = new PriceRepository(_context);
     Candle   = new CandleRepository(_context);
     Trade    = new TradeRepository(_context);
 }
        private static PriceList GetPriceList(string customerCode)
        {
            var url  = Environment.GetEnvironmentVariable("PriceDbUrl");
            var auth = Environment.GetEnvironmentVariable("PriceDbAuthKey");

            return(PriceRepository.Connect(url, auth).GetPriceList(customerCode));
        }
 /*
  * @description : Constructor class for testing or unit test
  */
 public ProductController(IDbPOS context)
 {
     _db = context;
     productRepository         = new ProductRepository(context);
     productCategoryRepository = new ProductCategoryRepository(context);
     priceRepository           = new PriceRepository(context);
 }
        public void Initialize(string username, string[] servers, ILoggerFactory loggerFactory = null, string authToken = null)
        {
            _loggerFactory      = loggerFactory ?? new DebugLoggerFactory();
            _log                = _loggerFactory.Create(typeof(ReactiveTrader));
            _connectionProvider = new ConnectionProvider(username, servers, _loggerFactory);

            var referenceDataServiceClient = new ReferenceDataServiceClient(_connectionProvider, _loggerFactory);
            var executionServiceClient     = new ExecutionServiceClient(_connectionProvider);
            var blotterServiceClient       = new BlotterServiceClient(_connectionProvider, _loggerFactory);
            var pricingServiceClient       = new PricingServiceClient(_connectionProvider, _loggerFactory);

            if (authToken != null)
            {
                var controlServiceClient = new ControlServiceClient(new AuthTokenProvider(authToken), _connectionProvider, _loggerFactory);
                _controlRepository = new ControlRepository(controlServiceClient);
            }

            PriceLatencyRecorder = new PriceLatencyRecorder();
            var concurrencyService = new ConcurrencyService();

            var tradeFactory              = new TradeFactory();
            var executionRepository       = new ExecutionRepository(executionServiceClient, tradeFactory, concurrencyService);
            var priceFactory              = new PriceFactory(executionRepository, PriceLatencyRecorder);
            var priceRepository           = new PriceRepository(pricingServiceClient, priceFactory, _loggerFactory);
            var currencyPairUpdateFactory = new CurrencyPairUpdateFactory(priceRepository);

            TradeRepository = new TradeRepository(blotterServiceClient, tradeFactory);
            ReferenceData   = new ReferenceDataRepository(referenceDataServiceClient, currencyPairUpdateFactory);
        }
Example #9
0
 public ProductController(ILogger <ProductController> logger, VitecContext context)
 {
     _logger                 = logger;
     _context                = context;
     _productRepository      = new ProductRepository(_connectionString + "/api/products");
     _subscriptionRepository = new SubscriptionRepository(_connectionString + "/api/subscriptions");
     _priceRepository        = new PriceRepository(_connectionString + "/api/prices");
 }
Example #10
0
        public void Collect(DateTime requestDate)
        {
            var allMarkets = MarketRepository.GetMarkets(true);
            var allPrices  = GetAllPrices(allMarkets, requestDate).ToList();
            var newPrices  = GetNewPrices(allPrices).ToList();

            PriceRepository.Save(newPrices);
        }
Example #11
0
        private static async Task Initialize()
        {
            priceDb = new CosmosPriceRepository(EnvHelper.GetEnvironmentVariable("CosmosConnStr"));
            itemDb  = new CosmosItemRepository(EnvHelper.GetEnvironmentVariable("CosmosConnStr"));
            items   = await itemDb.GetAllItemsAsync();

            emailSender = new SendGridEmailService();
        }
Example #12
0
 public async Task <IEnumerable <Price> > GetItemsInStoreByStoreWithNameIdAsync(int storeId, string text, long chainId)
 {
     using (var context = new PriceCompareDbContext())
     {
         var priceRep = new PriceRepository(context);
         return(await priceRep.GetItemsInStoreByStoreWithNameIdAsync(storeId, text, chainId));
     }
 }
Example #13
0
 public async Task <Price> GetItemPriceByCodeAsync(long itemCode)
 {
     using (var context = new PriceCompareDbContext())
     {
         var priceRep = new PriceRepository(context);
         return(await priceRep.GetItemPriceByCodeAsync(itemCode));
     }
 }
Example #14
0
 public async Task <IEnumerable <Price> > GetItemsPricesInStoreSortedAscAsync(int storeId, long chainId)
 {
     using (var context = new PriceCompareDbContext())
     {
         var priceRep = new PriceRepository(context);
         return(await priceRep.GetItemsPricesInStoreSortedAscAsync(storeId, chainId));
     }
 }
        public void GetAllReturnsAListOfPrices()
        {
            IRepository <Product> priceRepository = new PriceRepository();

            var priceList = priceRepository.GetAll();

            Assert.NotNull(priceList);
        }
Example #16
0
        private IEnumerable <Price> GetNewPrices(IEnumerable <Price> allPrices)
        {
            var lastPrices = PriceRepository.GetLastPrices().ToList();

            return(allPrices
                   .Where(i => (lastPrices
                                .Any(l => l.MarketId == i.MarketId && l.Value != i.Value) ||
                                (lastPrices.All(l => l.MarketId != i.MarketId)))).ToList());
        }
        public void UpdateWithExistingPriceReturnsTrue()
        {
            IRepository <Product> priceRepository = new PriceRepository();

            priceRepository.Save(product);
            bool updated = priceRepository.Update(updatedProduct);

            Assert.IsTrue(updated);
        }
        public void Initialize(IObservable <PriceDto> priceStream, ICurrencyPair currencyPair)
        {
            _loggerFactory = new DebugLoggerFactory();
            var pricingServiceClient = new WatchPricingServiceClient(priceStream);
            var priceFactory         = new PriceFactory(new WatchExecutionRepository(), new PriceLatencyRecorder());
            var priceRepository      = new PriceRepository(pricingServiceClient, priceFactory, _loggerFactory);

            PriceStream = priceRepository.GetPriceStream(currencyPair);
        }
        public void SaveAddsPriceToList()
        {
            IRepository <Product> priceRepository = new PriceRepository();

            priceRepository.Save(product);

            var priceList = priceRepository.GetAll();

            Assert.AreEqual(priceList.Count, 1);
        }
Example #20
0
 public UnitOfWork(ArchimedesContext context)
 {
     _context   = context;
     Price      = new PriceRepository(_context);
     Candle     = new CandleRepository(_context);
     Trade      = new TradeRepository(_context);
     Market     = new MarketRepository(_context);
     PriceLevel = new PriceLevelRepository(_context);
     Strategy   = new StrategyRepository(_context);
 }
        public void GetByProductNameWithNonExistentProductNameReturnsNull()
        {
            IRepository <Product> priceRepository = new PriceRepository();

            priceRepository.Save(product);

            var price = priceRepository.GetByProductName("Bananas");

            Assert.IsNull(price);
        }
        public void SaveAddsRightDataToList()
        {
            IRepository <Product> priceRepository = new PriceRepository();

            priceRepository.Save(product);

            var priceList = priceRepository.GetAll();

            Assert.AreEqual(priceList[0].ProductName, "Can of soup");
            Assert.AreEqual(priceList[0].Price, 2.5f);
        }
Example #23
0
        public BrowserAndDatabase(ChromeDriver browser, IJavaScriptExecutor js)
        {
            productRepository       = new ProductRepository();
            priceRepository         = new PriceRepository();
            marketProductRepository = new MarketProductRepository();

            tempProductRepository = new TempProductRepository();

            this.browserFirst = browser;
            this.jsFirst      = js;
        }
Example #24
0
 [UsedImplicitly]         // in GuiLoader
 public DeckIndexUpdateSubsystem(
     DeckSearcher searcher,
     PriceRepository priceRepo,
     DeckListModel listModel,
     IApplication app)
 {
     _searcher  = searcher;
     _priceRepo = priceRepo;
     _listModel = listModel;
     _app       = app;
 }
        public void GetByProductNameWithExistingProductNameReturnsRightPrice()
        {
            IRepository <Product> priceRepository = new PriceRepository();

            priceRepository.Save(product);

            var price = priceRepository.GetByProductName("Can of soup");

            Assert.AreEqual(price.ProductName, "Can of soup");
            Assert.AreEqual(price.Price, 2.5f);
        }
Example #26
0
        public UnitOfWork(VipServicesContext context)
        {
            this.context = context;

            Customers        = new CustomerRepository(this.context);
            Addresses        = new AddressRepository(this.context);
            Limousines       = new LimousineRepository(this.context);
            Locations        = new LocationRepository(this.context);
            Reservations     = new ReservationRepository(this.context);
            Prices           = new PriceRepository(this.context);
            StaffelDiscounts = new StaffelDiscountRepository(this.context);
        }
        public void UpdateWithExistingPriceUpdatesRightData()
        {
            IRepository <Product> priceRepository = new PriceRepository();

            priceRepository.Save(product);
            bool updated   = priceRepository.Update(updatedProduct);
            var  priceList = priceRepository.GetAll();

            Assert.IsTrue(updated);
            Assert.AreEqual(priceList[0].ProductName, "Can of soup");
            Assert.AreEqual(priceList[0].Price, 2.8f);
        }
Example #28
0
        private static void ConfigureDependencies(IServiceCollection services)
        {
            var priceRepository = new PriceRepository();

            services.AddSingleton(CreateEventStore())
            .AddSingleton <IEventBus, EventBus>()
            .AddSingleton <ICommandBus, CommandBus>()
            .AddSingleton <IEventStoreCommandHandler, EventStoreCommandHandler>()
            .AddSingleton <UpdatePricesHandler>()
            .AddSingleton <IPriceSaver>(priceRepository)
            .AddSingleton <IPriceQuery>(priceRepository)
            ;
        }
Example #29
0
        public BrowserAndDatabase(ChromeDriver browserF, IJavaScriptExecutor jsF, ChromeDriver browserS, IJavaScriptExecutor jsS)
        {
            productRepository       = new ProductRepository();
            priceRepository         = new PriceRepository();
            marketProductRepository = new MarketProductRepository();

            tempProductRepository = new TempProductRepository();

            this.browserFirst = browserF;
            this.jsFirst      = jsF;

            this.browserSecond = browserS;
            this.jsSecond      = jsS;
        }
Example #30
0
        public override void Configure(Funq.Container container)
        {
            //Set JSON web services to return idiomatic JSON camelCase properties
            ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;

            var apiClient = new HttpClient { BaseAddress = new Uri("https://api.trafiklab.se") };
            var stationRepository = new StationRepository(apiClient);
            container.Register(stationRepository);

            var priceRepository = new PriceRepository(10, 18);
            var ticketRepository = new TicketRepository(apiClient, "0767201010", priceRepository);
            container.Register(ticketRepository);

            ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
        }
Example #31
0
        public void OneTimeSetup()
        {
            _repo = new CardRepository
            {
                FilterSetCode = F.IsWithin(Sequence.From("ME2", "ICE"), Str.Comparer)
            };

            _repo.LoadFile();
            _repo.Load();

            _priceRepo = new PriceRepository();
            _priceRepo.Load();

            _repo.FillPrices(_priceRepo);
            _transformation = new CollectedCardsDeckTransformation(_repo);
        }
Example #32
0
 public TicketRepository(HttpClient apiClinet, string phonenumber, PriceRepository priceRepository)
 {
     this.ApiClient = apiClinet;
     this.PhoneNumber = phonenumber;
     this.PriceRepository = priceRepository;
 }