public void TestCalcRayEffTxHt() { EffectTxEnhancedSlope testEffectTxEnhancedSlope = new EffectTxEnhancedSlope(); SectionPathLossCalcParam param = new SectionPathLossCalcParam(); param.TxAntennaHeight = 5f; param.CalcResolution = 5f; StreamReader sr = new StreamReader(@"D:\UNet2012\TestCode\Huawei.UNet.Propagation.Plugins.Test\TextFile4.txt"); int startIndex = 0; int endIndex = 5; string line0 = null; while (null != (line0 = sr.ReadLine())) { //第一行赋值给期望结果 string lineExpected = line0.Trim(); if (lineExpected.StartsWith("#")) { continue; } string[] tokenExpected = lineExpected.Split(' '); List<float> listExpected = new List<float>(); for (int i = 0; i < tokenExpected.Length; i++) { listExpected.Add(float.Parse(tokenExpected[i])); } float[] expected = listExpected.ToArray(); //次行第一个给TxAntennaHeight赋值,第二个给CalcResolution赋值 string lineParam = sr.ReadLine().Trim(); string[] tokenParam = lineParam.Split(' '); param.TxAntennaHeight = float.Parse(tokenParam[0]); param.CalcResolution = float.Parse(tokenParam[1]); //第三行赋值给数组altitudes string lineAltitudes = sr.ReadLine().Trim(); string[] tokenAltitudes = lineAltitudes.Split(' '); List<short> list = new List<short>(); for (int i = 0; i < tokenAltitudes.Length; i++) { list.Add(short.Parse(tokenAltitudes[i])); } short[] altitudes = list.ToArray(); float[] result = testEffectTxEnhancedSlope.CalcRayEffTxHt(param, altitudes, startIndex, endIndex); //foreach (float f in result) //{ // Console.WriteLine(f.ToString()); //} Assert.AreEqual(expected, result); } sr.Close(); }
public static void InitialCalcMethods() { EffectTxHeightHtAbsSpot spot = new EffectTxHeightHtAbsSpot(); EffectTxAboveTheGround ground = new EffectTxAboveTheGround(); EffectTxAboveTheAverageGround ground2 = new EffectTxAboveTheAverageGround(); EffectTxSpotHt ht = new EffectTxSpotHt(); EffectTxSlopeAtReceiver receiver = new EffectTxSlopeAtReceiver(); EffectTxEnhancedSlope slope = new EffectTxEnhancedSlope(); EffectTxHeightCalcuMethod.EffectTxHeightCalcuMethodList[EffectTxHeightCalcuMethod.DefaultEffectTxHeightCalcuMethodName] = null; EffectTxHeightCalcuMethod.EffectTxHeightCalcuMethodList[spot.EffectTxHeightMethodName] = spot; EffectTxHeightCalcuMethod.EffectTxHeightCalcuMethodList[ground.EffectTxHeightMethodName] = ground; EffectTxHeightCalcuMethod.EffectTxHeightCalcuMethodList[ground2.EffectTxHeightMethodName] = ground; EffectTxHeightCalcuMethod.EffectTxHeightCalcuMethodList[ht.EffectTxHeightMethodName] = ht; EffectTxHeightCalcuMethod.EffectTxHeightCalcuMethodList[receiver.EffectTxHeightMethodName] = receiver; EffectTxHeightCalcuMethod.EffectTxHeightCalcuMethodList[slope.EffectTxHeightMethodName] = slope; }