Beispiel #1
0
        public static WatchedVM GetVM(WatchedSearchResult searchResult)
        {
            var vm = new WatchedVM(searchResult ?? throw new ArgumentNullException(nameof(searchResult)));

            HistoryDb.Add(new HistoryRecord
            {
                Type  = HistoryRecordType.Watched,
                Uri   = vm.SearchResult.SearchUri,
                Title = vm.Keyword,
            });
            Cache[vm.SearchQuery] = vm;
            return(vm);
        }
Beispiel #2
0
        public static FavoritesVM GetVM(FavoritesSearchResult searchResult)
        {
            var vm    = new FavoritesVM(searchResult ?? throw new ArgumentNullException(nameof(searchResult)));
            var query = vm.SearchQuery;

            HistoryDb.Add(new HistoryRecord
            {
                Type  = HistoryRecordType.Favorites,
                Uri   = vm.SearchResult.SearchUri,
                Title = vm.Keyword,
            });
            Cache[query] = vm;
            return(vm);
        }
Beispiel #3
0
        public void TestApplyChangesetNewNodesInNewWay()
        {
            var historyDb = new HistoryDb(new MemoryHistoryDb());

            historyDb.Add(new OsmGeo[] {
                new Node()
                {
                    Id      = 1,
                    Version = 1
                },
                new Node()
                {
                    Id      = 2,
                    Version = 1
                }
            });

            var osmChange = new OsmChange();

            osmChange.Create = new OsmGeo[]
            {
                new Node()
                {
                    Id      = -1,
                    Version = 1
                },
                new Node()
                {
                    Id      = -2,
                    Version = 1
                },
                new Way()
                {
                    Id      = -1,
                    Version = 1,
                    Nodes   = new long[]
                    {
                        1, -1, -2, 2
                    }
                }
            };

            var results = historyDb.ApplyChangeset(1, osmChange);

            Assert.IsNotNull(results);
            Assert.IsNotNull(results.Result);
            Assert.IsNotNull(results.Result.Results);
            Assert.AreEqual(3, results.Result.Results.Length);
            var result = results.Result.Results[0];

            Assert.IsInstanceOf <NodeResult>(result);
            Assert.AreEqual(3, result.NewId);
            Assert.AreEqual(-1, result.OldId);
            Assert.AreEqual(1, result.NewVersion);
            result = results.Result.Results[1];
            Assert.IsInstanceOf <NodeResult>(result);
            Assert.AreEqual(4, result.NewId);
            Assert.AreEqual(-2, result.OldId);
            Assert.AreEqual(1, result.NewVersion);
            result = results.Result.Results[2];
            Assert.IsInstanceOf <WayResult>(result);
            Assert.AreEqual(1, result.NewId);
            Assert.AreEqual(-1, result.OldId);
            Assert.AreEqual(1, result.NewVersion);

            var way = historyDb.Get(OsmGeoType.Way, 1) as Way;

            Assert.IsNotNull(way);
            Assert.IsNotNull(way.Nodes);
            Assert.AreEqual(4, way.Nodes.Length);
            Assert.AreEqual(1, way.Nodes[0]);
            Assert.AreEqual(3, way.Nodes[1]);
            Assert.AreEqual(4, way.Nodes[2]);
            Assert.AreEqual(2, way.Nodes[3]);
        }