Пример #1
0
        public void LocationNode_Constructor_ByProperties_SimSigCode(string Platform, string Electrification, SimSigLocationType LocationType, int?Length, bool FreightOnly, string Line, string Path)
        {
            Length TestLength = null;

            if (Length != null)
            {
                TestLength = new Length(Convert.ToInt32(Length));
            }

            Core.SimSig.LocationNode TestLocationNode = new Core.SimSig.LocationNode(this._TestSimulation.ID, this._TestLocation.SimSigCode, this._TestSimulation.GetSimulationEras().Find(x => x.Type == EraType.Template).ID, this._TestVersion, Platform, new Core.Electrification(Electrification), LocationType, TestLength, FreightOnly, Line, Path, this._SQLConnection);
            Assert.Equal(LocationType, TestLocationNode.LocationType);
            Assert.Equal(Platform, TestLocationNode.Platform);
            Assert.Equal(Line, TestLocationNode.Line);
            Assert.Equal(Path, TestLocationNode.Path);
            Assert.Equal(this._TestLocation.SimSigCode, TestLocationNode.LocationSimSigCode);
            Assert.Equal(this._TestLocation.ID, TestLocationNode.LocationID);

            if (Length == null)
            {
                Assert.Null(TestLocationNode.Length);
            }
            else
            {
                Assert.Equal(TestLength.Meters, TestLocationNode.Length.Meters);
            }

            Assert.Equal(FreightOnly, TestLocationNode.FreightOnly);
            Assert.Equal(new Electrification(Electrification).BitWise, TestLocationNode.Electrification.BitWise);
            Assert.Equal(0, TestLocationNode.ID);
        }
Пример #2
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);
        }
Пример #3
0
        public void LocationNode_Constructor_GroundFrameDBID(string Platform, string Electrification, SimSigLocationType LocationType, int?Length, bool FreightOnly, string Line, string Path)
        {
            Length TestLength = null;

            if (Length != null)
            {
                TestLength = new Length(Convert.ToInt32(Length));
            }

            SimulationEra SimEra = this._TestSimulation.GetSimulationEras().Find(x => x.Type == EraType.Template);

            Core.Electrification     ElecObject       = new Core.Electrification(Electrification);
            Core.SimSig.LocationNode TestLocationNode = new Core.SimSig.LocationNode(this._TestSimulation.ID, this._TestLocation.SimSigCode, SimEra.ID, this._TestVersion, Platform, ElecObject, LocationType, TestLength, FreightOnly, Line, Path, this._SQLConnection);
            TestLocationNode.SaveToSQLDB();
            Assert.Equal(LocationType, TestLocationNode.LocationType);
            Assert.Equal(Platform, TestLocationNode.Platform);
            Assert.Equal(Line, TestLocationNode.Line);
            Assert.Equal(Path, TestLocationNode.Path);
            Assert.Equal(this._TestLocation.SimSigCode, TestLocationNode.LocationSimSigCode);
            Assert.Equal(this._TestLocation.ID, TestLocationNode.LocationID);

            if (Length == null)
            {
                Assert.Null(TestLocationNode.Length);
            }
            else
            {
                Assert.Equal(TestLength.Meters, TestLocationNode.Length.Meters);
            }

            Assert.Equal(FreightOnly, TestLocationNode.FreightOnly);
            Assert.Equal(new Electrification(Electrification).BitWise, TestLocationNode.Electrification.BitWise);
            Assert.NotEqual(0, TestLocationNode.ID);

            //Load the LocationNode into a new object and compare
            Core.SimSig.LocationNode TestLoadLocationNode = new Core.SimSig.LocationNode(TestLocationNode.ID, this._SQLConnection, true);

            Assert.Equal(TestLocationNode.LocationType, TestLoadLocationNode.LocationType);
            Assert.Equal(TestLocationNode.Platform, TestLoadLocationNode.Platform);
            Assert.Equal(TestLocationNode.Line, TestLoadLocationNode.Line);
            Assert.Equal(TestLocationNode.Path, TestLoadLocationNode.Path);
            Assert.Equal(TestLocationNode.LocationSimSigCode, TestLoadLocationNode.LocationSimSigCode);
            Assert.Equal(TestLocationNode.LocationID, TestLoadLocationNode.LocationID);

            if (TestLocationNode.Length == null)
            {
                Assert.Null(TestLoadLocationNode.Length);
            }
            else
            {
                Assert.Equal(TestLocationNode.Length.Meters, TestLoadLocationNode.Length.Meters);
            }

            Assert.Equal(TestLocationNode.FreightOnly, TestLoadLocationNode.FreightOnly);
            Assert.Equal(TestLocationNode.Electrification.BitWise, TestLoadLocationNode.Electrification.BitWise);
            Assert.Equal(TestLocationNode.ID, TestLoadLocationNode.ID);
        }