Esempio n. 1
0
    public PotholeManager(GridStructure grid, RoadRepository roadRepository, PlacementManager placementManager, int workerCount)
    {
        //Set up parameters
        this.grid             = grid;
        this.roadRepository   = roadRepository;
        this.gridSize         = grid.GridSize;
        this.placementManager = placementManager;

        SetCounters(workerCount);
    }
Esempio n. 2
0
        static void Main(string[] args)
        {
            // Getting connection string and details
            SettingsModel settings = new SettingsModel();

            // Calling the method
            RoadRepository methods = new RoadRepository();

            methods.roadStatus(args.FirstOrDefault(), settings);
            Console.WriteLine("Press any key to exit... ");
            Console.ReadLine();
        }
Esempio n. 3
0
    public PotholeManager(int cellSize, int gridSize, RoadRepository roadRepository, PlacementManager placementManager, int workerCount)
    {
        //Set up parameters
        this.grid             = new GridStructure(cellSize, gridSize);
        this.roadRepository   = roadRepository;
        this.gridSize         = gridSize;
        this.placementManager = placementManager;

        SetCounters(workerCount);

        //Generate the city's road system
        this.placementManager.GenerateCityRoads(grid, roadRepository);
    }
Esempio n. 4
0
    public void GenerateCityRoads(GridStructure grid, RoadRepository roadRepository)
    {
        for (int i = 0; i < grid.GetGridLength(0); i++)
        {
            for (int j = 0; j < grid.GetGridLength(1); j++)
            {
                GameObject roadPrefab = GetRoadTypePrefab(grid.GetRoadType(i, j), roadRepository);

                if (roadPrefab != null)
                {
                    GameObject roadObject = CreateRoadObject(i, j, grid, roadPrefab);

                    //Set object to the grid
                    grid.PlaceRoadToGrid(i, j, roadObject, false, true);
                }
            }
        }
    }
        public void LoadExamplestate()
        {
            roadTextures = RoadRepository
                           .InitializeRoadRepository()
                           .GetOneRoadTextureMap("assets/straight-road.png");

            edgePipes = RoadRepository
                        .InitializeRoadRepository()
                        .GetAllFromFile("../../data/Roads.xml");

            vehicles = VehicleRepository
                       .InitializeVehicleRepository()
                       .GetAllFromFile("../../data/Vehicles.xml", edgePipes);

            intersections = IntersectionRepository
                            .InitializeIntersectionRepository()
                            .GetAllFromFile("../../data/Intersections.xml", edgePipes);
        }
Esempio n. 6
0
    private GameObject GetRoadTypePrefab(RoadType roadType, RoadRepository roadRepository)
    {
        switch (roadType)
        {
        case RoadType.Straight:
            return(roadRepository.roadModelCollection.straightRoadPrefab.prefab);

        case RoadType.Corner:
            return(roadRepository.roadModelCollection.cornerRoadPrefab.prefab);

        case RoadType.ThreeWay:
            return(roadRepository.roadModelCollection.threeWayRoadPrefab.prefab);

        case RoadType.FourWay:
            return(roadRepository.roadModelCollection.fourWayRoadPrefab.prefab);

        default:
            return(null);
        }
    }
Esempio n. 7
0
        public void GetRoadsStatusAsync_WhenHttpStatusIsNot200Or404_ReturnsEmptyListOfRoads()
        {
            var expectedCount = 0;
            var urlPath       = "roads/A13";

            var mockHttp = new MockHttpMessageHandler();

            mockHttp.When("https://appapi/roads/A13")
            .Respond(req => new HttpResponseMessage(HttpStatusCode.BadRequest));

            var apiClient = mockHttp.ToHttpClient();

            apiClient.BaseAddress = new Uri("https://appapi/");

            roadRepository = new RoadRepository(apiClient);

            var result = roadRepository.GetAllAsync(urlPath).GetAwaiter().GetResult();

            Assert.That(result, Is.TypeOf <List <Road> >());
            Assert.That(result, Has.Count.EqualTo(expectedCount));
        }
Esempio n. 8
0
        public void GetRoadsStatusAsync_WhenHttpStatusIs200_ReturnsNonEmptyListOfRoads()
        {
            var roads = new List <Road>();

            roads.Add(new Road
            {
                Type                      = "Tfl.Api.Presentation.Entities.RoadCorridor, Tfl.Api.Presentation.Entities",
                Id                        = "a13",
                DisplayName               = "A13",
                StatusSeverity            = "Good",
                StatusSeverityDescription = "No Exceptional Delays",
                Url                       = "/Road/a13"
            });

            var expectedCount = roads.Count;
            var urlPath       = "roads/A13";
            var mockHttp      = new MockHttpMessageHandler();

            mockHttp.When("https://appapi/roads/A13")
            .Respond("application/json", GetRoadStatusJson(roads));

            var apiClient = mockHttp.ToHttpClient();

            apiClient.BaseAddress = new Uri("https://appapi/");

            roadRepository = new RoadRepository(apiClient);

            var result = roadRepository.GetAllAsync(urlPath).GetAwaiter().GetResult();

            Assert.That(result, Is.TypeOf <List <Road> >());
            Assert.That(result, Has.Count.EqualTo(expectedCount));
            Assert.That(result[0].Id, Is.EquivalentTo(roads[0].Id));
            Assert.That(result[0].Type, Is.EquivalentTo(roads[0].Type));
            Assert.That(result[0].DisplayName, Is.EquivalentTo(roads[0].DisplayName));
            Assert.That(result[0].StatusSeverity, Is.EquivalentTo(roads[0].StatusSeverity));
            Assert.That(result[0].StatusSeverityDescription, Is.EquivalentTo(roads[0].StatusSeverityDescription));
            Assert.That(result[0].Url, Is.EquivalentTo(roads[0].Url));
        }