Esempio n. 1
0
        ///<summary>Deletes everything from the Unit Test ProgramProperty table.</summary>
        public static void ClearProgamPropertyTable()
        {
            string command = "DELETE FROM programproperty WHERE ProgramPropertyNum > 0";

            DataCore.NonQ(command);
            ProgramProperties.RefreshCache();
        }
Esempio n. 2
0
        ///<summary>Generates a single Unit Test ProgramProperty. This method refreshes the cache.</summary>
        public static ProgramProperty CreateProgramProperty(long programNum, string propertyDesc, long clinicNum, string propertyValue = "",
                                                            string computerName = "")
        {
            ProgramProperty prop = new ProgramProperty();

            prop.ProgramNum    = programNum;
            prop.PropertyDesc  = propertyDesc;
            prop.PropertyValue = propertyValue;
            prop.ComputerName  = computerName;
            prop.ClinicNum     = clinicNum;
            ProgramProperties.Insert(prop);
            ProgramProperties.RefreshCache();
            return(prop);
        }
        ///<summary>Tests the Delete method in ProgramProperties to ensure it will delete when the PropertyDesc is one of those in
        ///the GetDeletablePropertyDescriptions() list, in this case ProgramProperties.PropertyDescs.ClinicHideButton.</summary>
        public void ProgramProperties_Delete_DeletesWhenDescriptionInGetDeletablePropertyDescriptions()
        {
            ProgramProperty prop          = ProgramPropertyT.CreateProgramProperty(10, ProgramProperties.PropertyDescs.ClinicHideButton, 1);
            ProgramProperty getPropBefore = ProgramProperties.GetPropForProgByDesc(prop.ProgramNum, prop.PropertyDesc);

            Assert.IsNotNull(getPropBefore);
            Assert.AreEqual(prop.ProgramPropertyNum, getPropBefore.ProgramPropertyNum);
            try {
                ProgramProperties.Delete(prop);
            }
            catch (Exception ex) {
                ex.DoNothing();
            }
            ProgramProperties.RefreshCache();            //Make sure data is as current as it can be.
            //Ensure it was deleted.
            ProgramProperty getPropAfter = ProgramProperties.GetPropForProgByDesc(prop.ProgramNum, prop.PropertyDesc);

            Assert.IsNull(getPropAfter);            //No longer in DB
        }
        ///<summary>Tests the Delete method in ProgramProperties to ensure it does not delete a ProgramProperty when the PropertyDesc is outside of those
        ///in GetDeletablePropertyDescriptions(), instead it throws an exception (which we catch here) and then remains in the db.</summary>
        public void ProgramProperties_Delete_DoesNotDeleteWhenDescriptionIsNotInGetDeletablePropertyDescriptions()
        {
            ProgramProperty prop          = ProgramPropertyT.CreateProgramProperty(20, "Stuff", 2);
            ProgramProperty getPropBefore = ProgramProperties.GetPropForProgByDesc(prop.ProgramNum, prop.PropertyDesc);

            Assert.IsNotNull(getPropBefore);
            Assert.AreEqual(prop.ProgramPropertyNum, getPropBefore.ProgramPropertyNum);
            try {
                ProgramProperties.Delete(prop);
            }
            catch (Exception ex) {
                ex.DoNothing();
            }
            ProgramProperties.RefreshCache();            //Make sure data is as current as it can be.
            //Ensure it was NOT deleted since the description is most certainly not in GetDeletablePropertyDescriptions().
            ProgramProperty getPropAfter = ProgramProperties.GetPropForProgByDesc(prop.ProgramNum, prop.PropertyDesc);

            Assert.IsNotNull(getPropAfter);                                            //Still in DB
            Assert.AreEqual(prop.ProgramPropertyNum, getPropAfter.ProgramPropertyNum); //And we know its the ProgramProperty we put in.
        }
 public void TearDownTest()
 {
     ProgramPropertyT.ClearProgamPropertyTable();
     ProgramProperties.InsertMany(_listProgramProperties);
     ProgramProperties.RefreshCache();
 }