Exemple #1
0
        public void Simulation_Method_SaveToSQLDB_WithDateTime(string Name, string Description, string SimSigWikiLink, string SimSigCode)
        {
            Core.SimSig.Simulation TestSim = new Core.SimSig.Simulation(Name, Description, SimSigWikiLink, SimSigCode, this._SQLConnection);

            DateTimeOffset TestDateTime = new DateTimeOffset(new DateTime(2019, 1, 1), TimeSpan.FromHours(-8));

            TestSim.SaveToSQLDB(TestDateTime);
            Assert.Equal(Name, TestSim.Name);
            Assert.Equal(Description, TestSim.Description);
            Assert.Equal(SimSigWikiLink, TestSim.SimSigWikiLink);
            Assert.Equal(SimSigCode, TestSim.SimSigCode);
            Assert.NotEqual(0, TestSim.ID);

            this._SQLConnection.Open();
            SqlCommand Cmd = this._SQLConnection.SQLCommand("SELECT createdon, modifiedon FROM [simsig].[TSIM] WHERE [id] = @id", System.Data.CommandType.Text);

            Cmd.Parameters.Add(new SqlParameter("@id", TestSim.ID));
            SqlDataReader DataReader = Cmd.ExecuteReader();

            DateTimeOffset TestCreatedOnDateTime  = DateTimeOffset.UtcNow;
            DateTimeOffset TestModifiedOnDateTime = DateTimeOffset.UtcNow;

            while (DataReader.Read())
            {
                TestCreatedOnDateTime  = DataReader.GetDateTimeOffset(0);
                TestModifiedOnDateTime = DataReader.GetDateTimeOffset(1);
            }

            this._SQLConnection.Close();

            Assert.Equal(TestDateTime, TestCreatedOnDateTime);
            Assert.Equal(TestDateTime, TestModifiedOnDateTime);
        }
Exemple #2
0
 public void Simulation_Method_Exists(string Name, string Description, string SimSigWikiLink, string SimSigCode)
 {
     Core.SimSig.Simulation TestSim = new Core.SimSig.Simulation(Name, Description, SimSigWikiLink, SimSigCode, this._SQLConnection);
     Assert.False(TestSim.Exists());
     TestSim.SaveToSQLDB();
     //Now create a new Simulation object with the same arguments and see if it exists.
     Core.SimSig.Simulation TestSimExists = new Core.SimSig.Simulation(Name, Description, SimSigWikiLink, SimSigCode, this._SQLConnection);
     Assert.True(TestSimExists.Exists());
 }
Exemple #3
0
 public void Simulation_Method_SaveToSQLDB_NoDateTime(string Name, string Description, string SimSigWikiLink, string SimSigCode)
 {
     Core.SimSig.Simulation TestSim = new Core.SimSig.Simulation(Name, Description, SimSigWikiLink, SimSigCode, this._SQLConnection);
     TestSim.SaveToSQLDB();
     Assert.Equal(Name, TestSim.Name);
     Assert.Equal(Description, TestSim.Description);
     Assert.Equal(SimSigWikiLink, TestSim.SimSigWikiLink);
     Assert.Equal(SimSigCode, TestSim.SimSigCode);
     Assert.NotEqual(0, TestSim.ID);
 }
Exemple #4
0
        public void Simulation_Method_SaveToSQLDB_NoDateTime_CheckDuplicateUpdatesExistingRecord(string Name, string Description, string SimSigWikiLink, string SimSigCode)
        {
            Core.SimSig.Simulation TestSim = new Core.SimSig.Simulation(Name, Description, SimSigWikiLink, SimSigCode, this._SQLConnection);
            TestSim.SaveToSQLDB();
            int TestID = TestSim.ID;

            //Create a new object with same properties. The ID returned when saving should be the same as the first record saved
            Core.SimSig.Simulation DupeTestSim = new Core.SimSig.Simulation(Name, Description, SimSigWikiLink, SimSigCode, this._SQLConnection);
            DupeTestSim.SaveToSQLDB();
            Assert.Equal(TestID, DupeTestSim.ID);
        }
Exemple #5
0
        public void Simulation_Method_SaveToSQLDB_NoDateTime_CheckGetFromSQLDatabase(string Name, string Description, string SimSigWikiLink, string SimSigCode)
        {
            Core.SimSig.Simulation SetUpSim = new Core.SimSig.Simulation(Name, Description, SimSigWikiLink, SimSigCode, this._SQLConnection);
            SetUpSim.SaveToSQLDB();
            int SetupSimID = SetUpSim.ID;

            //Retrieve the simulation record from the Groundframe.SQL database
            Core.SimSig.Simulation TestSim = new Core.SimSig.Simulation(SetupSimID, this._SQLConnection);
            Assert.Equal(Name, TestSim.Name);
            Assert.Equal(Description, TestSim.Description);
            Assert.Equal(SimSigWikiLink, TestSim.SimSigWikiLink);
            Assert.Equal(SimSigCode.ToLower(), TestSim.SimSigCode);
            Assert.Equal(SetupSimID, TestSim.ID);
        }
Exemple #6
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);
        }