Ejemplo n.º 1
0
        public void AddAndRetieveSkill()
        {
            //Arrange
            var context      = GetSqlLiteContext();
            var cvService    = new CvService(new CvRepository(context), new Mapper().GetMapper());
            var skillService = new SkillService(new SkillRepository(context), new Mapper().GetMapper());

            var cv = new Cv()
            {
                Name = Constants.CvName, TagLine = Constants.CvTagLine, Blurb = Constants.CvBlurb
            };
            var cvId = cvService.Add(cv, Constants.RootUrl).Id;

            //Act
            var skill = new Skill()
            {
                Name = "Continuous Delivery", Blurb = "Awesome at CI and CD", Order = 12
            };
            var newSkill = skillService.AddToCv(skill, cvId, Constants.RootUrl);

            //Assert
            var skills = skillService.GetForCv(cvId, Constants.RootUrl);
            var result = skills[0];

            Assert.AreEqual(skill.Name, result.Name);
            Assert.AreEqual(skill.Blurb, result.Blurb);
            Assert.AreEqual(skill.Order, result.Order);
            Assert.AreEqual(cvId, result.CvId);
        }
Ejemplo n.º 2
0
        public void CheckUrlsAreCorrect()
        {
            //Arrange
            var context      = GetSqlLiteContext();
            var cvService    = new CvService(new CvRepository(context), new Mapper().GetMapper());
            var skillService = new SkillService(new SkillRepository(context), new Mapper().GetMapper());

            var cv = new Cv()
            {
                Name = Constants.CvName, TagLine = Constants.CvTagLine, Blurb = Constants.CvBlurb
            };
            var cvId = cvService.Add(cv, Constants.RootUrl).Id;

            //Act
            var skill1 = new Skill()
            {
                Name = "Continuous Delivery", Blurb = "Awesome at CI and CD", Order = 5
            };

            skillService.AddToCv(skill1, cvId, Constants.RootUrl);
            var skill2 = new Skill()
            {
                Name = "DevOps", Blurb = "DevOps Master", Order = 3
            };

            skillService.AddToCv(skill2, cvId, Constants.RootUrl);
            var skill3 = new Skill()
            {
                Name = "Agile", Blurb = "Agile Expert", Order = 1
            };

            skillService.AddToCv(skill3, cvId, Constants.RootUrl);
            var skill4 = new Skill()
            {
                Name = "Software Engineering", Blurb = "Since 2001", Order = 2
            };

            skillService.AddToCv(skill4, cvId, Constants.RootUrl);

            //Assert
            var skills = skillService.GetForCv(cvId, Constants.RootUrl);

            foreach (var skill in skills)
            {
                Assert.AreEqual($"{Constants.RootUrl}/cv/{skill.CvId}", skill.Links.Single(o => o.Rel == "cv").Href);
                Assert.AreEqual($"{Constants.RootUrl}/skill/{skill.Id}", skill.Links.Single(o => o.Rel == "self").Href);
            }
        }