Ejemplo n.º 1
0
        public async Task Returns_null_when_map_with_same_id_already_exists()
        {
            var repository = new MapRepository(_documentClient, DatabaseId);
            var mapId      = "testmap-" + DateTime.Now.ToString("u");
            var map        = new Map(mapId,
                                     new Node("a"),
                                     new Node("b"));

            map.AddEdge("a", "b", 5);
            var result1 = await repository.Create(map);

            Assert.Equal(map, result1);

            var result2 = await repository.Create(map);

            Assert.Null(result2);
        }
Ejemplo n.º 2
0
        public async Task Can_store_and_retrieve_map()
        {
            var repository = new MapRepository(_documentClient, DatabaseId);
            var mapId      = "testmap-" + DateTime.Now.ToString("u");
            var map        = new Map(mapId,
                                     new Node("a"),
                                     new Node("b"));

            map.AddEdge("a", "b", 5);
            var result1 = await repository.Create(map);

            Assert.Equal(map, result1);

            var result2 = await repository.GetById(mapId);

            Assert.NotNull(result2);
            Assert.Equal(mapId, result2.Id);
            Assert.Contains("a", result2.Nodes.Keys);
            Assert.Contains("b", result2.Nodes.Keys);
            Assert.Equal(5, result2.Nodes["a"].Edges[0].Distance);
        }
Ejemplo n.º 3
0
        public void Create(MapViewModel map)
        {
            Map newMap = _mapper.Map <Map>(map);

            _repository.Create(newMap);
        }