void _liveVwap_PropertyChanged(object sender, PropertyChangedEventArgs e) { // Using Stocktick instead of some custom value just to make it easy // to re-use the point collection converter _vwapTicks.Add(new StockSaleTick() { Price = _liveVwap.CurrentValue, Symbol = "VWAP", Quantity = 0, TimeStamp = DateTime.Now }); NotifyPropertyChanged("VwapTicks"); }
public void AddRange_Always_AddsItemsToEndOfList() { _target.Add(new Person { Age = 20 }); _target.Add(new Person { Age = 20 }); IEnumerable <Person> people = GetPeople(); _target.AddRange(people); Assert.AreEqual(12, _target.Count); var lastTenItemsInList = _target.Skip(2); Assert.IsTrue(people.SequenceEqual(lastTenItemsInList)); }
public void GroupJoin() { Random rand = new Random(); //_standardLinqResults = from outerPerson in _outer.AsEnumerable() // join innerPerson in _inner on outerPerson.Age equals innerPerson.Age into innersMatchingOuterAge // select new Pair<Person, IEnumerable<Person>>(outerPerson, innersMatchingOuterAge); Console.WriteLine("Ready"); Console.ReadLine(); int outerItems = 500; int innerItems = 7000; ContinuousCollection <NotifyingPerson> inner = new ContinuousCollection <NotifyingPerson>(); ContinuousCollection <NotifyingPerson> outer = new ContinuousCollection <NotifyingPerson>(); var clinqResults = from outerNotifyingPerson in outer join innerNotifyingPerson in inner on outerNotifyingPerson.Age equals innerNotifyingPerson.Age into innersMatchingOuterAge //select new KeyValuePair<NotifyingPerson, ReadOnlyContinuousCollection<NotifyingPerson>>(outerNotifyingPerson, innersMatchingOuterAge); select innersMatchingOuterAge; TimeIt(1, () => { //List<NotifyingPerson> innerPeople = new List<NotifyingPerson>(); //for (int i = 0; i < innerItems; i++) //{ // innerPeople.Add(new NotifyingPerson(i.ToString(), i % outerItems)); //} //inner.AddRange(innerPeople); for (int i = 0; i < innerItems; i++) { inner.Add(new NotifyingPerson(i.ToString(), i % outerItems)); } for (int i = 0; i < outerItems; i++) { outer.Add(new NotifyingPerson(i.ToString(), i)); } //for (int i = 0; i < outerItems; i++) //{ // outer.Move(rand.Next(outerItems), rand.Next(outerItems)); //} //for (int i = outerItems - 1; i >= 0; i--) //{ // //if ((rand.Next() & 1) == 0) // if(i % 2 == 0) // { // outer.RemoveAt(i); // } //} //for (int i = 0; i < innerItems; i++) //{ // inner.Move(rand.Next(innerItems), rand.Next(innerItems)); //} //for (int i = innerItems - 1; i >= 0; i--) //{ // if ((rand.Next() & 1) == 0) // { // inner.RemoveAt(i); // } //} }); Console.WriteLine(clinqResults.Count); }
void _simulationTimer_Elapsed(object sender, ElapsedEventArgs e) { double newPrice; double oldPrice; Random rnd = new Random(); double variance = rnd.NextDouble() * 1.50; // stock can change +- 1.50 if (_tickerData.Count > 0) { oldPrice = _tickerData.Last().Price; if (rnd.Next(0, 4) > 1) { newPrice = oldPrice - variance; } else { newPrice = oldPrice + variance; } } else { newPrice = 100; } // Simulation values. StockSaleTick newTick = new StockSaleTick() { Price = newPrice, TimeStamp = DateTime.Now, Symbol = "AAPL", Quantity = rnd.Next(50) + 50 // QTY range: 50-100 }; _tickerData.Add(newTick); newTick = new StockSaleTick() { Price = newPrice, TimeStamp = DateTime.Now, Symbol = "IBM", Quantity = rnd.Next(50) + 50 // QTY range: 50-100 }; _tickerData.Add(newTick); NotifyPropertyChanged("GraphWindowTicks"); StockQuoteTick newQuote = new StockQuoteTick() { Price = newPrice - (newPrice * 0.05), Side = QuoteSide.Bid, Quantity = rnd.Next(50) + 50, Symbol = "AAPL", TimeStamp = DateTime.Now }; _allQuotes.Add(newQuote); _allQuotes.Add(newQuote); newQuote = new StockQuoteTick() { Price = newPrice + (newPrice * 0.05), Side = QuoteSide.Ask, Quantity = rnd.Next(50) + 50, Symbol = "AAPL", TimeStamp = DateTime.Now }; _allQuotes.Add(newQuote); }
public void FilteringViewAdapter_OnAgeGreaterThan30_ReturnsCollectionWithPersonsOlderThan30() { _target = from item in _source where item.Age > 30 select item; Assert.AreEqual(2, _target.Count); Assert.AreEqual("Jordan", _target[0].Name); Assert.AreEqual("Erb", _target[1].Name); _source.Add(new Person("John", 12)); Assert.AreEqual(2, _target.Count); _source.Add(new Person("Tim", 34)); Assert.AreEqual(3, _target.Count); Assert.AreEqual("Tim", _target[2].Name); }