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 List<TA> GetTAList() { var errors = new List<string>(); var repository = new TARepository(); var service = new TaService(repository); return service.GetTAList(ref errors); }
public Ta GetTa(int id) { var errors = new List<string>(); var repository = new TaRepository(this.entities); var service = new TaService(repository); return service.GetTaById(id, ref errors); }
public void InsertTaErrorTest() { //// Arrange var errors = new List<string>(); var mockRepository = new Mock<ITARepository>(); var taservice = new TaService(mockRepository.Object); //// Act taservice.InsertTA(null, ref errors); //// Assert Assert.AreEqual(1, errors.Count); }
public string InsertTa(Ta ta) { var errors = new List<string>(); var repository = new TaRepository(this.entities); var service = new TaService(repository); service.InsertTa(ta, ref errors); if (errors.Count == 0) { return "ok"; } return "error"; }
public void DeleteTaErrorTest() { //// Arrange var errors = new List<string>(); var mockRepository = new Mock<ITaRepository>(); var teachingAssistantService = new TaService(mockRepository.Object); //// Act teachingAssistantService.DeleteTa(0, ref errors); //// Assert instructor id cannot be null Assert.AreEqual(1, errors.Count); }
public string InsertTa(TA ta) { var errors = new List<string>(); var repository = new TARepository(); var service = new TaService(repository); service.InsertTA(null, ref errors); if (errors.Count == 0) { return "ok"; } return "error"; }
public void InsertTaErrorTest2() { //// Arranage var errors = new List<string>(); var mockRepository = new Mock<ITARepository>(); var taservice = new TaService(mockRepository.Object); var ta = new TA { TA_Id = string.Empty }; //// Act taservice.InsertTA(ta, ref errors); //// Assert Assert.AreEqual(1, errors.Count); }
public string DeleteTa(int id) { var errors = new List<string>(); var repository = new TaRepository(this.entities); var service = new TaService(repository); service.DeleteTa(id, ref errors); if (errors.Count == 0) { return "ok"; } return "error"; }
public void GetTa() { var errors = new List<string>(); var mockRepository = new Mock<ITaRepository>(); var teachingAssistantService = new TaService(mockRepository.Object); var ta_1 = new Ta { FirstName = "hi", LastName = "bye", TaId = 5 }; var returnTa = new Ta(); mockRepository.Setup(x => x.FindTaById(5, ref errors)).Returns(ta_1); returnTa = teachingAssistantService.GetTaById(5, ref errors); Assert.AreEqual(returnTa.TaId, 5); Assert.AreEqual(returnTa.FirstName, "hi"); Assert.AreEqual(returnTa.LastName, "bye"); }
public void DeleteTa() { //// Arranage var errors = new List<string>(); var mockRepository = new Mock<ITaRepository>(); var ta_Service = new TaService(mockRepository.Object); mockRepository.Setup(x => x.RemoveTa(2, ref errors)); //// Act ta_Service.DeleteTa(2, ref errors); //// Assert mockRepository.Verify(x => x.RemoveTa(2, ref errors), Times.Once()); }
public string UpdateStudent(TA ta) { var errors = new List<string>(); var repository = new TARepository(); var service = new TaService(repository); service.UpdateTA(ta, ref errors); if (errors.Count == 0) { return "ok"; } return "error"; }
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); }
public void InsertTa() { //// Arranage var errors = new List<string>(); var mockRepository = new Mock<ITaRepository>(); var ta_Service = new TaService(mockRepository.Object); var ta_1 = new Ta { TaId = 2, TaType = "bb", FirstName = "cc", LastName = "dd" }; mockRepository.Setup(x => x.AddTa(ta_1, ref errors)); mockRepository.Setup(x => x.IsNotDuplicateTa(ta_1, ref errors)).Returns(true); //// Act ta_Service.InsertTa(ta_1, ref errors); //// Assert mockRepository.Verify(x => x.AddTa(ta_1, ref errors), Times.Once()); }
public void UpdateTaErrorTest3() { //// Arranage var errors = new List<string>(); var mockRepository = new Mock<ITaRepository>(); var teachingAssistantService = new TaService(mockRepository.Object); var ta = new Ta { FirstName = "nick", LastName = string.Empty }; //// Act teachingAssistantService.UpdateTa(ta, ref errors); //// Assert last name cannot be empty Assert.AreEqual(1, errors.Count); }
public void UpdateTaErrorTest1() { //// Arranage var errors = new List<string>(); var mockRepository = new Mock<ITaRepository>(); var teachingAssistantService = new TaService(mockRepository.Object); //// Act teachingAssistantService.UpdateTa(null, ref errors); //// Assert instructor object not null Assert.AreEqual(1, errors.Count); }