public void VerifyInvestorNotNotifiedFirstTimeThresholdCrossedFromOppositeDirectionOfTrigger() { // Arrange var utstock = new StockUnitTestCaseExtension("TestStock", "TEST", 10.00); var uttriggers = new List <Trigger>() { new Trigger() { Type = Models.Enums.TriggerType.Sell, Threshold = 15.00, Direction = Models.Enums.TriggerDirection.FromAbove, Sensitivity = 0.5, ClientNotified = false } }; var utinvestor = new UnitTestInvestor() { InvestorId = 1, Name = "TestInvestor", StockTriggers = new Dictionary <string, List <Trigger> >() }; utinvestor.StockTriggers.Add("TEST", uttriggers); utstock.Attach(utinvestor); //Act utstock.SetPrice(15.50); //Assert Assert.AreEqual(0, utinvestor.NotificationCount); }
public void VerifyNegativeStockPriceNotAllowed() { // Arrange var utstock = new StockUnitTestCaseExtension("TestStock", "TEST", 10.00); // Act => Assert Exception Assert.ThrowsException <InvalidOperationException>(() => utstock.SetPrice(-1.00)); }
public void VerifyPriceChangeIsSet() { // Arrange var utstock = new StockUnitTestCaseExtension("TestStock", "TEST", 10.00); //Act utstock.SetPrice(15.00); //Assert Assert.AreEqual(15.00, utstock.Price); }
public void VerifyInvestorNotifiedWhenThresholdReachedOutsideFromDelta() { // Arrange var utstock = new StockUnitTestCaseExtension("TestStock", "TEST", 20.00); var uttriggers = new List <Trigger>() { new Trigger() { Type = Models.Enums.TriggerType.Sell, Threshold = 15.00, Direction = Models.Enums.TriggerDirection.FromAbove, Sensitivity = 1.00, ClientNotified = false } }; var utinvestor = new UnitTestInvestor() { InvestorId = 1, Name = "TestInvestor", StockTriggers = new Dictionary <string, List <Trigger> >() }; utinvestor.StockTriggers.Add("TEST", uttriggers); utstock.Attach(utinvestor); //Act utstock.SetPrice(15.00); utstock.SetPrice(16.01); utstock.SetPrice(15.00); utstock.SetPrice(13.50); utstock.SetPrice(15.00); //Assert Assert.AreEqual(2, utinvestor.NotificationCount); }
public void VerifyInvestorNotNotifiedWhenOldPriceIsAlreadyBelowThreshold() { // Arrange var utstock = new StockUnitTestCaseExtension("TestStock", "TEST", 10.00); var uttriggers = new List <Trigger>() { new Trigger() { Type = Models.Enums.TriggerType.Buy, Threshold = 8.00, Direction = Models.Enums.TriggerDirection.FromAbove, Sensitivity = 1.00, ClientNotified = false } }; var utinvestor = new UnitTestInvestor() { InvestorId = 1, Name = "TestInvestor", StockTriggers = new Dictionary <string, List <Trigger> >() }; utinvestor.StockTriggers.Add("TEST", uttriggers); utstock.Attach(utinvestor); //Act utstock.SetPrice(8.00); utstock.SetPrice(8.50); utstock.SetPrice(7.75); utstock.SetPrice(7.25); utstock.SetPrice(5.25); //Assert Assert.AreEqual(1, utinvestor.NotificationCount); }