public void CanRebalanceWithPositiveOriginalPositionValue() { double newValue = 123456.78; Portfolio orig = new Portfolio { Positions = new ObservableCollection<Position>{ new Position { SecurityIdentifier = "gumballs", Amount = 0.0 } } }; Portfolio recommended = new Portfolio { Positions = new ObservableCollection<Position>{ new Position { SecurityIdentifier = "cherries", Amount = 0.0 } } }; Customer target = new Customer { OriginalPortfolio = orig, RecommendedPortfolio = recommended }; orig.Positions[0].Amount = newValue; Assert.IsTrue(target.CanRebalance(), "checking CanRebalance"); }
public void TotalValueZeroForEmptyPortfolio() { double expectedAmount = 0.0; Portfolio target = new Portfolio(); Assert.AreEqual(expectedAmount, target.TotalValue); }
public void CannotRebalanceWithZeroOriginalPositionValue() { Portfolio orig = new Portfolio{ Positions = new ObservableCollection<Position>{ new Position { SecurityIdentifier = "gumballs", Amount = 0.0 } } }; Portfolio recommended = new Portfolio { Positions = new ObservableCollection<Position>{ new Position { SecurityIdentifier = "cherries", Amount = 0.0 } } }; Customer target = new Customer { OriginalPortfolio = orig, RecommendedPortfolio = recommended }; Assert.IsFalse(target.CanRebalance(), "checking CanRebalance"); }
public void OnePosition_TotalValue() { double expectedAmount = 12345.67; Position pos = new Position { SecurityIdentifier = "foo", Amount = expectedAmount }; Portfolio target = new Portfolio(); target.Positions.Add(pos); Assert.AreEqual(expectedAmount, target.TotalValue); }
public void TwoPositions_TotalValue() { Position posOne = new Position { SecurityIdentifier = "foo", Amount = 12345.67 }; Position posTwo = new Position { SecurityIdentifier = "bar", Amount = 23456.78 }; double expectedAmount = posOne.Amount + posTwo.Amount; Portfolio target = new Portfolio(); target.Positions.Add(posOne); target.Positions.Add(posTwo); Assert.AreEqual(expectedAmount, target.TotalValue); }
public void AddingPositionFiresPropertyChangedEvent() { Position posOne = new Position { SecurityIdentifier = "foo", Amount = 12345.67 }; Position posTwo = new Position { SecurityIdentifier = "bar", Amount = 23456.78 }; Portfolio target = new Portfolio(); target.Positions.Add(posOne); List<string> propertyNames = new List<string>(); target.PropertyChanged += (s, e) => { propertyNames.Add(e.PropertyName); }; target.Positions.Add(posTwo); Assert.AreEqual(1, propertyNames.Count(), "checking propertyNames Count"); Assert.IsTrue(propertyNames.Contains(String.Empty), "checking that propertyNames contains empty string"); }
public Customer() { FirstName = "Joe"; LastName = "Schmoe"; OriginalPortfolio = new Portfolio { Positions = new ObservableCollection<Position> { new Position { SecurityIdentifier = "CASH", Amount = 100000.00 } } }; RecommendedPortfolio = new Portfolio { Positions = new ObservableCollection<Position> { new Position { SecurityIdentifier = "247109BR", Issuer = "DELMARVA POWER AND LIGHT", Coupon="4.00", Maturity="06/01/2042", Amount=20000.00 }, new Position { SecurityIdentifier = "369550AT", Issuer = "GENERAL DYNAMICS CORP", Coupon="3.60", Maturity="11/15/2042", Amount=20000.00 }, new Position { SecurityIdentifier = "61746BCY", Issuer = "MORGAN STANLEY DEAN WITTER", Coupon="5.75", Maturity="11/15/2038", Amount=20000.00 }, new Position { SecurityIdentifier = "927804FG", Issuer = "VIRGINIA ELECTRIC POWER", Coupon="8.875", Maturity="11/15/2038", Amount=20000.00 }, new Position { SecurityIdentifier = "931142CM", Issuer = "WAL-MART STORES", Coupon="6.20", Maturity="04/30/2038", Amount=20000.00 } } }; }
public void RebalancingWithOneRecommendedPosition() { double newValue = 123456.78; Portfolio orig = new Portfolio { Positions = new ObservableCollection<Position>{ new Position { SecurityIdentifier = "gumballs", Amount = 0.0 } } }; Portfolio recommended = new Portfolio { Positions = new ObservableCollection<Position>{ new Position { SecurityIdentifier = "cherries", Amount = 0.0 } } }; Customer target = new Customer { OriginalPortfolio = orig, RecommendedPortfolio = recommended }; orig.Positions[0].Amount = newValue; Assert.IsTrue(target.CanRebalance(), "checking CanRebalance"); target.DoRebalance(); Assert.AreEqual(newValue, target.RecommendedPortfolio.TotalValue, "checking recommended total value"); Assert.AreEqual(newValue, target.RecommendedPortfolio.Positions[0].Amount, "checking recommended position 0 amount"); }
public void ChangingPositionAmountInOldCollectionDoesNotFirePropertyChangedEvent() { Position posOne = new Position { SecurityIdentifier = "foo", Amount = 12345.67 }; Position posTwo = new Position { SecurityIdentifier = "bar", Amount = 23456.78 }; Position posThree = new Position { SecurityIdentifier = "bletch", Amount = 34567.89 }; ObservableCollection<Position> origPositions = new ObservableCollection<Position>{ posOne, posTwo }; ObservableCollection<Position> newPositions = new ObservableCollection<Position> { posThree }; Portfolio target = new Portfolio { Positions = origPositions }; target.Positions = newPositions; List<string> propertyNames = new List<string>(); target.PropertyChanged += (s, e) => { propertyNames.Add(e.PropertyName); }; posOne.Amount = 45678.90; Assert.AreEqual(0, propertyNames.Count(), "checking propertyNames Count"); }
public void ChangingRemovedPositionDoesNotFirePropertyChangedEvent() { Position posOne = new Position { SecurityIdentifier = "foo", Amount = 12345.67 }; Position posTwo = new Position { SecurityIdentifier = "bar", Amount = 23456.78 }; Portfolio target = new Portfolio(); target.Positions.Add(posOne); target.Positions.Add(posTwo); target.Positions.Remove(posTwo); List<string> propertyNames = new List<string>(); target.PropertyChanged += (s, e) => { propertyNames.Add(e.PropertyName); }; posTwo.Amount = 34567.89; Assert.AreEqual(0, propertyNames.Count(), "checking propertyNames Count"); }
public void ReplacingPositionsCollectionFiresPropertyChangedEvent() { Position posOne = new Position { SecurityIdentifier = "foo", Amount = 12345.67 }; Position posTwo = new Position { SecurityIdentifier = "bar", Amount = 23456.78 }; Position posThree = new Position { SecurityIdentifier = "bletch", Amount = 34567.89 }; ObservableCollection<Position> origPositions = new ObservableCollection<Position>{ posOne, posTwo }; ObservableCollection<Position> newPositions = new ObservableCollection<Position> { posThree }; Portfolio target = new Portfolio { Positions = origPositions }; List<string> propertyNames = new List<string>(); target.PropertyChanged += (s, e) => { propertyNames.Add(e.PropertyName); }; target.Positions = newPositions; Assert.AreEqual(1, propertyNames.Count(), "checking propertyNames Count"); Assert.IsTrue(propertyNames.Contains(String.Empty), "checking that propertyNames contains String.Empty"); }
public Customer() { FirstName = "Joe"; LastName = "Schmoe"; OriginalPortfolio = new Portfolio { Positions = new ObservableCollection <Position> { new Position { SecurityIdentifier = "CASH", Amount = 100000.00 } } }; RecommendedPortfolio = new Portfolio { Positions = new ObservableCollection <Position> { new Position { SecurityIdentifier = "247109BR", Issuer = "DELMARVA POWER AND LIGHT", Coupon = "4.00", Maturity = "06/01/2042", Amount = 20000.00 }, new Position { SecurityIdentifier = "369550AT", Issuer = "GENERAL DYNAMICS CORP", Coupon = "3.60", Maturity = "11/15/2042", Amount = 20000.00 }, new Position { SecurityIdentifier = "61746BCY", Issuer = "MORGAN STANLEY DEAN WITTER", Coupon = "5.75", Maturity = "11/15/2038", Amount = 20000.00 }, new Position { SecurityIdentifier = "927804FG", Issuer = "VIRGINIA ELECTRIC POWER", Coupon = "8.875", Maturity = "11/15/2038", Amount = 20000.00 }, new Position { SecurityIdentifier = "931142CM", Issuer = "WAL-MART STORES", Coupon = "6.20", Maturity = "04/30/2038", Amount = 20000.00 } } }; }