public List<Ta> GetTaList() { var errors = new List<string>(); var repository = new TaRepository(this.entities); var service = new TaService(repository); return service.GetTaList(ref errors); }
public void GetTaList() { var errors = new List<string>(); var mockRepository = new Mock<ITaRepository>(); var teachingAssistantService = new TaService(mockRepository.Object); var ta_List = new List<Ta>(); var ta_1 = new Ta { FirstName = "hi", LastName = "bye" }; var ta_2 = new Ta { FirstName = "hi", LastName = "bye" }; var returnTaList = new List<Ta>(); ta_List.Add(ta_1); ta_List.Add(ta_2); mockRepository.Setup(x => x.GetTaList(ref errors)).Returns(ta_List); returnTaList = teachingAssistantService.GetTaList(ref errors); Assert.AreEqual(returnTaList.Count, 2); }