Ejemplo n.º 1
0
        public void Constructor_NullFilePath_TrowArgumentNullException()
        {
            //Arrange
            string fileName = null;

            //Act
            var descriptor = new SourceDescriptor(fileName);

            //Asert
        }
Ejemplo n.º 2
0
        public void Constructor_UseFileNameConventionAndOtherDirectoryLevel_SetMarketAndCompany()
        {
            //Arrange
            var market = "";
            var company = "";
            var fileName = String.Format("SomeDirectory\\{0}_{1}.csv", market, company);

            //Act
            var descriptor = new SourceDescriptor(fileName);

            //Asert
            Assert.AreEqual(market, descriptor.Market);
            Assert.AreEqual(company, descriptor.Company);
        }
Ejemplo n.º 3
0
 public void Start(SourceDescriptor descriptor)
 {
     try
     {
         foreach (var stockQuote in _stockQuotesReader.Read(descriptor))
         {
             _stockQuotesSubcject.OnNext(stockQuote);
         }
         _stockQuotesSubcject.OnCompleted();
     }
     catch (Exception ex)
     {
         _logger.Error(ex);
         _stockQuotesSubcject.OnError(ex);
     }
 }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            BasicConfigurator.Configure();

            var directory = "Files";

            foreach (var filePath in Directory.EnumerateFiles(directory))
            {
                var descriptor = new SourceDescriptor(filePath);
                var reader = new SourceReader();
                var delay = 10;
                var inputSource = new StockQuotesStream(reader);
                var rocIndex = new RocIndex(delay);

                inputSource.Inputs.Subscribe(rocIndex);
                var pocket = new Pocket(inputSource.Inputs.Skip(delay), rocIndex.Values.Select(x => x > 0 ? true : false), 1000);

                decimal finalValue = 0;
                pocket.Money.Subscribe(Console.WriteLine);

                inputSource.Start(descriptor);
                Console.WriteLine(String.Format("{0}: {1}", Path.GetFileName(filePath), finalValue));
            }
        }