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


C# History.Add方法代码示例

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


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

示例1: TestMaxLength

        public void TestMaxLength()
        {
            var buffer = _testHost.ExportProvider.GetExport<ITextBufferFactoryService>().Value.CreateTextBuffer();
            buffer.Insert(0, "0123456789");
            var snapshot = buffer.CurrentSnapshot;

            var history = new History(maxLength: 0);

            history.Add(new SnapshotSpan(snapshot, new Span(0, 1)));
            Assert.Empty(GetHistoryEntries(history));

            history = new History(maxLength: 1);
            history.Add(new SnapshotSpan(snapshot, new Span(0, 1)));
            Assert.Equal(new[] { "0" }, GetHistoryEntries(history));
            history.Add(new SnapshotSpan(snapshot, new Span(1, 1)));
            Assert.Equal(new[] { "1" }, GetHistoryEntries(history)); // Oldest entry is dropped.

            history = new History(maxLength: 2);
            history.Add(new SnapshotSpan(snapshot, new Span(0, 1)));
            Assert.Equal(new[] { "0" }, GetHistoryEntries(history));
            history.Add(new SnapshotSpan(snapshot, new Span(1, 1)));
            Assert.Equal(new[] { "0", "1" }, GetHistoryEntries(history));
            history.Add(new SnapshotSpan(snapshot, new Span(2, 1)));
            Assert.Equal(new[] { "1", "2" }, GetHistoryEntries(history)); // Oldest entry is dropped.
        }
开发者ID:noahfalk,项目名称:roslyn,代码行数:25,代码来源:HistoryTests.cs

示例2: TestAfter

        public void TestAfter()
        {
            var a = new History ();
            a.Add (new DateTime (2003, 3, 15));
            a.Add (new DateTime (2003, 3, 20));

            var b = a.After (new DateTime (2003, 3, 18));
            Assert.True (b.Count == 2);
            Assert.True (b[0] == new DateTime (2003, 3, 18));
            Assert.True (b[1] == new DateTime (2003, 3, 20));
        }
开发者ID:bvssvni,项目名称:csharp-play,代码行数:11,代码来源:TestHistory.cs

示例3: TestBefore

        public void TestBefore()
        {
            var a = new History ();
            a.Add (new DateTime (2002, 3, 15));
            a.Add (new DateTime (2002, 3, 20));

            var b = a.Before (new DateTime (2002, 3, 18));
            Assert.False (b.Inverted);
            Assert.True (b.Count == 2);
            Assert.True (b[0] == new DateTime (2002, 3, 15));
            Assert.True (b[1] == new DateTime (2002, 3, 18));
        }
开发者ID:bvssvni,项目名称:csharp-play,代码行数:12,代码来源:TestHistory.cs

示例4: TestMain

        public void TestMain()
        {
            var hist = new History<string>(maxCount: 2);

            hist.Add("one");
            hist.Add("two");
            hist.Add("three");

            Assert.IsTrue(hist.Count == 2);
            Assert.IsTrue(hist[0] == "three");
            Assert.IsTrue(hist[1] == "two");
        }
开发者ID:dajuric,项目名称:more-collections,代码行数:12,代码来源:HistoryTests.cs

示例5: TestIntersect

        public void TestIntersect()
        {
            var a = new History ();
            a.Add (new DateTime (2005, 1, 1));
            a.Add (new DateTime (2005, 1, 6));

            var b = new History ();
            b.Add (new DateTime (2005, 1, 5));
            b.Add (new DateTime (2005, 1, 10));

            var c = a * b;
            Assert.True (c.Count == 2);
            Assert.True (c[0] == new DateTime (2005, 1, 5));
            Assert.True (c[1] == new DateTime (2005, 1, 6));
        }
开发者ID:bvssvni,项目名称:csharp-play,代码行数:15,代码来源:TestHistory.cs

示例6: TestInvertedIntersect

        public void TestInvertedIntersect()
        {
            var a = History.AllTime ();
            a.Add (new DateTime (2010, 1, 1));
            a.Add (new DateTime (2010, 1, 10));

            var b = new History ();
            b.Add (new DateTime (2010, 1, 8));
            b.Add (new DateTime (2010, 1, 12));

            var c = History.Intersect (a, b);
            Assert.False (c.Inverted);
            Assert.True (c[0] == new DateTime (2010, 1, 10));
            Assert.True (c[1] == new DateTime (2010, 1, 12));

            var d = History.Intersect (b, a);
            Assert.False (d.Inverted);
            Assert.True (d[0] == new DateTime (2010, 1, 10));
            Assert.True (d[1] == new DateTime (2010, 1, 12));

            b.Inverted = true;
            var e = History.Intersect (a, b);
            Assert.True (e.Inverted);
            Assert.True (e[0] == new DateTime (2010, 1, 1));
            Assert.True (e[1] == new DateTime (2010, 1, 12));
        }
