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)); }
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); }
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()); }
public void Remove(Skill entity) { _skillsRepository.Remove(entity); }
public void Add(Skill newEntity) { _skillsRepository.Add(newEntity); }