private void btn_Save_Click(object sender, EventArgs e) { DBInfo info = new DBInfo() { Uid = txt_Uid.Text.Trim(), DBName = txt_DBName.Text.Trim(), Server = txt_Server.Text.Trim(), Port = txt_Port.Text.Trim(), Pwd = txt_PWD.Text.Trim(), Type = (DBEnum)cbx_DBType.SelectedIndex + 1 }; var connect = GetDBLink.GetTableList(info); if (string.IsNullOrEmpty(connect) == false) { MessageBox.Show($"非有效数据库连接,明细:{connect}"); return; } var result = XMLNodeHelper.NodeAdd(DBLink, info); if (string.IsNullOrEmpty(result) == false) { MessageBox.Show($"添加出现错误,明细:{result}"); } else { this.Close(); } }
public void GetStringValue_1() { //Arrange XmlDocument Menu = new XmlDocument(); Menu.LoadXml("<breakfast_menu>" + "<food1>" + "<name>Belgian Waffles</name>" + "<price>$5.95</price >" + "</food1>" + "<food2>" + "<name>Strawberry Belgian Waffles</name>" + "<price>$7.95</price>" + "</food2>" + "<food3>" + "<name>Homestyle Breakfast</name>" + "<price>$6.95</price>" + "</food3>" + "<food4>" + "<name>French Toast</name>" + "<price>$4.50</price>" + "</food4>" + "</breakfast_menu>"); string xPath = ("/breakfast_menu/food1/name"); //Act string returnModel = XMLNodeHelper.GetStringValue(Menu, xPath); //Assert returnModel.Should().Be("Belgian Waffles"); }
public void GetIntValue_3_Doc() { //Arrange XmlDocument Menu = new XmlDocument(); Menu.LoadXml("<breakfast_menu>" + "<food1>" + "<name>Belgian Waffles</name>" + "<rating>7</rating>" + "</food1>" + "<food2>" + "<name>Strawberry Belgian Waffles</name>" + "<rating>8</rating>" + "</food2>" + "<food3>" + "<name>Homestyle Breakfast</name>" + "<rating>1</rating>" + "</food3>" + "<food4>" + "<name>French Toast</name>" + "<rating>10</rating>" + "</food4>" + "</breakfast_menu>"); string xPath = ("/breakfast_menu/food2/rating"); //Act int returnModel = XMLNodeHelper.GetIntValue(Menu, xPath); //Assert returnModel.Should().Be(8); }
private void DelDB_Click(object sender, EventArgs e) { if (CurrentNode != null) { var result = XMLNodeHelper.NodeRemove(Path.Combine(BEContent.SelectedProject.ABEPath, "Config", "DBLinkInfo.xml"), CurrentNode.Name); if (string.IsNullOrEmpty(result)) { BindData(true); MessageBox.Show("操作成功"); } else { MessageBox.Show(result); } } }
public void GetIntValue_1_Node() { //Arrange XmlDocument Menu = new XmlDocument(); Menu.LoadXml("<breakfast_menu>" + "<food>" + "<name1>Belgian Waffles</name1>" + "<rating>7</rating>" + "</food>" + "<food>" + "<name>Strawberry Belgian Waffles</name>" + "<rating>8</rating>" + "</food>" + "<food>" + "<name>Homestyle Breakfast</name>" + "<rating>1</rating>" + "</food>" + "<food>" + "<name>French Toast</name>" + "<rating>10</rating>" + "</food>" + "</breakfast_menu>"); XmlNode node = Menu.FirstChild; XmlNode node2 = node.FirstChild; string xPath = ("/breakfast_menu/food/rating"); //Act int returnModel = XMLNodeHelper.GetIntValue(node2, xPath); //Assert returnModel.Should().Be(7); }