Example #1
0
 public ContractAppService(IContractRepository repo, IContractPartRepository contractPartRepo, IUnitOfWork uow, IPathFinderService pathFinderService)
 {
     _repo             = repo;
     _contractPartRepo = contractPartRepo;
     _uow = uow;
     _pathFinderService = pathFinderService;
 }
Example #2
0
        static void Main(string[] args)
        {
            long attemptsCount = 10;

            mapService = new MapService(100, 3);

            pathFinderService = new DijkstraService(mapService);
            var  result = new ResultEntity();
            long elapsedMilliseconds = 0;

            for (var i = 0; i < attemptsCount; i++)
            {
                var stopwatch = new Stopwatch();
                stopwatch.Start();
                result = pathFinderService.Find(0, mapService.GetMapSize() - 1);
                stopwatch.Stop();

                elapsedMilliseconds += stopwatch.ElapsedMilliseconds;
            }
            result.Print($"DijkstraService: average time of {attemptsCount} iterations [{elapsedMilliseconds / (double)attemptsCount} ms.]");

            pathFinderService   = new FloydService(mapService);
            result              = new ResultEntity();
            elapsedMilliseconds = 0;
            for (var i = 0; i < attemptsCount; i++)
            {
                var stopwatch = new Stopwatch();
                stopwatch.Start();
                result = pathFinderService.Find(0, mapService.GetMapSize() - 1);
                stopwatch.Stop();

                elapsedMilliseconds += stopwatch.ElapsedMilliseconds;
            }
            result.Print($"FloydService: average time of {attemptsCount} iterations [{elapsedMilliseconds / (double)attemptsCount} ms.]");

            pathFinderService   = new FordService(mapService);
            result              = new ResultEntity();
            elapsedMilliseconds = 0;
            for (var i = 0; i < attemptsCount; i++)
            {
                var stopwatch = new Stopwatch();
                stopwatch.Start();
                result = pathFinderService.Find(0, mapService.GetMapSize() - 1);
                stopwatch.Stop();

                elapsedMilliseconds += stopwatch.ElapsedMilliseconds;
            }
            result.Print($"FordService: average time of {attemptsCount} iterations [{elapsedMilliseconds / (double)attemptsCount} ms.]");
        }
Example #3
0
 public MazeService(IPathFinderService pathFinderService, IHttpClientFactory httpClientFactory)
 {
     PathFinderService = pathFinderService;
     HttpClient        = httpClientFactory.CreateClient();
     HttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
 }
 public PathFinderController(IPathFinderService pathFinderService)
 {
     _pathFinderService = pathFinderService;
 }
        public void Setup()
        {
            map = new List <VertexEntity>();
            map.AddRange(new List <VertexEntity>
            {
                new VertexEntity()
                {
                    Number = 0,
                    Paths  = new List <PathEntity>
                    {
                        new PathEntity()
                        {
                            Length       = 1,
                            VertexNumber = 1
                        }
                    }
                },
                new VertexEntity()
                {
                    Number = 1,
                    Paths  = new List <PathEntity>
                    {
                        new PathEntity()
                        {
                            Length       = 1,
                            VertexNumber = 0
                        },
                        new PathEntity()
                        {
                            Length       = 1,
                            VertexNumber = 2
                        }
                    }
                },
                new VertexEntity()
                {
                    Number = 2,
                    Paths  = new List <PathEntity>
                    {
                        new PathEntity()
                        {
                            Length       = 1,
                            VertexNumber = 1
                        },
                        new PathEntity()
                        {
                            Length       = 1,
                            VertexNumber = 3
                        }
                    }
                },
                new VertexEntity()
                {
                    Number = 3,
                    Paths  = new List <PathEntity>
                    {
                        new PathEntity()
                        {
                            Length       = 1,
                            VertexNumber = 2
                        },
                        new PathEntity()
                        {
                            Length       = 1,
                            VertexNumber = 4
                        }
                    }
                },
                new VertexEntity()
                {
                    Number = 4,
                    Paths  = new List <PathEntity>
                    {
                        new PathEntity()
                        {
                            Length       = 1,
                            VertexNumber = 3
                        }
                    }
                }
            });

            _mapService = new Mock <IMapService>();
            _mapService.Setup(mock => mock.GetVertexEntities()).Returns(map);
            _mapService.Setup(mock => mock.GetMapSize()).Returns(map.Count);

            _pathFinderService = new DijkstraService(_mapService.Object);
        }