public void ParsesCsvDataWithCamelCaseHeader()
            {
                // Setup Test Data
                var dataWithCamelCaseHeaders =
                    "Symbol,Name,LastSale,MarketCap,ADR TSO,IPOyear,Sector,Industry,Summary Quote" + Environment.NewLine
                    + "FLWS,\"1-800 FLOWERS.COM, Inc.\",4.64,300378353,n/a,1999,Consumer Services,Other Specialty Stores,http://www.nasdaq.com/symbol/flws" + Environment.NewLine
                    + "FCTY,\"1st Century Bancshares, Inc.\",5.3,48325272.8,n/a,n/a,Finance,Major Banks,http://www.nasdaq.com/symbol/fcty" + Environment.NewLine
                    + "FCCY,1st Constitution Bancorp (NJ),8.9899,53297727.91,n/a,n/a,Finance,Savings Institutions,http://www.nasdaq.com/symbol/fccy" + Environment.NewLine;

                // Setup expected results
                var expected = new List<Stock>
                    {
                        new Stock { Ticker = "FLWS", CompanyName = "1-800 FLOWERS.COM Inc." },
                        new Stock { Ticker = "FCTY", CompanyName = "1st Century Bancshares Inc." },
                        new Stock { Ticker = "FCCY", CompanyName = "1st Constitution Bancorp (NJ)" }
                    };

                // Setup target
                var target = new StockListCsvParser("Symbol", "Name");

                // Execute
                var actual = target.ParseCsvData(dataWithCamelCaseHeaders);

                // Verify: Actual results exactly match expected results.
                Assert.AreEqual(expected.Count, actual.Count);                        // Verify # of elements
                for (var index = 0; index < actual.Count; index++)
                {
                    var expectedElement = expected[index];
                    var actualElement = actual[index];

                    Assert.AreEqual(expectedElement.Ticker, actualElement.Ticker);              // Verify ticker symbol
                    Assert.AreEqual(expectedElement.CompanyName, actualElement.CompanyName);    // Verify company name.
                    Assert.False(actualElement.IsExcluded);                                     // Verify excluded flag is not initialized.
                    Assert.AreEqual(0, actualElement.Id);                                       // Verify ID # is not initialized.
                }
            }
        /// <summary>   
        /// Configures the Structure Map object factory.
        /// </summary>
        private void ConfigureStructureMap()
        {
            ObjectFactory.Configure(cfg => cfg.For<ISessionFactory>().Use(this.sessionFactory));

            // Stock data repositories.
            ObjectFactory.Configure(cfg => cfg.For<IReadOnlyRepository<Stock>>().Use<NHibernateReadOnlyRepository<Stock>>());
            ObjectFactory.Configure(cfg => cfg.For<IRepository<Stock>>().Use<NHibernateRepository<Stock>>());
            ObjectFactory.Configure(cfg => cfg.For<IReadOnlyStockRepository>().Use<ReadOnlyStockRepository>());
            ObjectFactory.Configure(cfg => cfg.For<IStockRepository>().Use<StockRepository>());

            // Stock data fetchers
            var stockListCvsParser = new StockListCsvParser("Symbol", "Name");
            ObjectFactory.Configure(cfg => cfg.For<IStockListCsvParser>().Use(stockListCvsParser));
            ObjectFactory.Configure(cfg => cfg.For<IStockListCsvDownloader>().Use<NasdaqDotComCsvDownloader>());
            ObjectFactory.Configure(cfg => cfg.For<IStockListFetcher>().Use<CsvStockListFetcher>());
        }
            public void ThrowsDataFetchExceptionForNonCsvData()
            {
                // Setup Test Data
                var nonCsvData =
                    "<!doctype html>" + Environment.NewLine
                    + "<html lang=\"en-us\">" + Environment.NewLine
                    + "<head>" + Environment.NewLine
                    + "<script type=\"text/javascript\"></script" + Environment.NewLine
                    + "</head>"
                    + "<body>"
                    + "<div></div>"
                    + "</body>"
                    + "</html>";

                // Setup target
                var target = new StockListCsvParser("Symbol", "Name");

                // Execute -- should throw exception.
                target.ParseCsvData(nonCsvData);
            }
            public void ThrowsDataFetchExceptionForNoDataRows()
            {
                // Setup Test Data
                var dataWithMissingSymbols =
                    "Symbol,Name,LastSale,MarketCap,ADR TSO,IPOyear,Sector,Industry,Summary Quote" + Environment.NewLine;

                // Setup target
                var target = new StockListCsvParser("Symbol", "Name");

                // Execute -- should throw exception.
                target.ParseCsvData(dataWithMissingSymbols);
            }
            public void ThrowsDataFetchExceptionForMissingSymbolColumn()
            {
                // Setup Test Data
                var dataWithMissingSymbols =
                    "LastSale,MarketCap,ADR TSO,IPOyear,Sector,industry,Name,Summary Quote" + Environment.NewLine
                    + "4.64,300378353,n/a,1999,Consumer Services,Other Specialty Stores,\"1-800 FLOWERS.COM, Inc.\",http://www.nasdaq.com/symbol/flws" + Environment.NewLine
                    + "5.3,48325272.8,n/a,n/a,Finance,Major Banks,\"1st Century Bancshares, Inc.\",http://www.nasdaq.com/symbol/fcty" + Environment.NewLine
                    + "8.9899,53297727.91,n/a,n/a,Finance,Savings Institutions,1st Constitution Bancorp (NJ),http://www.nasdaq.com/symbol/fccy" + Environment.NewLine;

                // Setup target
                var target = new StockListCsvParser("Symbol", "Name");

                // Execute -- should throw exception.
                target.ParseCsvData(dataWithMissingSymbols);
            }
            public void ThrowsDataFetchExceptionForEmptyString()
            {
                // Setup target
                var target = new StockListCsvParser("Symbol", "Name");

                // Execute -- should throw exception.
                target.ParseCsvData(string.Empty);
            }