我的代码是 public void Compare_CoolProp_with_CoreMediumDensity() { Water coreWater = new Water(Pressure.FromPascals(101325), Temperature.FromKelvins(300)); GetCoolPropOriginal asd = new GetCoolPropOriginal(); GetCoolProp asdf = new GetCoolProp(); Pressure pressure = Pressure.FromPascals(101325); Temperature temperature = Temperature.FromKelvins(300); double actual = (CoolProp.PropsSI("D", "P", 101325, "T", 300, "Water")); double actual2 = asd.GetDensity("P", 101325, "T", 300, "Water"); double actual3= asdf.GetDensity(pressure, temperature,"Water"); double expected = coreWater.ThermodynamicState.Density.KilogramsPerCubicMeter; //double expected3 = coreWater.ThermodynamicState.Temperature.DegreesCelsius; List<double> liste = new List<double>(); liste.Add(actual); liste.Add(actual2); liste.Add(actual3); liste.Add(expected); Boolean boola = true; for (int i = 0; i < liste.Count-1; i++) { for (int j = i+1; j < liste.Count; j++) { if (!Precision.AlmostEqual(liste[i], liste[j], 0.01)) { boola = false; } } } Assert.True(boola); }我的代码是工作。但我想在一行中测试我的流体密度和其他功能。我不想要每一个,因为我有很多功能。有没有办法测试这个代码,比如 (assert.true(precision.almostEqual(double,double,双,双,MaximumAbsoluteError)
2 回答
米脂
TA贡献1836条经验 获得超3个赞
您可以创建自己的方法,其中值将作为params参数给出。
public void AssertThatAlmostEqual(double precision, params double[] values)
{
var isAlmostEqual = Precision.AlmostEqual(double.Min(), double.Max(), precision);
Assert.IsTrue(isAlmostEqual);
}
测试中
AssertThatAlmostEqual(0.01, actual1, actual2, actual3, expected);
- 2 回答
- 0 关注
- 175 浏览
添加回答
举报
0/150
提交
取消