Ejemplo n.º 1
0
        public async Task CustomProject_DataSearch()
        {
            var bo      = new BuildOutput();
            var monitor = bo.GetProgressMonitor();

            monitor.LogObject(new BuildSessionStartedEvent());
            for (int i = 0; i < 100; i++)
            {
                monitor.Log.WriteLine($"Message {i + 1}");
            }
            monitor.Log.WriteLine("Custom project built");
            monitor.LogObject(new BuildSessionFinishedEvent());

            var nodes      = bo.GetRootNodes(true);
            var dataSource = new BuildOutputDataSource(nodes);
            var search     = new BuildOutputDataSearch(nodes);
            int matches    = 0;
            var visited    = new HashSet <BuildOutputNode> ();

            for (var match = await search.FirstMatch("Message "); match != null; match = search.NextMatch())
            {
                if (visited.Contains(match))
                {
                    break;
                }

                visited.Add(match);
                matches++;
            }

            Assert.That(matches, Is.EqualTo(100));
        }
Ejemplo n.º 2
0
        public async Task CustomProject_SearchCanBeCanceled()
        {
            var bo     = GenerateCustomBuild(10);
            var search = new BuildOutputDataSearch(bo.GetRootNodes(true));

            var searchTask = search.FirstMatch("Message ");

            search.Cancel();

            var firstMatch = await searchTask;

            Assert.Null(firstMatch, "Got a first match, but the canceled search did not expect records");
            Assert.True(search.IsCanceled, "Search was not canceled, but we expect cancel the operation");

            searchTask = search.FirstMatch("Message ");
            firstMatch = await searchTask;
            Assert.NotNull(firstMatch, "No record was found in the search, but one was expected to be found.");
            Assert.False(search.IsCanceled, "Search was canceled for some unexpected reason");
        }
Ejemplo n.º 3
0
        public async Task CustomProject_StressSearchCanBeCanceled()
        {
            BuildOutputNode firstMatch = null;

            var bo = GenerateCustomBuild(10);

            var search = new BuildOutputDataSearch(bo.GetRootNodes(true));

            for (int i = 0; i < 100; i++)
            {
                await Task.WhenAll(Task.Run(async() => firstMatch = await search.FirstMatch("Message ")),
                                   Task.Delay (100).ContinueWith(t => search.Cancel()));

                Assert.True(search.IsCanceled, "Search was not canceled");
            }
        }
Ejemplo n.º 4
0
        public async Task CustomProject_DataSearch()
        {
            var bo = GenerateCustomBuild(1);

            var nodes   = bo.GetRootNodes(true);
            var search  = new BuildOutputDataSearch(nodes);
            int matches = 0;
            var visited = new HashSet <BuildOutputNode> ();

            for (var match = await search.FirstMatch("Message "); match != null; match = search.NextMatch())
            {
                if (visited.Contains(match))
                {
                    break;
                }

                visited.Add(match);
                matches++;
            }

            Assert.That(matches, Is.EqualTo(1000));
        }