Exemple #1
0
        /// <summary>
        /// Get the surrounding locations based on a strength radius
        /// </summary>
        /// <param name="strength">number of places to go out</param>
        /// <returns>list of valid surrounding locations</returns>
        public IEnumerable <ILocation> GetSurroundings(int strength)
        {
            var radiusLocations = new List <ILocation>();

            //If we don't have any paths out what can we even do
            if (Pathways.Count() == 0)
            {
                return(radiusLocations);
            }

            var currentRadius   = 0;
            var currentPathsSet = Pathways.EntitiesContained();

            while (currentRadius <= strength && currentPathsSet.Count() > 0)
            {
                var currentLocsSet = currentPathsSet.Select(path => path.ToLocation);

                if (currentLocsSet.Count() == 0)
                {
                    break;
                }

                radiusLocations.AddRange(currentLocsSet);
                currentPathsSet = currentLocsSet.SelectMany(ro => ro.Pathways.EntitiesContained());

                currentRadius++;
            }

            return(radiusLocations);
        }
Exemple #2
0
        public async void GetAllPathways_returns_all_pathways()
        {
            MockPathwaysConfigurationManager.Setup(m => m.UseLivePathways).Returns(false);
            _pathwayRepository = new PathwayRepository(GraphRepository, MockPathwaysConfigurationManager.Object);

            var res = await _pathwayRepository.GetAllPathways();

            Assert.AreEqual(res.Count(), Pathways.Count());
        }
Exemple #3
0
        public async void GetAllPathways_when_only_using_live_returns_only_live_pathways()
        {
            MockPathwaysConfigurationManager.Setup(m => m.UseLivePathways).Returns(true);
            _pathwayRepository = new PathwayRepository(GraphRepository, MockPathwaysConfigurationManager.Object);

            var liveOnlyPathways = PathwaysConfigurationManager.GetLivePathwaysElements().Select(e => e.Title);

            var res = await _pathwayRepository.GetAllPathways();

            Assert.AreEqual(res.Count(), Pathways.Count(p => liveOnlyPathways.Contains(p.Title)));
        }