/// <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 void Version_Constructor_ByProperties(string Name, string Description, Decimal Version) { Core.SimSig.Version TestVersion = new Core.SimSig.Version(Name, Description, Version, this._SQLConnection); TestVersion.SaveToSQLDB(); Assert.Equal(Name, TestVersion.Name); Assert.Equal(Description, TestVersion.Description); Assert.Equal(Version, TestVersion.VersionFrom); Assert.Null(TestVersion.VersionTo); Assert.NotEqual(0, TestVersion.ID); }
public void Version_Constructor_ByID(string Name, string Description, Decimal Version) { Core.SimSig.Version TestVersion = new Core.SimSig.Version(Name, Description, Version, this._SQLConnection); TestVersion.SaveToSQLDB(); Core.SimSig.Version ComparisonVersion = new Core.SimSig.Version(TestVersion.ID, this._SQLConnection); Assert.Equal(TestVersion.ID, ComparisonVersion.ID); Assert.Equal(TestVersion.Name, ComparisonVersion.Name); Assert.Equal(TestVersion.Description, ComparisonVersion.Description); Assert.Equal(Version, ComparisonVersion.VersionFrom); }
/// <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(); }
public void Version_Constructor_CheckVersionNumber() { //Create versions Core.SimSig.Version TestVersion1 = new Core.SimSig.Version("Test Version Name 4", "Test Version Description 4", 1.0000M, this._SQLConnection); TestVersion1.SaveToSQLDB(); Core.SimSig.Version TestVersion2 = new Core.SimSig.Version("Test Version Name 5", "Test Version Description 5", 2.0000M, this._SQLConnection); TestVersion2.SaveToSQLDB(); decimal VersionNumber1 = 1.5M; Core.SimSig.Version TestVersionNumber1 = new Core.SimSig.Version(VersionNumber1, this._SQLConnection); Assert.Equal("Test Version Name 4", TestVersionNumber1.Name); decimal VersionNumber2 = 3M; Core.SimSig.Version TestVersionNumber2 = new Core.SimSig.Version(VersionNumber2, this._SQLConnection); Assert.Equal("Test Version Name 5", TestVersionNumber2.Name); decimal VersionNumber3 = 0M; Core.SimSig.Version TestVersionNumber3 = new Core.SimSig.Version(VersionNumber3, this._SQLConnection); Assert.Null(TestVersionNumber3.Name); }
public void Version_Constructor_CheckVersionToUpdatesCorrectly(string Name, string Description, Decimal Version) { //Create initial version Core.SimSig.Version TestVersion = new Core.SimSig.Version(Name, Description, Version, this._SQLConnection); TestVersion.SaveToSQLDB(); Assert.NotEqual(0, TestVersion.ID); Assert.Equal(Name, TestVersion.Name); Assert.Equal(Description, TestVersion.Description); Assert.Equal(Version, TestVersion.VersionFrom); Assert.Null(TestVersion.VersionTo); //Create and check next verion Core.SimSig.Version ComparisonVersion = new Core.SimSig.Version(string.Format(@"{0}_U", Name), string.Format(@"{0}_U", Description), Version + 1, this._SQLConnection); ComparisonVersion.SaveToSQLDB(); Assert.NotEqual(0, ComparisonVersion.ID); Assert.Equal(string.Format(@"{0}_U", Name), ComparisonVersion.Name); Assert.Equal(string.Format(@"{0}_U", Description), ComparisonVersion.Description); Assert.Equal((decimal)Version + 1, ComparisonVersion.VersionFrom); Assert.Null(ComparisonVersion.VersionTo); //Refresh Initial TestVersion.RefreshFromDB(); Assert.Equal((decimal)3.9900, TestVersion.VersionTo); }