public void CanSaveAndLoad()
        {
            IStockRepository repository = new MemoryStockRepository();

            repository.SaveStock(yhoo);
            long  id     = yhoo.Id;
            Stock loaded = repository.LoadStock(id);

            Assert.AreEqual(yhoo, loaded);
        }
        public void CanSaveAfterChangeWithoutError()
        {
            IStockRepository repository = new MemoryStockRepository();

            repository.SaveStock(yhoo);
            yhoo.NumShares = 120;
            repository.SaveStock(yhoo);
            Stock loaded = repository.LoadStock(yhoo.Id);

            Assert.AreEqual(120, loaded.NumShares);
        }
        public void FindNextId()
        {
            IStockRepository repository = new MemoryStockRepository();
            long             id1        = repository.NextId();

            Assert.IsTrue(id1 != 0);
            long id2 = repository.NextId();

            Assert.IsTrue(id2 != 0);
            Assert.IsTrue(id2 != id1);
        }
        public void CanClearRepository()
        {
            IStockRepository repository = new MemoryStockRepository();

            repository.SaveStock(yhoo);
            repository.SaveStock(hp);
            repository.Clear();
            ICollection stocks;

            stocks = repository.FindAllStocks();
            Assert.AreEqual(0, stocks.Count);
        }