示例#1
0
        public void SetProjectNameTest()
        {
            Link link = new Link("test2", "test2", "www.test.com");

            Assert.IsTrue(link.SetProjectName("test2"));
        }
示例#2
0
        public void SetLinkTest()
        {
            Link link = new Link("test2", "test2", "www.test.com");

            Assert.IsTrue(link.SetLink("www.test.org"));
        }
示例#3
0
        public void SetDescriptionTest()
        {
            Link link = new Link("test2", "test2", "www.test.com");

            Assert.IsTrue(link.SetDescription("test2"));
        }
示例#4
0
 public void ConstructorTest()
 {
     Link link = new Link("test", "test2", "www.test.com");
     Assert.IsNotNull(link);
 }
示例#5
0
        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;
        }
示例#6
0
        //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;
        }