Exemplo n.º 1
0
 public void TestGetCommandReturnsTrueWithNonExistingSkillAndAddsItToTheDatabase()
 {
     string skill = "python";
     InsertSkill ins = new InsertSkill();
     bool insert = ins.GetCommand(skill);
     Assert.IsTrue(insert);
 }
Exemplo n.º 2
0
 public void TestFormatSkillReturnsCorrectSkillString()
 {
     string skill = "dot net";
     InsertSkill ins = new InsertSkill();
     string newSkill = ins.FormatSkill(skill);
     Assert.AreEqual("Dot Net", newSkill);
 }
Exemplo n.º 3
0
 public void TestGetCommandReturnsTrueWithExistingSkill()
 {
     string skill = "SQL";
     InsertSkill ins = new InsertSkill();
     string newSkill = ins.FormatSkill(skill);
     Assert.IsTrue(ins.GetCommand(skill));
 }
Exemplo n.º 4
0
        public bool GetCommand(string skill, int userID)
        {
            ConnectionString cnString = new ConnectionString();
            IDbConnection cn = new OleDbConnection(cnString.GetConnString());

            try
            {
                cn.Open();
                IDbTransaction tran = cn.BeginTransaction();

                // Add userskill
                IDbCommand cmd = new OleDbCommand("sp_del_userSkill", (OleDbConnection)cn);
                cmd.Transaction = tran;
                cmd.CommandType = CommandType.StoredProcedure;

                Console.WriteLine(userID);
                InsertSkill ins = new InsertSkill();
                string formattedSkill = ins.FormatSkill(skill);
                GetSkillId id = new GetSkillId();
                int skillid = int.Parse(id.Read(formattedSkill));
                cmd.Parameters.Add(new OleDbParameter("@userID", int.Parse(userID.ToString())));
                cmd.Parameters.Add(new OleDbParameter("@skillID", int.Parse(skillid.ToString())));
                int affectedRows = cmd.ExecuteNonQuery();

                if (affectedRows > 0)
                {
                    tran.Commit();

                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch(Exception e)
            {

                Console.WriteLine(e.Message);
                return false;
            }
        }
Exemplo n.º 5
0
        public bool GetCommand(string skill, int userID)
        {
            ConnectionString cnString = new ConnectionString();
            IDbConnection    cn       = new OleDbConnection(cnString.GetConnString());

            try
            {
                cn.Open();
                IDbTransaction tran = cn.BeginTransaction();

                // Add userskill
                IDbCommand cmd = new OleDbCommand("sp_del_userSkill", (OleDbConnection)cn);
                cmd.Transaction = tran;
                cmd.CommandType = CommandType.StoredProcedure;

                Console.WriteLine(userID);
                InsertSkill ins            = new InsertSkill();
                string      formattedSkill = ins.FormatSkill(skill);
                GetSkillId  id             = new GetSkillId();
                int         skillid        = int.Parse(id.Read(formattedSkill));
                cmd.Parameters.Add(new OleDbParameter("@userID", int.Parse(userID.ToString())));
                cmd.Parameters.Add(new OleDbParameter("@skillID", int.Parse(skillid.ToString())));
                int affectedRows = cmd.ExecuteNonQuery();

                if (affectedRows > 0)
                {
                    tran.Commit();

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(false);
            }
        }
Exemplo n.º 6
0
 public void TestDetermineIfExistsReturnsTrueWithExistingSkill()
 {
     InsertSkill ins = new InsertSkill();
     Assert.IsTrue(ins.DetermineIfExists("java"));
 }
Exemplo n.º 7
0
 public void TestDetermineIfExistsReturnsFalseWithNonExistingSkill()
 {
     InsertSkill ins = new InsertSkill();
     Assert.IsFalse(ins.DetermineIfExists("prolog"));
 }
Exemplo n.º 8
0
        public string FormatSkill(string skill)
        {
            InsertSkill insSkill = new InsertSkill();

            return(insSkill.FormatSkill(skill));
        }
Exemplo n.º 9
0
        public bool InsertSkill(string skill)
        {
            InsertSkill insSkill = new InsertSkill();

            return(insSkill.GetCommand(skill));
        }
Exemplo n.º 10
0
 public bool InsertSkill(string skill)
 {
     InsertSkill insSkill = new InsertSkill();
     return insSkill.GetCommand(skill);
 }
Exemplo n.º 11
0
 public string FormatSkill(string skill)
 {
     InsertSkill insSkill = new InsertSkill();
     return insSkill.FormatSkill(skill);
 }