public void CanDetermineNotEvens(int number) { OddEven oddEven = new OddEven(); var result = oddEven.IsEven(number); result.Should().BeFalse(); }
public void IsTwoEven() { // Arrage OddEven sample = new OddEven(); // Act & Assert Assert.IsTrue(sample.IsEven(2)); }
/// <summary> /// 根据设备关系创建线路 /// </summary> /// <param name="device">变电站图元</param> /// <param name="devicSUID">变电站设备ID</param> void createLine(XmlElement device, string devicSUID) { string projectid = Itop.Client.MIS.ProgUID; string strCon = string.Format(" where Type = '01' and projectid='{0}' and svguid='{1}'", projectid, devicSUID); IList list = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon); // SvgElementCollection list2 = tlVectorControl1.SVGDocument.CurrentLayer.GraphList.Clone();// tlVectorControl1.SVGDocument.SelectNodes("svg/use"); XmlNodeList list2 = tlVectorControl1.SVGDocument.SelectNodes("svg/use"); float scale = tlVectorControl1.ScaleRatio; //scale = 1; foreach (PSPDEV dev in list) { foreach (SvgElement element in list2) { if (!(element is Use)) { continue; } ///XmlElement element = node as XmlElement; //XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + element.GetAttribute("id") + "']"); string deviceid = (element).GetAttribute("Deviceid"); if (string.IsNullOrEmpty(deviceid)) { continue; } if (devicSUID == deviceid) { continue; } string strCon1 = string.Format(" where Type = '01' and projectid='{0}' and svguid='{1}'", projectid, deviceid); //" where projectid='" + projectid + "' AND SvgUID = '" + (element).GetAttribute("Deviceid") + "' AND Type = '01'"; string label = element.GetAttribute("info-name"); IList list3 = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon1); foreach (PSPDEV pd in list3) { // if (dev.Number != pd.Number) { string strCon2 = " where projectid = '" + projectid + "' AND Type = '05' AND IName = '" + dev.Name + "' AND JName = '" + pd.Name + "'"; IList list4 = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon2); string strCon3 = "where projectid = '" + projectid + "' AND Type = '05' AND IName = '" + pd.Name + "' AND JName = '" + dev.Name + "'"; IList list5 = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon3); float width = ((IGraph)element).GetBounds().Width / 3; for (int i = 0; i < list4.Count; i++) { //判断次图上是否已经有此线路 XmlNodeList xnl = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@Deviceid='" + ((PSPDEV)list4[i]).SUID + "']"); if (xnl.Count > 0) { continue; } PointF[] t2 = new PointF[] { ((IGraph)device).CenterPoint, ((IGraph)element).CenterPoint }; float angel = 0f; angel = (float)(180 * Math.Atan2((t2[1].Y - t2[0].Y), (t2[1].X - t2[0].X)) / Math.PI); PointF pStart1 = new PointF(((IGraph)device).CenterPoint.X + (float)(width * ((i + 1) / 2) * Math.Sin((angel) * Math.PI / 180)), ((IGraph)device).CenterPoint.Y - (float)(width * ((i + 1) / 2) * Math.Cos((angel) * Math.PI / 180))); PointF pStart2 = new PointF(((IGraph)device).CenterPoint.X - (float)(width * (i / 2) * Math.Sin((angel) * Math.PI / 180)), ((IGraph)device).CenterPoint.Y + (float)(width * (i / 2) * Math.Cos((angel) * Math.PI / 180))); PointF pStart3 = new PointF(((IGraph)element).CenterPoint.X + (float)(width * ((i + 1) / 2) * Math.Sin((angel) * Math.PI / 180)), ((IGraph)element).CenterPoint.Y - (float)(width * ((i + 1) / 2) * Math.Cos((angel) * Math.PI / 180))); PointF pStart4 = new PointF(((IGraph)element).CenterPoint.X - (float)(width * (i / 2) * Math.Sin((angel) * Math.PI / 180)), ((IGraph)element).CenterPoint.Y + (float)(width * (i / 2) * Math.Cos((angel) * Math.PI / 180))); string temp = ""; if (i == 0) { temp = ((IGraph)device).CenterPoint.X.ToString() + " " + ((IGraph)device).CenterPoint.Y.ToString() + "," + ((IGraph)element).CenterPoint.X + " " + ((IGraph)element).CenterPoint.Y.ToString(); } else if (OddEven.IsOdd(i)) { temp = pStart1.X.ToString() + " " + pStart1.Y.ToString() + "," + pStart3.X.ToString() + " " + pStart3.Y.ToString(); } else if (OddEven.IsEven(i)) { temp = pStart2.X.ToString() + " " + pStart2.Y.ToString() + "," + pStart4.X.ToString() + " " + pStart4.Y.ToString(); } XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline; n1.SetAttribute("points", temp); n1.SetAttribute("IsLead", "1"); n1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); //决定线路在那条图层上:本级图层中有包含“线路”两字的图层,则生成到此图层; 如果有多个包含“线路”的图层,则生成到第一个; 如果没有包含“线路”的图层,则生成到当前选择图层。 //ArrayList layercol = tlVectorControl1.SVGDocument.getLayerList(); ArrayList layercol = frmlar.getBrotherLayers(); bool jsflag = false; for (int m = 0; m < layercol.Count; m++) { if ((layercol[m] as Layer).GetAttribute("id") == SvgDocument.currentLayer && !(layercol[m] as Layer).GetAttribute("label").Contains("线路")) { continue; } else if ((layercol[m] as Layer).GetAttribute("id") != SvgDocument.currentLayer && !(layercol[m] as Layer).GetAttribute("label").Contains("线路")) { continue; } else if ((layercol[m] as Layer).GetAttribute("id") == SvgDocument.currentLayer && (layercol[m] as Layer).GetAttribute("label").Contains("线路")) { n1.SetAttribute("layer", SvgDocument.currentLayer); jsflag = true; break; } else if ((layercol[m] as Layer).GetAttribute("id") != SvgDocument.currentLayer && (layercol[m] as Layer).GetAttribute("label").Contains("线路")) { n1.SetAttribute("layer", (layercol[m] as Layer).GetAttribute("id")); jsflag = true; break; } } if (!jsflag) { n1.SetAttribute("layer", SvgDocument.currentLayer); } n1.SetAttribute("FirstNode", device.GetAttribute("id")); n1.SetAttribute("LastNode", element.GetAttribute("id")); n1.SetAttribute("Deviceid", ((PSPDEV)list4[i]).SUID); SetPolyLineType(n1, (PSPDEV)list4[i]); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.ChangeLevel(LevelType.Bottom); //n1.RemoveAttribute("layer"); tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.SVGDocument.CurrentElement = element as SvgElement; } int j = 0; if (list4 != null) { j = list4.Count; } for (int i = j; i < j + list5.Count; i++) { //判断次图上是否已经有此线路 XmlNodeList xnl = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@Deviceid='" + ((PSPDEV)list5[i - j]).SUID + "']"); if (xnl.Count > 0) { continue; } PointF[] t2 = new PointF[] { ((IGraph)element).CenterPoint, ((IGraph)device).CenterPoint }; float angel = 0f; angel = (float)(180 * Math.Atan2((t2[1].Y - t2[0].Y), (t2[1].X - t2[0].X)) / Math.PI); PointF pStart1 = new PointF(((IGraph)element).CenterPoint.X + (float)(width * ((i + 1) / 2) * Math.Sin((angel) * Math.PI / 180)), ((IGraph)element).CenterPoint.Y - (float)(width * ((i + 1) / 2) * Math.Cos((angel) * Math.PI / 180))); PointF pStart2 = new PointF(((IGraph)element).CenterPoint.X - (float)(width * (i / 2) * Math.Sin((angel) * Math.PI / 180)), ((IGraph)element).CenterPoint.Y + (float)(width * (i / 2) * Math.Cos((angel) * Math.PI / 180))); PointF pStart3 = new PointF(((IGraph)device).CenterPoint.X + (float)(width * ((i + 1) / 2) * Math.Sin((angel) * Math.PI / 180)), ((IGraph)device).CenterPoint.Y - (float)(width * ((i + 1) / 2) * Math.Cos((angel) * Math.PI / 180))); PointF pStart4 = new PointF(((IGraph)device).CenterPoint.X - (float)(width * (i / 2) * Math.Sin((angel) * Math.PI / 180)), ((IGraph)device).CenterPoint.Y + (float)(width * (i / 2) * Math.Cos((angel) * Math.PI / 180))); string temp = ""; if (i == 0) { temp = ((IGraph)element).CenterPoint.X.ToString() + " " + ((IGraph)element).CenterPoint.Y.ToString() + "," + ((IGraph)device).CenterPoint.X + " " + ((IGraph)device).CenterPoint.Y.ToString(); } else if (OddEven.IsOdd(i)) { temp = pStart1.X.ToString() + " " + pStart1.Y.ToString() + "," + pStart3.X.ToString() + " " + pStart3.Y.ToString(); } else if (OddEven.IsEven(i)) { temp = pStart2.X.ToString() + " " + pStart2.Y.ToString() + "," + pStart4.X.ToString() + " " + pStart4.Y.ToString(); } //ArrayList layercol = tlVectorControl1.SVGDocument.getLayerList(); ArrayList layercol = frmlar.getBrotherLayers(); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline; n1.SetAttribute("points", temp); n1.SetAttribute("IsLead", "1"); n1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); bool jsflag = false; for (int m = 0; m < layercol.Count; m++) { if ((layercol[m] as Layer).ID == SvgDocument.currentLayer && !(layercol[m] as Layer).Label.Contains("线路")) { continue; } else if ((layercol[m] as Layer).ID != SvgDocument.currentLayer && !(layercol[m] as Layer).Label.Contains("线路")) { continue; } else if ((layercol[m] as Layer).ID == SvgDocument.currentLayer && (layercol[m] as Layer).Label.Contains("线路")) { n1.SetAttribute("layer", SvgDocument.currentLayer); jsflag = true; break; } else if ((layercol[m] as Layer).ID != SvgDocument.currentLayer && (layercol[m] as Layer).Label.Contains("线路")) { n1.SetAttribute("layer", (layercol[m] as Layer).ID); jsflag = true; break; } } if (!jsflag) { n1.SetAttribute("layer", SvgDocument.currentLayer); } n1.SetAttribute("FirstNode", element.GetAttribute("id")); n1.SetAttribute("LastNode", device.GetAttribute("id")); n1.SetAttribute("Deviceid", ((PSPDEV)list5[i - j]).SUID); SetPolyLineType(n1, (PSPDEV)list5[i - j]); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.ChangeLevel(LevelType.Bottom); //n1.RemoveAttribute("layer"); tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.SVGDocument.CurrentElement = element as SvgElement; } } } } } }