예제 #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);
        }
예제 #2
0
 public void Location_Constructor_ByProperties(string TIPLOC, string Name, bool EntryPoint, string SimSigCode, int LocationType)
 {
     Core.SimSig.Location TestLocation = new Core.SimSig.Location(this._TestSimulation, Name, TIPLOC, SimSigCode, EntryPoint, (Core.SimSig.SimSigLocationType)LocationType, this._SQLConnection);
     TestLocation.SaveToSQLDB();
     Assert.Equal(Name, TestLocation.Name);
     Assert.Equal(TIPLOC, TestLocation.TIPLOC);
     Assert.Equal(EntryPoint, TestLocation.EntryPoint);
     Assert.Equal(SimSigCode, TestLocation.SimSigCode);
     Assert.Equal((Core.SimSig.SimSigLocationType)LocationType, TestLocation.LocationType);
     Assert.NotEqual(0, TestLocation.ID);
 }
예제 #3
0
        public void LocationCollection_Constructor_Default()
        {
            //Populate some data
            Core.SimSig.Simulation TestSim = new Core.SimSig.Simulation("LocColl Sim Name", "LocColl Sim Desc", null, "LocCollCode", this._SQLConnection);
            TestSim.SaveToSQLDB();
            Core.SimSig.Location TestLocation1 = new Core.SimSig.Location(TestSim, "LocColl Loc Name", null, "LocCollLocCode1", true, Core.SimSig.SimSigLocationType.Station, this._SQLConnection);
            TestLocation1.SaveToSQLDB();
            Core.SimSig.Location TestLocation2 = new Core.SimSig.Location(TestSim, "LocCol2 Loc Name", "LocCollTIPLOC2", "LocCollLocCode2", false, Core.SimSig.SimSigLocationType.Station, this._SQLConnection);
            TestLocation2.SaveToSQLDB();

            //Get Collection
            Core.SimSig.LocationCollection TestLocCollection = new Core.SimSig.LocationCollection(TestSim, this._SQLConnection);
            //Check 5 records are returned
            Assert.Equal(2, TestLocCollection.Count);
        }
예제 #4
0
        public void Location_Method_CheckRefresh(string TIPLOC, string Name, bool EntryPoint, string SimSigCode, int LocationType)
        {
            Core.SimSig.Location TestLocation = new Core.SimSig.Location(this._TestSimulation, Name, TIPLOC, SimSigCode, EntryPoint, (Core.SimSig.SimSigLocationType)LocationType, this._SQLConnection);
            TestLocation.SaveToSQLDB();

            //Now load into a new object and compare

            Core.SimSig.Location CheckLocation = new Core.SimSig.Location(TestLocation.ID, this._SQLConnection);
            Assert.Equal(TestLocation.ID, CheckLocation.ID);
            Assert.Equal(TestLocation.Name, CheckLocation.Name);
            Assert.Equal(TestLocation.SimSigCode, CheckLocation.SimSigCode);
            Assert.Equal(TestLocation.EntryPoint, CheckLocation.EntryPoint);
            Assert.Equal(TestLocation.LocationType, CheckLocation.LocationType);

            string TestTIPLOC  = string.IsNullOrEmpty(TestLocation.TIPLOC) ? "NULL" : TestLocation.TIPLOC;
            string CheckTIPLOC = string.IsNullOrEmpty(CheckLocation.TIPLOC) ? "NULL" : CheckLocation.TIPLOC;

            Assert.Equal(TestTIPLOC, CheckTIPLOC);
        }
예제 #5
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();
        }
예제 #6
0
        public void Location_Method_CheckUpdate(string TIPLOC, string Name, bool EntryPoint, string SimSigCode, int LocationType)
        {
            Core.SimSig.Location TestLocation = new Core.SimSig.Location(this._TestSimulation, Name, TIPLOC, SimSigCode, EntryPoint, (Core.SimSig.SimSigLocationType)LocationType, this._SQLConnection);
            TestLocation.SaveToSQLDB();

            Assert.Equal(Name, TestLocation.Name);
            Assert.Equal(TIPLOC, TestLocation.TIPLOC);
            Assert.Equal(EntryPoint, TestLocation.EntryPoint);
            Assert.Equal(SimSigCode, TestLocation.SimSigCode);
            Assert.NotEqual(0, TestLocation.ID);
            Assert.Equal((Core.SimSig.SimSigLocationType)LocationType, TestLocation.LocationType);

            int LocationID = TestLocation.ID;

            TestLocation.TIPLOC = string.Format(@"{0}_U", TIPLOC);

            TestLocation.SaveToSQLDB();

            Assert.Equal(LocationID, TestLocation.ID);
        }