コード例 #1
0
        public void Add_DLAddIsInvoked()
        {
            Skill skill = new Skill() { SkillName = "C#" };
            var mockSkillsRepo = MockRepository.GenerateMock<DL.Interfaces.IRepository<Skill>>();
            ISkillsBL skillsBl = new BL.SkillsBL(mockSkillsRepo);

            skillsBl.Add(skill);

            mockSkillsRepo.AssertWasCalled(x => x.Add(skill));
        }
コード例 #2
0
        public void FindById_DLFindByIdIsInvoked_ReturnsValue()
        {
            int id1 = 1;
            int id2 = 2;
            Skill skill1 = new Skill { Id = id1, SkillName = "C#" };
            Skill skill2 = new Skill { Id = id2, SkillName = "JavaScript" };
            Skill expectedValue = skill1;

            var mockSkillsRepo = MockRepository.GenerateMock<DL.Interfaces.IRepository<Skill>>();
            mockSkillsRepo.Stub(x => x.FindById(id1)).Return(skill1);
            ISkillsBL skillBL = new BL.SkillsBL(mockSkillsRepo);

            Skill actualValue = skillBL.FindById(id1);

            mockSkillsRepo.AssertWasCalled(m => m.FindById(id1));
            Assert.AreEqual(expectedValue, actualValue);
        }
コード例 #3
0
        public void Find_DLFindIsInvoked_ReturnsValue()
        {
            int id1 = 1;
            int id2 = 2;
            Skill skill1 = new Skill { Id = id1, SkillName = "C#" };
            Skill skill2 = new Skill { Id = id2, SkillName = "JavaScript" };
            IQueryable<Skill> skills = new List<Skill>() { skill1, skill2 }.AsQueryable();
            IQueryable<Skill> expectedValue = skills.Where(x => x.SkillName == "C#");
            Expression<Func<Skill, bool>> queryExpression = (x => x.SkillName == "C#");
            var mockSkillsRepo = MockRepository.GenerateMock<DL.Interfaces.IRepository<Skill>>();
            mockSkillsRepo.Stub(x => x.Find(queryExpression)).Return(skills.Where(x => x.SkillName == "C#"));
            ISkillsBL skillBL = new BL.SkillsBL(mockSkillsRepo);

            IQueryable<Skill> actualValue = skillBL.Find(queryExpression);

            mockSkillsRepo.AssertWasCalled(m => m.Find(queryExpression));
            Assert.AreEqual(expectedValue.Count(), actualValue.Count());
        }
コード例 #4
0
 public void Remove(Skill entity)
 {
     _skillsRepository.Remove(entity);
 }
コード例 #5
0
 public void Add(Skill newEntity)
 {
     _skillsRepository.Add(newEntity);
 }