当前位置: 首页>>代码示例>>C#>>正文


C# Stock.AddHistoricPrice方法代码示例

本文整理汇总了C#中Stock.AddHistoricPrice方法的典型用法代码示例。如果您正苦于以下问题:C# Stock.AddHistoricPrice方法的具体用法?C# Stock.AddHistoricPrice怎么用?C# Stock.AddHistoricPrice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Stock的用法示例。


在下文中一共展示了Stock.AddHistoricPrice方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddsHistoricPriceWhenPriceIsNew

            public void AddsHistoricPriceWhenPriceIsNew()
            {
                //// SETUP

                // Test Data
                var price1 = new HistoricPrice { Date = DateTime.Parse("1/1/2000") };
                var price2 = new HistoricPrice { Date = DateTime.Parse("1/2/2000") };
                var price3 = new HistoricPrice { Date = DateTime.Parse("1/3/2000") };

                // Setup target
                var target = new Stock { Ticker = "FLWS", CompanyName = "1-800 FLOWERS.COM" };

                // EXECUTE (3 times)
                var actual1 = target.AddHistoricPrice(price1);
                var actual2 = target.AddHistoricPrice(price2);
                var actual3 = target.AddHistoricPrice(price3);

                //// VERIFY

                Assert.AreEqual(3, target.PriceHistory.Count);

                // Price 1
                Assert.True(actual1);
                Assert.True(target.PriceHistory.Contains(price1));
                Assert.AreSame(target, price1.Stock);

                // Price 2
                Assert.True(actual2);
                Assert.True(target.PriceHistory.Contains(price2));
                Assert.AreSame(target, price2.Stock);

                // Price 3
                Assert.True(actual3);
                Assert.True(target.PriceHistory.Contains(price3));
                Assert.AreSame(target, price2.Stock);
            }
开发者ID:TheLogansFerrySoftwareCo,项目名称:LF-Trading-Suite,代码行数:36,代码来源:StockTests.cs

示例2: DoesNotAddHistoricPriceWhenPriceIsPreexisting

            public void DoesNotAddHistoricPriceWhenPriceIsPreexisting()
            {
                //// SETUP

                // Test Data
                var price = new HistoricPrice { Date = DateTime.Parse("1/1/2000") };
                var duplicatePrice = new HistoricPrice { Date = DateTime.Parse("1/1/2000") };

                // Setup target
                var target = new Stock { Ticker = "FLWS", CompanyName = "1-800 FLOWERS.COM" };

                // EXECUTE (twice)
                var initialActual = target.AddHistoricPrice(price);
                var duplicateActual = target.AddHistoricPrice(duplicatePrice);

                //// VERIFY

                Assert.AreEqual(1, target.PriceHistory.Count);

                // Initial (Should have succeeded)
                Assert.True(initialActual);
                Assert.True(target.PriceHistory.Contains(price));
                Assert.AreSame(target, price.Stock);

                // Duplicate (Should have failed)
                Assert.False(duplicateActual);
                Assert.Null(duplicatePrice.Stock);
            }
开发者ID:TheLogansFerrySoftwareCo,项目名称:LF-Trading-Suite,代码行数:28,代码来源:StockTests.cs


注:本文中的Stock.AddHistoricPrice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。