public void GetSkillByName()
        {
            var input = new Skill
            {
                Skill_Id         = 1,
                Skill_Name       = "HTML5",
                Associate_Skills = null
            };
            var skill = skillsService.GetSkillByName(input.Skill_Name);

            if (skill == null)
            {
                Assert.Null(skill);
            }
            Assert.NotNull(skill);
            Assert.AreEqual(skill.Skill_Name, input.Skill_Name);
        }
Example #2
0
        public void UpdateSkillTest()
        {
            var skill    = _skillsService.GetSkillByName("TestSkill");
            var response = new SkillModel();
            var request  = Helper.CastObject <SkillModel>(skill);

            request.Skill_Name = "TestSkillUpdated";
            var skillController = new SkillController(_skillsService, _logManager)
            {
                Request = new HttpRequestMessage
                {
                    Method     = HttpMethod.Post,
                    RequestUri = new Uri(ServiceBaseURL + "skill/updateSkill")
                }
            };

            skillController.Configuration = new HttpConfiguration();
            _response = skillController.UpdateSkill(request);
            response  = JsonConvert.DeserializeObject <SkillModel>(_response.Content.ReadAsStringAsync().Result);
            Assert.AreEqual(_response.StatusCode, HttpStatusCode.OK);
            Assert.AreEqual(response != null, true);
            Assert.AreEqual(response.Skill_Name, "TestSkillUpdated");
        }
Example #3
0
        public HttpResponseMessage AddSkill([FromBody] SkillModel skill)
        {
            SkillModel result = new SkillModel();

            try
            {
                var alreadyExists = _skillsService.GetSkillByName(skill.Skill_Name);
                if (alreadyExists == null)
                {
                    var input = Helper.CastObject <Skill>(skill);
                    var res   = _skillsService.CreateSkill(input);
                    result = Helper.CastObject <SkillModel>(res);
                }
            }
            catch (Exception ex)
            {
                _logManager.WriteLog(ex);
            }
            return(ToJson(result));
        }