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


C# TestScheduler.AdvanceByMilliSeconds方法代码示例

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


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

示例1: SkipFirstLine

        public void SkipFirstLine()
        {
            var firstLine = "This is the first line";
            var secondLine = "This is the second line";
            var startPosition = (firstLine + Environment.NewLine).Length;

            FileNotification result = null;

            var scheduler = new TestScheduler();

            using (var file = new TestFile())
            using (file.Info
                .WatchFile(scheduler: scheduler)
                .ScanFrom(startPosition, scheduler: scheduler)
                .Subscribe(x => result = x))
            {

                file.Append(firstLine);
                file.Append(secondLine);

                scheduler.AdvanceByMilliSeconds(1000);

                var lines = File.ReadAllLines(result.FullName).ToArray();
                lines.Should().HaveCount(1);
                lines.Single().Should().Be(secondLine);
            }
        }
开发者ID:mgnslndh,项目名称:TailBlazer,代码行数:27,代码来源:StartFromFixture.cs

示例2: WillCheckPreviousPage

        public void WillCheckPreviousPage()
        {
            var scheduler = new TestScheduler();

            using (var file = new TestFile())
            {
                file.Append(Enumerable.Range(1, 20).Select(i => i.ToString()).ToArray());

                ILineProvider lineProvider = null;

                using (file.Info.Index(scheduler).Exclude(str => str.Contains("9")).Subscribe(x => lineProvider = x))
                {
                    scheduler.AdvanceByMilliSeconds(250);
                    lineProvider.Count.Should().Be(20);

                    var lines = lineProvider.ReadLines(new ScrollRequest(10)).AsArray();
                    lines.Count().Should().Be(9);

                    var expected = Enumerable.Range(1, 20)
                        .Select(i => i.ToString())
                        .Where(str => !str.Contains("9"))
                        .Reverse()
                        .Take(10);

                    //slines.Select(line => line.Text).Should().BeEquivalentTo(expected);
                }
            }
        }
开发者ID:RolandPheasant,项目名称:TailBlazer,代码行数:28,代码来源:ExlusionFilterFixture.cs

示例3: CanStreamFile

        public void CanStreamFile()
        {
            var file = Path.GetTempFileName();
            var info = new FileInfo(file);
            int[] result=new int[0];
            var scheduler = new TestScheduler();

            File.AppendAllLines(file, Enumerable.Range(1, 100).Select(i => $"{i}").ToArray());

            using (info.WatchFile(TimeSpan.FromMilliseconds(1), scheduler).Index().Subscribe(x => result = x.Lines.Select((_,idx)=>idx+1).ToArray()))
            {
                scheduler.AdvanceByMilliSeconds(1);
                result.ShouldAllBeEquivalentTo(Enumerable.Range(1, 100));

                File.AppendAllLines(file, Enumerable.Range(101, 10).Select(i => $"{i}"));
                scheduler.AdvanceByMilliSeconds(1);
                File.Delete(file);
                result.ShouldAllBeEquivalentTo(Enumerable.Range(1, 110));

            }
        }
开发者ID:WELL-E,项目名称:TailBlazer,代码行数:21,代码来源:FileScanFixture.cs

示例4: AutoTail

        public void AutoTail()
        {
            var scheduler  = new TestScheduler();
            var textMatch = Observable.Return(FileSearchResult.None);
            var autoTailer = Observable.Return(new ScrollRequest(10));

            using (var file = new TestFile())
            {
                file.Append( Enumerable.Range(1, 100).Select(i => i.ToString()).ToArray());

                using (var tailer = new FileTailer(file.Info, textMatch, autoTailer, new NullLogger(), scheduler))
                {
                    scheduler.AdvanceByMilliSeconds(250);
                    tailer.Lines.Items.Select(l => l.Number).ShouldAllBeEquivalentTo(Enumerable.Range(91, 10));
                    file.Append( Enumerable.Range(101, 10).Select(i => i.ToString()));

                    scheduler.AdvanceByMilliSeconds(250);
                    tailer.Lines.Items.Select(l => l.Number).ShouldAllBeEquivalentTo(Enumerable.Range(101, 10));
                }
            }
        }
开发者ID:ivanatpr,项目名称:TailBlazer,代码行数:21,代码来源:FileTailerFixture.cs

示例5: EmptyForEmptyFile

        public void EmptyForEmptyFile()
        {
            FileNotification result = null;

            var scheduler = new TestScheduler();

            using (var file = new TestFile())

            using (file.Info
                .WatchFile(scheduler: scheduler)
                .ScanFrom(0, scheduler: scheduler)
                .Subscribe(x => result = x))
            {
                scheduler.AdvanceByMilliSeconds(1000);

                var lines = File.ReadAllLines(result.FullName).ToArray();
                lines.Should().HaveCount(0);
            }
        }
开发者ID:mgnslndh,项目名称:TailBlazer,代码行数:19,代码来源:StartFromFixture.cs

示例6: CanStreamFileWithPredicate

        public void CanStreamFileWithPredicate()
        {
            var file = Path.GetTempFileName();
            var info = new FileInfo(file);
            int[] result = new int[0];
            var scheduler = new TestScheduler();
            File.AppendAllLines(file, Enumerable.Range(1, 100).Select(i => $"{i}").ToArray());

            //filter by odd numbers
            using (info.WatchFile(scheduler: scheduler).ScanFile(l=>int.Parse(l) % 2 == 1).Subscribe(x => result = x.MatchingLines.Select(l=>l.Line).ToArray()))
            {
                result.ShouldAllBeEquivalentTo(Enumerable.Range(1, 100).Where(i=>i % 2 == 1));

                File.AppendAllLines(file, Enumerable.Range(101, 10).Select(i => $"{i}"));

                scheduler.AdvanceByMilliSeconds(250);
                File.Delete(file);
                result.ShouldAllBeEquivalentTo(Enumerable.Range(1, 110).Where(i => i % 2 == 1));
            }
        }
