public void StrategyPointTest() { StrategyPoint sp = new StrategyPoint("Test", "TEST"); Assert.AreEqual("Test", sp.GetName()); Assert.AreEqual("TEST", sp.GetDescription()); List<BusinessValue> values = sp.GetBusinessValues(); Assert.AreEqual(1, values.Count()); }
public static void AddStrat(string id, string name, string color, string mapName) { RoadMap map = new RoadMap(mapName); int n = map.GetStrategyPoints().Count; StrategyPoint point = new StrategyPoint(id, name, mapName); map.AddStrategyPoint(point); point.EditColor(color); }
public void EditStrategyPointTest() { StrategyPoint sp = new StrategyPoint("Test", "TEST"); Assert.IsTrue(sp.EditDescription("NEW")); Assert.AreEqual("NEW", sp.GetDescription()); Assert.IsTrue(sp.EditName("NEW")); Assert.AreEqual("NEW", sp.GetName()); StrategyPoint testsp = new StrategyPoint("NEW", "NEW"); Assert.AreEqual("NEW", sp.GetName()); Assert.AreEqual("NEW", sp.GetDescription()); Assert.IsTrue(sp.EditName("Test")); Assert.IsTrue(sp.EditDescription("TEST")); }
public void RoadMapTest() { RoadMap map = new RoadMap("Test"); Assert.AreEqual("TEST", map.GetDecription()); Assert.AreEqual("Test", map.GetName()); Assert.AreEqual("10/6/2015 1:53:46 PM", map.GetTimeStamp().ToString()); Assert.AreEqual("123", map.GetUser().GetUserName()); TimeLine timeline = new TimeLine("Test"); TimeLine test = map.GetTimeline(); Assert.AreEqual( timeline.GetID(), test.GetID()); StrategyPoint sp = new StrategyPoint("Test", "TEST"); List<StrategyPoint> spTest = map.GetStrategyPoints(); Assert.AreEqual(sp.GetName(), spTest.First().GetName()); }
//Reorders strategy points to insert one in the middle public void ReOrderStrategyPoint(string currname,string desc, bool isFirst) { //Get current strategy point StrategyPoint current = new StrategyPoint(currname, desc, mName); int index = (int)Char.GetNumericValue(currname[8]) + 1; string nextID = "StratBox"+index.ToString(); string nextdesc=null; //Move next one up string selectname = null; if (isFirst) selectname = currname; else selectname = nextID; using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString)) { using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = "SELECT Description FROM [dbo].[StrategyPoint] WHERE Name=@sname AND RoadmapName=@Rname"; cmd.Parameters.AddWithValue("@sname", selectname); cmd.Parameters.AddWithValue("@Rname", mName); cmd.Connection = conn; conn.Open(); using (SqlDataReader Reader = cmd.ExecuteReader()) { if (Reader.HasRows) { Reader.Read(); nextdesc = Reader.GetString(0); } Reader.Close(); } conn.Close(); } } //Continue moving strat points up one StrategyPoint next = new StrategyPoint(nextID, nextdesc, mName); StrategyPoint nextdummy = new StrategyPoint(currname, nextdesc, mName); if (nextdesc != null) { nextdummy.EditName(nextID); ReOrderStrategyPoint(nextID, nextdesc, false); } }
//Reloads list of strategy points public void ReloadStrategyPoints() { mStrategyPoints = new List<StrategyPoint>(); using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString)) { using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = "SELECT Name, Description FROM [dbo].[StrategyPoint] WHERE RoadmapName = @Rname ORDER BY NAME ASC"; cmd.Parameters.AddWithValue("@Rname", mName); cmd.Connection = conn; conn.Open(); using (SqlDataReader Reader = cmd.ExecuteReader()) { while (Reader.Read()) { StrategyPoint sp = new StrategyPoint(Reader.GetString(0), Reader.GetString(1), mName); mStrategyPoints.Add(sp); } } conn.Close(); } } }
//CONSTRUCTOR public RoadMap( string name ) { mName = name; string UID; using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString)) { using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = "SELECT Timestamp, Description, UserID, color_dep_of, color_dep_on FROM [dbo].[Roadmap] WHERE Name =@Rname"; cmd.Parameters.AddWithValue("@Rname", name); cmd.Connection = conn; conn.Open(); using (SqlDataReader Reader = cmd.ExecuteReader()) { Reader.Read(); mTimeStamp = Reader.GetDateTime(0); mDescription = Reader.GetString(1); UID = Reader.GetString(2); try { mColor_of = Reader.GetString(3); mColor_on = Reader.GetString(4); } catch { mColor_of = "#ffff00"; mColor_on = "#ff66ff"; } } } using (SqlCommand cmd1 = new SqlCommand()) { cmd1.CommandText = "SELECT Name, Email, Password FROM [dbo].[User] WHERE ID = @User"; cmd1.Parameters.AddWithValue("@User", UID); cmd1.Connection = conn; using (SqlDataReader Reader = cmd1.ExecuteReader()) { Reader.Read(); mUser = new User(Reader.GetString(0), UID, Reader.GetString(1), Reader.GetString(2)); } } mTimeline = new TimeLine(mName); //Get the StrategyPoints using (SqlCommand cmd3 = new SqlCommand()) { cmd3.CommandText = "SELECT Name, Description FROM [dbo].[StrategyPoint] WHERE RoadmapName =@Rname ORDER BY SORT ASC"; cmd3.Parameters.AddWithValue("@Rname", mName); cmd3.Connection = conn; using (SqlDataReader Reader = cmd3.ExecuteReader()) { while (Reader.Read()) { StrategyPoint sp = new StrategyPoint(Reader.GetString(0), Reader.GetString(1), name); mStrategyPoints.Add(sp); } } } conn.Close(); } }
//Add strategy point to roadmap public bool AddStrategyPoint(StrategyPoint point) { mStrategyPoints.Add(point); bool flag; int order = Convert.ToInt32(point.GetName().Substring(8, (point.GetName().Length) - 8)); using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString)) { using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = "INSERT INTO [dbo].[StrategyPoint] ([Name],[Description],[RoadmapName],[Sort]) VALUES (@Sname,@descrip,@Rname,@sort)"; cmd.Parameters.AddWithValue("@Sname", point.GetName()); cmd.Parameters.AddWithValue("@descrip", point.GetDescription()); cmd.Parameters.AddWithValue("@Rname", mName); cmd.Parameters.AddWithValue("@sort", order); cmd.Connection = conn; conn.Open(); flag = cmd.ExecuteNonQuery() != 0; conn.Close(); } } return flag; }