public void PFS_SetVariable_float_OK() { using (PFS pfs = new PFS(fi)) { Assert.IsNotNull(fi); Assert.IsTrue(fi.Exists); Assert.AreEqual(fileName, fi.FullName); float?floatRet = pfs.GetVariable <float>("FemEngineHD/DOMAIN", "minimum_depth", 1); Assert.IsNotNull(floatRet); Assert.IsTrue(floatRet.ToString().StartsWith("-0.4999")); Assert.AreEqual("", pfs.ErrorMessage); floatRet = pfs.SetVariable <float>("FemEngineHD/DOMAIN", "minimum_depth", 1, 0.777f); Assert.IsNotNull(floatRet); Assert.AreEqual(0.777f, floatRet); Assert.AreEqual("", pfs.ErrorMessage); floatRet = pfs.GetVariable <float>("FemEngineHD/DOMAIN", "minimum_depth", 1); Assert.IsNotNull(floatRet); Assert.AreEqual(0.777f, floatRet); Assert.AreEqual("", pfs.ErrorMessage); floatRet = pfs.SetVariable <float>("FemEngineHD/DOMAIN", "minimum_depth", 1, -0.4999854f); Assert.IsNotNull(floatRet); Assert.AreEqual(-0.4999854f, floatRet); Assert.AreEqual("", pfs.ErrorMessage); floatRet = pfs.GetVariable <float>("FemEngineHD/DOMAIN", "minimum_depth", 1); Assert.IsNotNull(floatRet); Assert.AreEqual(-0.4999854f, floatRet); Assert.AreEqual("", pfs.ErrorMessage); } }
public void PFS_SetVariable_int_OK() { using (PFS pfs = new PFS(fi)) { Assert.IsNotNull(fi); Assert.IsTrue(fi.Exists); Assert.AreEqual(fileName, fi.FullName); int?doubleRet = pfs.GetVariable <int>("FemEngineHD/DOMAIN", "discretization", 1); Assert.IsNotNull(doubleRet); Assert.AreEqual(2, doubleRet); Assert.AreEqual("", pfs.ErrorMessage); doubleRet = pfs.SetVariable <int>("FemEngineHD/DOMAIN", "discretization", 1, 3); Assert.IsNotNull(doubleRet); Assert.AreEqual(3, doubleRet); Assert.AreEqual("", pfs.ErrorMessage); doubleRet = pfs.GetVariable <int>("FemEngineHD/DOMAIN", "discretization", 1); Assert.IsNotNull(doubleRet); Assert.AreEqual(3, doubleRet); Assert.AreEqual("", pfs.ErrorMessage); doubleRet = pfs.SetVariable <int>("FemEngineHD/DOMAIN", "discretization", 1, 2); Assert.IsNotNull(doubleRet); Assert.AreEqual(2, doubleRet); Assert.AreEqual("", pfs.ErrorMessage); doubleRet = pfs.GetVariable <int>("FemEngineHD/DOMAIN", "discretization", 1); Assert.IsNotNull(doubleRet); Assert.AreEqual(2, doubleRet); Assert.AreEqual("", pfs.ErrorMessage); } }
public void PFS_SetVariable_bool_OK() { using (PFS pfs = new PFS(fi)) { Assert.IsNotNull(fi); Assert.IsTrue(fi.Exists); Assert.AreEqual(fileName, fi.FullName); bool?boolRet = pfs.GetVariable <bool>("FemEngineHD/MUD_TRANSPORT_MODULE/WATER_COLUMN/SAND_FRACTIONS/FRACTION_1", "include_sand", 1); Assert.IsNotNull(boolRet); Assert.AreEqual(true, boolRet); Assert.AreEqual("", pfs.ErrorMessage); boolRet = pfs.SetVariable <bool>("FemEngineHD/MUD_TRANSPORT_MODULE/WATER_COLUMN/SAND_FRACTIONS/FRACTION_1", "include_sand", 1, false); Assert.IsNotNull(boolRet); Assert.AreEqual(false, boolRet); Assert.AreEqual("", pfs.ErrorMessage); boolRet = pfs.GetVariable <bool>("FemEngineHD/MUD_TRANSPORT_MODULE/WATER_COLUMN/SAND_FRACTIONS/FRACTION_1", "include_sand", 1); Assert.IsNotNull(boolRet); Assert.AreEqual(false, boolRet); Assert.AreEqual("", pfs.ErrorMessage); boolRet = pfs.SetVariable <bool>("FemEngineHD/MUD_TRANSPORT_MODULE/WATER_COLUMN/SAND_FRACTIONS/FRACTION_1", "include_sand", 1, true); Assert.IsNotNull(boolRet); Assert.AreEqual(true, boolRet); Assert.AreEqual("", pfs.ErrorMessage); boolRet = pfs.GetVariable <bool>("FemEngineHD/MUD_TRANSPORT_MODULE/WATER_COLUMN/SAND_FRACTIONS/FRACTION_1", "include_sand", 1); Assert.IsNotNull(boolRet); Assert.AreEqual(true, boolRet); Assert.AreEqual("", pfs.ErrorMessage); } }
public void PFS_SetVariable_double_OK() { using (PFS pfs = new PFS(fi)) { Assert.IsNotNull(fi); Assert.IsTrue(fi.Exists); Assert.AreEqual(fileName, fi.FullName); double?doubleRet = pfs.GetVariable <double>("FemEngineHD/DOMAIN", "minimum_depth", 1); Assert.IsNotNull(doubleRet); Assert.IsTrue(doubleRet.ToString().StartsWith("-0.4999")); Assert.AreEqual("", pfs.ErrorMessage); doubleRet = pfs.SetVariable <double>("FemEngineHD/DOMAIN", "minimum_depth", 1, 0.777D); Assert.IsNotNull(doubleRet); Assert.IsTrue(doubleRet.ToString().StartsWith("0.777")); Assert.AreEqual("", pfs.ErrorMessage); doubleRet = pfs.GetVariable <double>("FemEngineHD/DOMAIN", "minimum_depth", 1); Assert.IsNotNull(doubleRet); Assert.AreEqual(0.777D, doubleRet); Assert.AreEqual("", pfs.ErrorMessage); doubleRet = pfs.SetVariable <double>("FemEngineHD/DOMAIN", "minimum_depth", 1, -0.4999854D); Assert.IsNotNull(doubleRet); Assert.AreEqual(-0.4999854D, doubleRet); Assert.AreEqual("", pfs.ErrorMessage); doubleRet = pfs.GetVariable <double>("FemEngineHD/DOMAIN", "minimum_depth", 1); Assert.IsNotNull(doubleRet); Assert.AreEqual(-0.4999854D, doubleRet); Assert.AreEqual("", pfs.ErrorMessage); } }
public void PFS_GetVariable_bool_File_DoesNotExist_In_GetBool_Error() { using (PFS pfs = new PFS(fi)) { pfs.fi = new FileInfo(fi.FullName + "aa"); bool?boolRet = pfs.GetVariable <bool>("FemEngineHD/MUD_TRANSPORT_MODULE/WATER_COLUMN/SAND_FRACTIONS/FRACTION_1", "include_sand", 1); Assert.IsNull(boolRet); Assert.AreEqual(string.Format(CSSPDHIRes.File_DoesNotExist, pfs.fi.FullName), pfs.ErrorMessage); } }
public void PFS_GetVariable_bit_not_implemented_should_return_null_OK() { using (PFS pfs = new PFS(fi)) { Assert.IsNotNull(fi); Assert.IsTrue(fi.Exists); Assert.AreEqual(fileName, fi.FullName); decimal?decimalRet = pfs.GetVariable <decimal>("FemEngineHD/DOMAIN", "minimum_depth", 1); Assert.IsNull(decimalRet); } }
public void PFS_GetVariable_bool_WrongFileTypeLookingFor__Error() { FileInfo fi = new FileInfo(@"C:\CSSP Latest Code Old\CSSPDHIFormApp\CSSPDHIFormApp\trans_Mike21.dfsu"); using (PFS pfs = new PFS(fi)) { Assert.IsNotNull(fi); Assert.IsTrue(fi.Exists); bool? boolRet = pfs.GetVariable <bool>("FemEngineHD/MUD_TRANSPORT_MODULE/WATER_COLUMN/SAND_FRACTIONS/FRACTION_1", "include_sand", 1); string ErrorMessage = string.Format(CSSPDHIRes.WrongFileTypeLookingFor_, "[.m21fm or .m3fm]"); Assert.AreEqual(ErrorMessage, pfs.ErrorMessage.Substring(0, ErrorMessage.Length)); } }
public void PFS_GetVariable_bool_false_OK() { using (PFS pfs = new PFS(fi)) { Assert.IsNotNull(fi); Assert.IsTrue(fi.Exists); Assert.AreEqual(fileName, fi.FullName); bool?boolRet = pfs.GetVariable <bool>("FemEngineHD/MUD_TRANSPORT_MODULE/WATER_COLUMN/DENSITY_AND_VISCOSITY", "include_density_feedback_on_HD", 1); Assert.IsNotNull(boolRet); Assert.AreEqual(false, boolRet); Assert.AreEqual("", pfs.ErrorMessage); } }
public void PFS_GetVariable_float_OK() { using (PFS pfs = new PFS(fi)) { Assert.IsNotNull(fi); Assert.IsTrue(fi.Exists); Assert.AreEqual(fileName, fi.FullName); double?doubleRet = pfs.GetVariable <float>("FemEngineHD/DOMAIN", "minimum_depth", 1); Assert.IsNotNull(doubleRet); Assert.AreEqual(-0.4999854f, doubleRet); Assert.AreEqual("", pfs.ErrorMessage); } }
public void PFS_GetVariable_bool_CouldNotFindSectionForPath__Error() { using (PFS pfs = new PFS(fi)) { Assert.IsNotNull(fi); Assert.IsTrue(fi.Exists); Assert.AreEqual(fileName, fi.FullName); string path = "FemEngineHD/MUD_TRANSPORT_MODULE/WATER_COLUMN/SAND_FRACTIONS/ThisPathDoesNotExist"; bool? boolRet = pfs.GetVariable <bool>(path, "include_sand", 1); Assert.IsNull(boolRet); Assert.AreEqual(string.Format(CSSPDHIRes.CouldNotFindSectionForPath_, path), pfs.ErrorMessage); } }
public void PFS_GetVariable_bool_Keyword_DoesNotExistForSectionPath_Error__Error() { using (PFS pfs = new PFS(fi)) { Assert.IsNotNull(fi); Assert.IsTrue(fi.Exists); Assert.AreEqual(fileName, fi.FullName); string keyword = "NotAnExistingKeyword"; string path = "FemEngineHD/MUD_TRANSPORT_MODULE/WATER_COLUMN/SAND_FRACTIONS/FRACTION_1"; bool? boolRet = pfs.GetVariable <bool>(path, keyword, 1); Assert.IsNull(boolRet); string ErrorMessage = string.Format(CSSPDHIRes.Keyword_DoesNotExistForSectionPath_Error_, keyword, path, ""); Assert.AreEqual(ErrorMessage, pfs.ErrorMessage.Substring(0, ErrorMessage.Length - 1) + "]"); } }