开发者ID:ButchersBoy,项目名称:TailBlazer,代码行数:20,代码来源:FileScanFixture.cs

示例7: EmptyFile

        public void EmptyFile()
        {
            var pulse = new Subject<Unit>();
            var scheduler = new TestScheduler();
            using (var file = new TestFile())
            {
                FileSearchResult fileSearchResult = null;

                using (file.Info
                    .Search(str => str.Contains("9"), scheduler)
                    .Subscribe(x => fileSearchResult = x))
                {
                    scheduler.AdvanceByMilliSeconds(250);
                    pulse.Once();
                    fileSearchResult.Segments.Should().Be(1);
                    fileSearchResult.SegmentsCompleted.Should().Be(0);
                    fileSearchResult.IsSearching.Should().Be(false);
                    fileSearchResult.Count.Should().Be(0);
                }
            }
        }
开发者ID:ItsJustSean,项目名称:TailBlazer,代码行数:21,代码来源:FileSearchFixture.cs

示例8: AutoTail

        public void AutoTail()
        {
            var file = Path.GetTempFileName();
            var info = new FileInfo(file);
            var scheduler  = new TestScheduler();
            var textMatch = Observable.Return((string)null);
            var autoTailer = Observable.Return(new ScrollRequest(10));

            File.AppendAllLines(file, Enumerable.Range(1, 100).Select(i =>i.ToString()).ToArray());

            using (var tailer = new FileTailer(info, textMatch, autoTailer,scheduler))
            {

                tailer.Lines.Items.Select(l => l.Number).ShouldAllBeEquivalentTo(Enumerable.Range(91, 10));
                File.AppendAllLines(file, Enumerable.Range(101, 10).Select(i => i.ToString()));

                scheduler.AdvanceByMilliSeconds(250);
                File.Delete(file);
                tailer.Lines.Items.Select(l => l.Number).ShouldAllBeEquivalentTo(Enumerable.Range(101, 10));
            }
        }
开发者ID:ButchersBoy,项目名称:TailBlazer,代码行数:21,代码来源:FileTailerFixture.cs

示例9: StartAfterEndOfFileShouldReturnNothing

        public void StartAfterEndOfFileShouldReturnNothing()
        {
            FileNotification result = null;

            var scheduler = new TestScheduler();

            using (var file = new TestFile())

            using (file.Info
                .WatchFile(scheduler: scheduler)
                .ScanFrom(10000, scheduler: scheduler)
                .Subscribe(x => result = x))
            {
                file.Append("A");
                file.Append("B");
                file.Append("C");
                scheduler.AdvanceByMilliSeconds(1000);

                var lines = File.ReadAllLines(result.FullName).ToArray();
                lines.Should().HaveCount(0);
            }
        }
开发者ID:mgnslndh,项目名称:TailBlazer,代码行数:22,代码来源:StartFromFixture.cs

示例10: InitiallyEmptyThenLinesAdded

        public void InitiallyEmptyThenLinesAdded()
        {
            var scheduler = new TestScheduler();

            using (var file = new TestFile())
            {
                FileSearchResult fileSearchResult = null;
                
                using (file.Info.WatchFile(scheduler:scheduler)
                    .Search(str => str.Contains("9"))
                    .Subscribe(x => fileSearchResult = x))
                {
                    scheduler.AdvanceBy(1);
                    file.Append(Enumerable.Range(1, 100).Select(i => i.ToString()).ToArray());
                    scheduler.AdvanceByMilliSeconds(250);
                    fileSearchResult.Matches.Length.Should().Be(19);
                }
            }
        }
开发者ID:ItsJustSean,项目名称:TailBlazer,代码行数:19,代码来源:FileSearchFixture.cs

示例11: AutoTailWithFilter

        public void AutoTailWithFilter()
        {
            var file = Path.GetTempFileName();
            var info = new FileInfo(file);
            var scheduler = new TestScheduler();
            var textMatch = Observable.Return((string)"1");
            var autoTailer = Observable.Return(new ScrollRequest(10));

            File.AppendAllLines(file, Enumerable.Range(1, 100).Select(i => i.ToString()).ToArray());

            using (var tailer = new FileTailer(info, textMatch, autoTailer, scheduler))
            {

                //lines which contain "1"
                var expectedLines = Enumerable.Range(1, 100)
                    .Select(i => i.ToString())
                    .Where(s => s.Contains("1"))
                    .Reverse()
                    .Take(10)
                    .Reverse()
                    .Select(int.Parse)
                    .ToArray();

                tailer.Lines.Items.Select(l => l.Number).ShouldAllBeEquivalentTo(expectedLines);

                File.AppendAllLines(file, Enumerable.Range(101, 10).Select(i => i.ToString()));

                //lines which contain "1"
                expectedLines = Enumerable.Range(1, 110)
                    .Select(i => i.ToString())
                    .Where(s => s.Contains("1"))
                    .Reverse()
                    .Take(10)
                    .Reverse()
                    .Select(int.Parse)
                    .ToArray();

                scheduler.AdvanceByMilliSeconds(250);
                File.Delete(file);
                tailer.Lines.Items.Select(l => l.Number).ShouldAllBeEquivalentTo(expectedLines);
            }
        }
开发者ID:ButchersBoy,项目名称:TailBlazer,代码行数:42,代码来源:FileTailerFixture.cs


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