public async Task GenerateUniqueRoute_returns_route_with_no_counter_when_current_route_is_empty_string() { var generator = new RouteGenerator(); var result = await generator.GenerateUniqueRoute(string.Empty, null, "Example thing", Array.Empty <string>(), x => Task.FromResult(0)).ConfigureAwait(false); Assert.Equal("/example-thing", result); }
private void routeGeneratorToolStripMenuItem_Click(object sender, EventArgs e) { if (RouteGenerator == null) { RouteGenerator = new RouteGenerator(Client); } enableControl(RouteGenerator); }
public void Routes_should_match_disregarding_counter(string original, string generated, bool shouldMatch) { var generator = new RouteGenerator(); var result = generator.IsMatchingRoute(original, generated); Assert.Equal(shouldMatch, result); }
public void Increment_adds_1_to_existing_counter_greater_than_9() { var original = "example-10"; var generator = new RouteGenerator(); var result = generator.IncrementRoute(original); Assert.Equal("example-11", result); }
public void Increment_adds_1_where_no_counter() { var original = "example"; var generator = new RouteGenerator(); var result = generator.IncrementRoute(original); Assert.Equal("example-1", result); }
public void Noise_word_removed_from_end() { var original = "somewhere-club"; var generator = new RouteGenerator(); var result = generator.GenerateRoute(string.Empty, original, new[] { "club" }); Assert.Equal("/somewhere", result); }
public void Noise_word_removed_from_middle() { var original = "some-stoolball-friends"; var generator = new RouteGenerator(); var result = generator.GenerateRoute(string.Empty, original, new[] { "stoolball" }); Assert.Equal("/some-friends", result); }
public void Noise_word_removed_from_start() { var original = "stoolball-ladies"; var generator = new RouteGenerator(); var result = generator.GenerateRoute(string.Empty, original, new[] { "stoolball" }); Assert.Equal("/ladies", result); }
public void Punctuation_is_removed() { var original = "example? route's punctuation; good! example."; var generator = new RouteGenerator(); var result = generator.GenerateRoute(string.Empty, original, Array.Empty <string>()); Assert.Equal("/example-routes-punctuation-good-example", result); }
public void Route_is_lowercase() { var original = "MiXeD"; var generator = new RouteGenerator(); var result = generator.GenerateRoute(string.Empty, original, Array.Empty <string>()); Assert.Equal("/mixed", result); }
public void Prefix_is_added() { var prefix = "prefix"; var original = "example"; var generator = new RouteGenerator(); var result = generator.GenerateRoute(prefix, original, Array.Empty <string>()); Assert.Equal("prefix/example", result); }
public BootstrapInstanceController(string name, List <List <Coordinate> > geofences, ushort minLevel, ushort maxLevel, ushort circleSize = 70, bool fastBootstrapMode = false, string groupName = null, bool isEvent = false) { Name = name; MinimumLevel = minLevel; MaximumLevel = maxLevel; FastBootstrapMode = fastBootstrapMode; GroupName = groupName; IsEvent = isEvent; _logger = new Logger <BootstrapInstanceController>(LoggerFactory.Create(x => x.AddConsole())); _geofences = Geofence.FromPolygons(geofences); _routeGenerator = new RouteGenerator(); Coordinates = _routeGenerator.GenerateBootstrapRoute((List <Geofence>)_geofences, circleSize); }
private const decimal Velocity = 0.1m; //pixels in milliseconds static void Main() { var busStops = BusStopGenerator.Generate(Size, BustStopsNumber); var routes = RouteGenerator.Generate(busStops, Size, Velocity, RoutesNumber); var json = JsonSerializer.Serialize(new Root { Width = Size, Height = Size, BusStops = busStops, Routes = routes }, new JsonSerializerOptions{WriteIndented = true}); var path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), $"metadata-{Guid.NewGuid()}.json"); File.AppendAllText(path, json); }
public async Task TestApiRouteGenerator() { try { var client = new TestSite("Core.Api").BuildClient(); var response = await client.GetAsync(Router.DefaultRoute); var content = await response.Content.ReadAsStringAsync(); var routesGenerated = RouteGenerator.GenerateRoutes(content); Assert.IsTrue(routesGenerated.Contains("namespace")); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public static ResponderRoute GetResponderRoute(Coordinate startPoint) { var endPoint = MapPointGenerator.GetPoint(startPoint, routeRadius); var routePoints = RouteGenerator.GetRoute(startPoint, endPoint); var responderRoute = new ResponderRoute(); if (routePoints != null) { foreach (var r in routePoints) { responderRoute.RoutePoints.Add(new RoutePoint { Latitude = r[0], Longitude = r[1] }); } } return(responderRoute); }
public async void Start(Assembly assembly) { Host = Browser.Window.Location.Host; Port = Browser.Window.Location.Port; Scheme = Browser.Window.Location.Protocol; Browser.Window.AddEventListener("popstate", evt => OnPopState(evt.As <PopStateEvent>())); var path = Browser.Window.Location.PathName; Console.WriteLine(path); ControllerFactory = new DefaultControllerFactory(DependencyResolver); var routeGenerator = new RouteGenerator(); routeTree = routeGenerator.GenerateRoutes(assembly); await OnStarting(); await OnStarted(); }
public void Start(Assembly assembly) { Host = Browser.Window.Location.Host; Port = Browser.Window.Location.Port; Scheme = Browser.Window.Location.Protocol; Browser.Window.AddEventListener("popstate", evt => OnPopState(evt.As <PopStateEvent>())); var path = Browser.Window.Location.PathName; Console.WriteLine(path); ControllerFactory = new DefaultControllerFactory(DependencyResolver); var routeGenerator = new RouteGenerator(); routeTree = routeGenerator.GenerateRoutes(assembly); OnStarting(() => { Open(path + (!string.IsNullOrEmpty(Browser.Window.Location.Search) ? "?" + Browser.Window.Location.Search : ""), false, OnStarted); }); }
public ServerBase() { _routeGenerator = new RouteGenerator(); _routeTable = new RouteTable(); _serverContext = new ServerContext(GetType().Assembly, _routeTable); }
public void EnemyControllerUpdate(float deltaTime) { if (alive) { if (conditions.HasActiveConditions) { CheckHealth.Invoke(); conditions.ConditionsUpdateStart(CharacterModel, ref spec, deltaTime); } ///<summary> ///Проверка состояния деятельности врага /// </summary> if (inChase) { enemyView.enabled = false; Chasing.Chase(player, deltaTime); //Debug.Log("Chasing"); } else if (comingHome) { //Debug.Log("ComingHome"); timer += deltaTime; ComingHome.ComingHome(); if (timer > 3f && !enemyView.enabled) { enemyView.enabled = true; } } else if (onPatrol) { Patroling.Patrol(route); } else if (onIdle) { Idle.Idle(); } else if (inFight) { Fight.Fight(player, deltaTime); } else { var choseAct = Random.Range(-patrolChance, idleChance); if (choseAct < 0) { onPatrol = true; route = RouteGenerator.Compile(homePoint, spec.PatrolDistance); patrolChance--; idleChance = 5; } else { onIdle = true; idleChance--; patrolChance = 5; } } } else { Move.Stop(); headMesh.enabled = false; gun.enabled = false; knife.enabled = false; enemyBorder.enabled = false; //выключаем коллайдер rb.constraints = RigidbodyConstraints.FreezeAll; //замораживаем перемещения и повороты Dying.Die(mesh, deltaTime); //запускаем событие смерти } }
private async void RunDemo() { this.Timer.Stop(); PlayButton.IsEnabled = false; PauseButton.IsEnabled = false; StopButton.IsEnabled = false; ClearCars(); this.ViewModel.IsShowingRoutes = false; this.ViewModel.UpdateControls(); var region = this.MyMap.GetVisibleRegion(MapVisibleRegionKind.Near); var pointGenerator = new PointGenerator(); pointGenerator.Boundaries = region; var routeGenerator = new RouteGenerator(pointGenerator); var carModels = new List <string>() { Car.HammerheadRedUri, Car.HammerheadWhiteUri, Car.ShiftBlueUri, Car.ShiftGoldUri, }; int model = 0; SimulatedTraffic.Cars = new List <Car>(); SimulatedTraffic.Routes = await routeGenerator.GenerateRoutes(NumberOfRoutes); foreach (var route in SimulatedTraffic.Routes) { //var car = new PoliceCar(); //var car = new SchoolBus(); var car = new Car(carModels.ElementAt(model++ % carModels.Count)); car.Connect(this.MyMap, route); SimulatedTraffic.Cars.Add(car); } SimulatedTraffic.Trucks = new List <Car>(); SimulatedTraffic.HighwayRoutes = await routeGenerator.GenerateHighwayRoutes(); foreach (var route in SimulatedTraffic.HighwayRoutes) { var truck = new SemiTruck(); truck.Connect(this.MyMap, route); SimulatedTraffic.Trucks.Add(truck); var dumptruck = new DumpTruck(40); dumptruck.Connect(this.MyMap, route); SimulatedTraffic.Trucks.Add(dumptruck); var car = new Car(55, carModels.ElementAt(model++ % carModels.Count)); car.Connect(this.MyMap, route); SimulatedTraffic.Cars.Add(car); } // Set the interval to 16ms (60 ticks / sec) this.Timer.Interval = new TimeSpan(0, 0, 0, 0, 1000 / UpdatesPerSecond); this.Timer.Start(); this.ViewModel.UpdateControls(); PlayButton.IsEnabled = true; PauseButton.IsEnabled = true; StopButton.IsEnabled = true; }