public void MobilityTest() { string gc = Mobility.GetCode(string.Empty); Assert.AreEqual(gc, string.Empty); gc = Mobility.GetCode(null); Assert.AreEqual(gc, string.Empty); gc = Mobility.GetCode("qqqqqqqqqqqqqqq"); Assert.AreEqual(gc, "QQ"); string str = Mobility.GetName(string.Empty); Assert.AreEqual(str, string.Empty); str = Mobility.GetName(null); Assert.AreEqual(str, string.Empty); str = Mobility.GetName("qqqqqqqqqqqqqqq"); Assert.AreEqual(str, string.Empty); str = Mobility.GetName("qqpqqqqqqqmwqqq"); Assert.AreEqual(str, "Pack Animals"); }
/// <summary> /// Generates barge mobility object. /// </summary> /// <param name="symbolCode"> /// The symbol code containing the mobility indicator for which to create a mobility Shape. /// </param> /// <returns> /// A Shape object representing the mobility object. /// </returns> public static Shape GenerateMobility(string symbolCode) { if (!SymbolData.Check(ref symbolCode)) { return(null); } if (!Mobility.IsMobility(symbolCode)) { return(null); } Rect b = SymbolData.GetBounds(symbolCode); double bottom = b.Bottom + HalfWidth; bool flat = SymbolData.IsBaseFlat(symbolCode); const double X = End - Rad; switch (Mobility.GetCode(symbolCode)) { case Mobility.WheeledLimited: return(GenerateWheels(new[] { -X, X }, bottom)); case Mobility.WheeledCrossCountry: return(GenerateWheels(new[] { -X, 0, X }, bottom)); case Mobility.Tracked: return(GenerateTracked(bottom)); case Mobility.WheeledTracked: return(GenerateWheeledTracked(bottom)); case Mobility.Towed: if (flat) { bottom += Rad; } return(GenerateTowed(bottom)); case Mobility.Railway: return(GenerateWheels(new[] { -X, -X + TwoRad, X - TwoRad, X }, bottom)); case Mobility.OverSnow: if (flat) { bottom += TwoRad; } return(GenerateOverSnow(bottom)); case Mobility.Sled: if (!flat) { bottom -= TwoRad; } return(GenerateSled(bottom)); case Mobility.PackAnimals: return(GeneratePackAnimals(bottom)); case Mobility.Barge: return(GenerateBarge(bottom)); case Mobility.Amphibious: return(GenerateAmphibious(bottom)); case Mobility.TowedArrayShort: return(GenerateArray(new[] { -End - TwoSqr, 0.0, End + TwoSqr }, bottom + ThreeSqr - HalfWidth)); case Mobility.TowedArrayLong: if (!flat) { bottom -= Sqr + HalfWidth; } return(GenerateArray( new[] { -End - TwoSqr, -HalfEnd - Sqr, 0.0, HalfEnd + Sqr, End + TwoSqr }, bottom + ThreeSqr - HalfWidth)); } return(null); }