public async Task GetSkillNotFoundTest()
        {
            // Arrange
            var repo       = new FakeSkillRepository(TestData.Skills());
            var controller = new SkillsController(repo, null);
            var skillId    = 76;

            // Act
            var result = await controller.GetSkill(skillId);

            // Assert
            Assert.IsNotNull(result);
            var objResult = result.Result as NotFoundResult;

            Assert.IsNotNull(objResult);
        }
        public async Task GetSkillTest()
        {
            // Arrange
            var repo       = new FakeSkillRepository(TestData.Skills());
            var controller = new SkillsController(repo, null);
            var skillId    = 1;

            // Act
            var result = await controller.GetSkill(skillId);

            // Assert
            Assert.IsNotNull(result);
            var testItem  = TestData.Skills().Find(s => s.Id == skillId);
            var objResult = result.Result as OkObjectResult;

            Assert.IsNotNull(objResult);
            var retResult = objResult.Value as SkillDTO;

            Assert.IsNotNull(retResult);
            Assert.AreEqual(testItem.Id, retResult.Id);
            Assert.AreEqual(testItem.Name, retResult.Name);
        }
Ejemplo n.º 3
0
        public async void TestReturnSkillsWithId()
        {
            var options = new DbContextOptionsBuilder <Databasecontext
                                                       >().UseInMemoryDatabase(databaseName: "Test")
                          .Options;

            using (var context = new Databasecontext(options))
            {
                var skill = new Skill()
                {
                    SkillId     = 1,
                    SkillName   = "test",
                    Description = "test"
                };
                context.Add(skill);
                context.SaveChanges();
                SkillsController Skills = new SkillsController(context);

                var skills = await Skills.GetSkill(1);

                Skill result = skills.Value;
                Assert.Equal("test", result.Description);
            }
        }
        public async Task GetAllSkillsTest()
        {
            // Arrange
            var repo       = new FakeSkillRepository(TestData.Skills());
            var controller = new SkillsController(repo, null);

            // Act
            var result = await controller.GetSkill();

            // Assert
            Assert.IsNotNull(result);
            var objResult = result.Result as OkObjectResult;

            Assert.IsNotNull(objResult);
            var retResult = objResult.Value as List <SkillDTO>;

            Assert.IsNotNull(retResult);
            Assert.AreEqual(TestData.Skills().Count, retResult.Count);
            foreach (var skill in retResult)
            {
                var testItem = TestData.Skills().Find(s => s.Id == skill.Id);
                Assert.AreEqual(testItem.Name, skill.Name);
            }
        }
        public void GetSkillTest()
        {
            var skillsList = skillsController.GetSkill(1);

            Assert.IsNotNull(skillsList);
        }