public void SetProjectNameTest() { Link link = new Link("test2", "test2", "www.test.com"); Assert.IsTrue(link.SetProjectName("test2")); }
public void SetLinkTest() { Link link = new Link("test2", "test2", "www.test.com"); Assert.IsTrue(link.SetLink("www.test.org")); }
public void SetDescriptionTest() { Link link = new Link("test2", "test2", "www.test.com"); Assert.IsTrue(link.SetDescription("test2")); }
public void ConstructorTest() { Link link = new Link("test", "test2", "www.test.com"); Assert.IsNotNull(link); }
public bool DeleteLink(Link link) { bool flag; using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString)) { using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = "DELETE FROM [dbo].[Link] WHERE RoadmapName = @Rname AND ProjectName = @Pname AND Address = @addr"; cmd.Parameters.AddWithValue("@Pname", mName); cmd.Parameters.AddWithValue("@Rname", mRoadmapName); cmd.Parameters.AddWithValue("@addr", link.GetLink()); cmd.Connection = conn; conn.Open(); flag = cmd.ExecuteNonQuery() != 0; conn.Close(); } } mLinks.Remove(link); return flag; }
//Create and delete links in list and DB public bool CreateLink(Link link) { bool flag; using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString)) { using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = "INSERT INTO [dbo].[Link] (Description, ProjectName, Address, RoadmapName) VALUES (@descrip,@Pname, @addr,@Rname)"; cmd.Parameters.AddWithValue("@descrip", link.GetDescription()); cmd.Parameters.AddWithValue("@Pname", mName); cmd.Parameters.AddWithValue("@addr", link.GetLink()); cmd.Parameters.AddWithValue("@Rname", mRoadmapName); cmd.Connection = conn; conn.Open(); flag = cmd.ExecuteNonQuery() != 0; conn.Close(); } } return flag; }