コード例 #1
0
        public void Can_go_next()
        {
            IWorkItem item1      = new WorkItemMock(1);
            IWorkItem item2      = new WorkItemMock(2);
            IWorkItem item3      = new WorkItemMock(3);
            IWorkItem item4      = new WorkItemMock(4);
            var       repository = new ItemRepositoryMock(new List <IWorkItem> {
                item1, item2, item3, item4
            });

            IWorkList wl = new MemoryQueryWorkList(repository, "work list");

            wl.GoNext();
            Assert.AreEqual(item1, wl.Current);
            Assert.True(wl.Current?.Visited);

            wl.GoNext();
            Assert.AreEqual(item2, wl.Current);
            Assert.True(wl.Current?.Visited);

            wl.GoNext();
            Assert.AreEqual(item3, wl.Current);
            Assert.True(wl.Current?.Visited);

            wl.GoNext();
            Assert.AreEqual(item4, wl.Current);
            Assert.True(wl.Current?.Visited);

            // end of work list, current item is the same as before
            wl.GoNext();
            Assert.AreEqual(item4, wl.Current);
            Assert.True(wl.Current?.Visited);
        }
コード例 #2
0
        public void Cannot_go_first_again_if_first_item_is_set_done()
        {
            IWorkItem item1      = new WorkItemMock(1);
            IWorkItem item2      = new WorkItemMock(2);
            IWorkItem item3      = new WorkItemMock(3);
            IWorkItem item4      = new WorkItemMock(4);
            var       repository = new ItemRepositoryMock(new List <IWorkItem> {
                item1, item2, item3, item4
            });

            IWorkList wl = new MemoryQueryWorkList(repository, "work list");

            wl.GoFirst();
            Assert.AreEqual(item1, wl.Current);
            Assert.True(wl.Current?.Visited);

            wl.GoNext();
            Assert.AreEqual(item2, wl.Current);
            Assert.True(wl.Current?.Visited);

            wl.GoFirst();
            Assert.AreEqual(item1, wl.Current);
            Assert.True(wl.Current?.Visited);

            // set status done and update work list
            wl.Current.Status = WorkItemStatus.Done;
            wl.SetStatus(wl.Current, WorkItemStatus.Done);

            // second item is now the first in work list
            // because first item is set to done and therefor 'not visible'
            wl.GoFirst();
            Assert.AreEqual(item2, wl.Current);
            Assert.True(wl.Current?.Visited);
        }
コード例 #3
0
        public void Can_go_nearest()
        {
            MapPoint pt7  = PolygonConstruction.CreateMapPoint(7, 0, 0);
            MapPoint pt10 = PolygonConstruction.CreateMapPoint(10, 0, 0);
            MapPoint pt15 = PolygonConstruction.CreateMapPoint(15, 0, 0);

            var item7  = new WorkItemMock(7, pt7);
            var item10 = new WorkItemMock(10, pt10);
            var item15 = new WorkItemMock(15, pt15);

            var repository = new ItemRepositoryMock(new[] { item7, item10, item15 });

            IWorkList wl = new MemoryQueryWorkList(repository, nameof(Can_go_nearest));

            Geometry reference = PolygonConstruction.CreateMapPoint(11, 0, 0);

            // go to item10
            Assert.True(wl.CanGoNearest());
            wl.GoNearest(reference);
            Assert.AreEqual(item10, wl.Current);
            Assert.True(wl.Current?.Visited);

            // go to item7
            Assert.True(wl.CanGoNearest());
            Assert.NotNull(wl.Current);
            wl.GoNearest(wl.Current.Extent);
            Assert.AreEqual(item7, wl.Current);
            Assert.True(wl.Current?.Visited);

            // go to item15
            Assert.True(wl.CanGoNearest());
            Assert.NotNull(wl.Current);
            wl.GoNearest(wl.Current.Extent);
            Assert.AreEqual(item15, wl.Current);
            Assert.True(wl.Current?.Visited);

            // Now all are visited, what is the next item? None because there is no
            // more item *after* the last item15.
            // Now we need to go to item *before* the last one.
            Assert.False(wl.CanGoNearest());

            Assert.True(wl.CanGoPrevious());
            wl.GoPrevious();
            Assert.AreEqual(item10, wl.Current);

            // Now we can go nearest again which is item7 (nearst to item10)
            Assert.True(wl.CanGoNearest());
            Assert.NotNull(wl.Current);
            wl.GoNearest(wl.Current.Extent);
            Assert.AreEqual(item7, wl.Current);
            Assert.True(wl.Current?.Visited);
        }
コード例 #4
0
        public void Can_go_previous()
        {
            IWorkItem item1      = new WorkItemMock(1);
            IWorkItem item2      = new WorkItemMock(2);
            IWorkItem item3      = new WorkItemMock(3);
            IWorkItem item4      = new WorkItemMock(4);
            var       repository = new ItemRepositoryMock(new List <IWorkItem> {
                item1, item2, item3, item4
            });

            IWorkList wl = new MemoryQueryWorkList(repository, "work list");

            wl.GoNext();
            Assert.AreEqual(item1, wl.Current);
            Assert.True(wl.Current?.Visited);

            wl.GoNext();
            Assert.AreEqual(item2, wl.Current);
            Assert.True(wl.Current?.Visited);

            wl.GoNext();
            Assert.AreEqual(item3, wl.Current);
            Assert.True(wl.Current?.Visited);

            // go previous
            wl.GoPrevious();
            Assert.AreEqual(item2, wl.Current);
            Assert.True(wl.Current?.Visited);

            // go previous again
            wl.GoPrevious();
            Assert.AreEqual(item1, wl.Current);
            Assert.True(wl.Current?.Visited);

            wl.GoNext();
            Assert.AreEqual(item2, wl.Current);
            Assert.True(wl.Current?.Visited);
        }