Exemplo n.º 1
0
        public async Task TestCreate()
        {
            var skill = new Skill()
            {
                Name = "Test Skill"
            };

            skillService.Setup(entity => entity.CreateAsync(skill)).Returns(Task.FromResult(new Skill()
            {
                Name = skill.Name, Id = SkillIdTest
            }));
            httpContextAccessor.Setup(acc => acc.HttpContext.User.Identity.Name).Returns(UserIdStr);

            var skillController = new SkillController(skillService.Object, skillValidation,
                                                      logger.Object, httpContextAccessor.Object);
            var result = await skillController.CreateAsync(skill);

            Assert.IsTrue(result is OkObjectResult);
            Assert.IsTrue(((Skill)((OkObjectResult)result).Value).Id == SkillIdTest);
        }