开发者ID:bvssvni,项目名称:csharp-play,代码行数:26,代码来源:TestHistory.cs

示例7: TestSum

 public void TestSum()
 {
     var a = new History ();
     a.Add (new DateTime (2008, 3, 1));
     a.Add (new DateTime (2008, 3, 8));
     var sum = History.Sum (a);
     Assert.True (sum.TotalDays == 7);
 }
开发者ID:bvssvni,项目名称:csharp-play,代码行数:8,代码来源:TestHistory.cs

示例8: TestNormalInfiniteUnion2

        public void TestNormalInfiniteUnion2()
        {
            var a = new History ();
            a.Add (new DateTime (2009, 1, 1));

            var b = new History ();
            b.Add (new DateTime (2009, 1, 2));

            var c = a + b;
            Assert.True (c.Count == 1);
            Assert.True (c[0] == new DateTime (2009, 1, 1));

            var d = b + a;
            Assert.True (d.Count == 1);
            Assert.True (d[0] == new DateTime (2009, 1, 1));
        }
开发者ID:bvssvni,项目名称:csharp-play,代码行数:16,代码来源:TestHistory.cs

示例9: TestNormalInfiniteSubtract2

        public void TestNormalInfiniteSubtract2()
        {
            var a = new History ();
            a.Add (new DateTime (2003, 1, 1));

            var b = new History ();
            b.Add (new DateTime (2003, 1, 5));

            var c = a - b;
            Assert.True (c.Count == 2);
            Assert.True (c[0] == new DateTime (2003, 1, 1));
            Assert.True (c[1] == new DateTime (2003, 1, 5));

            var d = b - a;
            Assert.True (d.Count == 0);
        }
开发者ID:bvssvni,项目名称:csharp-play,代码行数:16,代码来源:TestHistory.cs

示例10: TestNormalInfiniteIntersect2

        public void TestNormalInfiniteIntersect2()
        {
            var a = new History ();
            a.Add (new DateTime (2002, 1, 1));

            var b = new History ();
            b.Add (new DateTime (2002, 1, 10));

            var c = a * b;
            Assert.True (c.Count == 1);
            Assert.True (c[0] == new DateTime (2002, 1, 10));

            var d = b * a;
            Assert.True (d.Count == 1);
            Assert.True (d[0] == new DateTime (2002, 1, 10));
        }
开发者ID:bvssvni,项目名称:csharp-play,代码行数:16,代码来源:TestHistory.cs

示例11: TestNormalInfiniteIntersect

        public void TestNormalInfiniteIntersect()
        {
            var a = new History ();
            a.Add (new DateTime (2009, 1, 1));

            var b = new History ();
            b.Add (new DateTime (2010, 1, 1));
            b.Add (new DateTime (2010, 1, 10));

            var c = a * b;
            Assert.False (c.Inverted);
            Assert.True (c.Count == 2);
            Assert.True (c[0] == new DateTime (2010, 1, 1));
            Assert.True (c[1] == new DateTime (2010, 1, 10));
        }
开发者ID:bvssvni,项目名称:csharp-play,代码行数:15,代码来源:TestHistory.cs

示例12: TestIsSequential

        public void TestIsSequential()
        {
            var a = new History ();
            a.Add (new DateTime (2003, 1, 1));
            a.Add (new DateTime (2002, 12, 18));
            Assert.False (a.IsSequential ());

            var b = new History ();
            b.Add (new DateTime (2002, 12, 18));
            b.Add (new DateTime (2003, 1, 1));
            Assert.True (b.IsSequential ());
        }
开发者ID:bvssvni,项目名称:csharp-play,代码行数:12,代码来源:TestHistory.cs

示例13: TestIsFinite

 public void TestIsFinite()
 {
     var history = new History ();
     history.Add (new DateTime (2002, 1, 1));
     Assert.False (History.IsFinite (history));
     history.Add (new DateTime (2002, 1, 4));
     Assert.True (History.IsFinite (history));
 }
开发者ID:bvssvni,项目名称:csharp-play,代码行数:8,代码来源:TestHistory.cs

示例14: TestIsEmpty

 public void TestIsEmpty()
 {
     var a = new History ();
     Assert.True (History.IsEmpty (a));
     Assert.True (History.IsEmpty (null));
     a.Add (new DateTime (2004, 1, 1));
     Assert.False (History.IsEmpty (a));
 }
开发者ID:bvssvni,项目名称:csharp-play,代码行数:8,代码来源:TestHistory.cs


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