Esempio n. 1
0
        public void GetSkillsThatTheProgrammerDoesNotHave_InvalidProfileId_ShouldBeThrownValidationException()
        {
            Mock <IUnitOfWork> uow     = new Mock <IUnitOfWork>();
            SkillService       service = new SkillService(uow.Object);

            uow.Setup(a => a.ProgrammerProfiles.Get(It.IsAny <string>())).Returns((ProgrammerProfile)null);
            service.GetSkillsThatTheProgrammerDoesNotHave(It.IsAny <string>());
        }
Esempio n. 2
0
        public void GetSkillsThatTheProgrammerDoesNotHave_GetSkillsWithCorrectProfileId_ShouldBeRecieved()
        {
            Mock <IUnitOfWork> mock    = new Mock <IUnitOfWork>();
            IUnitOfWork        uow     = mock.Object;
            SkillService       service = new SkillService(uow);

            IEnumerable <Skill> skills = new List <Skill>
            {
                new Skill()
                {
                    Id = 1, Name = "C#"
                },
                new Skill()
                {
                    Id = 2, Name = "Java"
                },
                new Skill()
                {
                    Id = 3, Name = "PHP"
                }
            };
            IEnumerable <ProgrammerSkill> programmerSkills = new List <ProgrammerSkill>
            {
                new ProgrammerSkill()
                {
                    SkillId = 1, ProgrammerId = "1"
                }
            };
            var expected = new List <Skill>
            {
                new Skill()
                {
                    Id = 2, Name = "Java"
                },
                new Skill()
                {
                    Id = 3, Name = "PHP"
                }
            };

            mock.Setup(a => a.ProgrammerProfiles.Get(It.IsAny <string>())).Returns(new ProgrammerProfile());
            mock.Setup(a => a.ProgrammerSkills.GetAll()).Returns(programmerSkills);
            mock.Setup(a => a.Skills.GetAll()).Returns(skills);
            var actual = service.GetSkillsThatTheProgrammerDoesNotHave("1");

            CollectionAssert.AreEquivalent(actual.Select(x => x.Id).ToList(), expected.Select(x => x.Id).ToList());
            CollectionAssert.AreEquivalent(actual.Select(x => x.Name).ToList(), expected.Select(x => x.Name).ToList());
        }