示例#1
0
        /// <summary>
        /// Instantiates a new Location Test object
        /// </summary>
        public PathEdge()
        {
            //Set up the Data Connection
            var    config    = new ConfigurationBuilder().AddJsonFile("xunit.config.json").Build();
            string SQLServer = config["gfSqlServer"];
            string DBName    = config["gfDbName"];

            this._SQLConnection = new GFSqlConnector("testappAPIKEY", "testadminuserAPIKEY", SQLServer, DBName, true); //Need to log in as admin

            //Create a Test Simulation and save to DB

            this._TestSimulation = new Core.SimSig.Simulation("Test PathEdge Sim Name", "Test PathEdge Sim Desc", null, "TestPESimCode", this._SQLConnection);
            this._TestSimulation.SaveToSQLDB();
            this._TestVersion = new Core.SimSig.Version("Test PathEdge Version", "Test LocCode Version", 4.15M, this._SQLConnection);
            this._TestVersion.SaveToSQLDB();
            this._TestLocation1 = new Core.SimSig.Location(this._TestSimulation, "Test PathEdge Loc Name 1", null, "TestPECode1", false, Core.SimSig.SimSigLocationType.Station, this._SQLConnection);
            this._TestLocation1.SaveToSQLDB();
            this._TestLocationNode1 = new Core.SimSig.LocationNode(this._TestSimulation.ID, this._TestLocation1.SimSigCode, this._TestSimulation.GetSimulationEras().Find(x => x.Type == EraType.Template).ID, this._TestVersion, null, new Core.Electrification(0), SimSigLocationType.Station, null, false, null, null, this._SQLConnection);
            this._TestLocationNode1.SaveToSQLDB();
            this._TestLocation2 = new Core.SimSig.Location(this._TestSimulation, "Test PathEdge Loc Name 2", null, "TestPECode2", false, Core.SimSig.SimSigLocationType.Station, this._SQLConnection);
            this._TestLocation2.SaveToSQLDB();
            this._TestLocationNode2 = new Core.SimSig.LocationNode(this._TestSimulation.ID, this._TestLocation2.SimSigCode, this._TestSimulation.GetSimulationEras().Find(x => x.Type == EraType.Template).ID, this._TestVersion, null, new Core.Electrification(0), SimSigLocationType.Station, null, false, null, null, this._SQLConnection);
            this._TestLocationNode2.SaveToSQLDB();
            this._TestSimulationExt = new SimulationExtension(this._TestSimulation.ID, this._SQLConnection);
            this._TestSimulationExt.Locations.Add(this._TestLocation1);
            this._TestSimulationExt.Locations.Add(this._TestLocation2);
            this._TestSimulationExt.LocationNodes.Add(this._TestLocationNode1);
            this._TestSimulationExt.LocationNodes.Add(this._TestLocationNode2);
        }
 public IActionResult Get(int id)
 {
     try
     {
         Core.SimSig.SimulationExtension Sim = new Core.SimSig.SimulationExtension(id, this._SQLConnection);
         return(Ok(Sim));
     }
     catch (Exception Ex)
     {
         _logger.LogError($"An error has occurred: {Ex}");
         return(StatusCode(500, Ex.Message));
     }
 }
示例#3
0
        /// <summary>
        /// Instantiates a new Location Test object
        /// </summary>
        public LocationNode()
        {
            //Set up the Data Connection
            var    config    = new ConfigurationBuilder().AddJsonFile("xunit.config.json").Build();
            string SQLServer = config["gfSqlServer"];
            string DBName    = config["gfDbName"];

            this._SQLConnection = new GFSqlConnector("testappAPIKEY", "testadminuserAPIKEY", SQLServer, DBName, true); //Need to log in as admin

            //Create a Test Simulation and save to DB

            this._TestSimulation = new Core.SimSig.Simulation("Test LocationNode Sim Name", "Test LocationNode Sim Desc", null, "TestLocationNodeSimCode", this._SQLConnection);
            this._TestSimulation.SaveToSQLDB();
            this._TestLocation = new Core.SimSig.Location(this._TestSimulation, "Test LocNode Loc Name", null, "TestLocNodeCode", false, Core.SimSig.SimSigLocationType.Station, this._SQLConnection);
            this._TestLocation.SaveToSQLDB();
            this._TestSimulationExt = new SimulationExtension(this._TestLocation.ID, this._SQLConnection);
            this._TestSimulationExt.Locations.Add(this._TestLocation);
            this._TestVersion = new Core.SimSig.Version("Test LocNode Version", "Test LocCode Version", 4.15M, this._SQLConnection);
            this._TestVersion.SaveToSQLDB();
        }