public List<Admin> GetAdminList() { var service = new AdminService(new AdminRepository(this.entities)); var errors = new List<string>(); return service.GetAdminList(ref errors); }
public Admin GetAdminInfo(int adminId) { //// 136 TODO: get the admin info //// for now, returning the hard-coded value var errors = new List<string>(); var repository = new AdminRepository(); var service = new AdminService(repository); return service.GetAdmin(adminId, ref errors); }
public void UpdateAdminTest() { var errors = new List<string>(); var mockRepository = new Mock<IAdminRepository>(); var adminService = new AdminService(mockRepository.Object); //// Act adminService.UpdateAdmin(null, ref errors); //// Assert Assert.AreEqual(1, errors.Count); }
public string InsertAdmin(Admin admin) { var errors = new List<string>(); var repository = new AdminRepository(); var service = new AdminService(repository); service.InsertAdmin(admin, ref errors); if (errors.Count == 0) { return "ok"; } return "error"; }
public void UpdateAdminErrorTest1() { //// Arranage var errors = new List<string>(); var mockRepository = new Mock<IAdminRepository>(); var adminService = new AdminService(mockRepository.Object); //// Act adminService.UpdateAdmin(null, ref errors); //// Assert instructor object not null Assert.AreEqual(1, errors.Count); }
public string DeleteStudent(string id) { var errors = new List<string>(); var repository = new AdminRepository(); var service = new AdminService(repository); service.DeleteAdmin(id, ref errors); if (errors.Count == 0) { return "ok"; } return "error"; }
public void InsertAdminTest2() { //// Arrange var errors = new List<string>(); var mockRepository = new Mock<IAdminRepository>(); var adminService = new AdminService(mockRepository.Object); var admin = new Admin { Email = string.Empty, FirstName = string.Empty, LastName = string.Empty, Password = string.Empty }; //// Act adminService.InsertAdmin(admin, ref errors); //// Assert Assert.AreEqual(4, errors.Count); }
public string UpdateAdminInfo(Admin admin) { var errors = new List<string>(); var repository = new AdminRepository(this.entities); var service = new AdminService(repository); service.UpdateAdmin(admin, ref errors); if (errors.Count == 0) { return "Update Successful"; } return "error"; }
public Admin GetAdminInfo(int adminId) { var errors = new List<string>(); var repository = new AdminRepository(this.entities); var service = new AdminService(repository); var adminPoco = service.GetAdminById(adminId, ref errors); if (errors.Count == 0 && adminPoco != null) { return adminPoco; } return new Admin(); }
public void GetAdminErrorTest3() { //// Arranage var errors = new List<string>(); var mockRepository = new Mock<IAdminRepository>(); var adminService = new AdminService(mockRepository.Object); var adminPoco = new Admin() { FirstName = "hi", LastName = string.Empty }; //// Act adminService.GetAdminById(0, ref errors); //// Assert instructor object not null Assert.AreEqual(1, errors.Count); }
public void UpdateAdmin() { //// Arranage var errors = new List<string>(); var mockRepository = new Mock<IAdminRepository>(); var adminService = new AdminService(mockRepository.Object); var adminPoco = new Admin() { FirstName = "hi", LastName = "bye", Id = 1 }; mockRepository.Setup(x => x.UpdateAdmin(adminPoco, ref errors)); //// Act adminService.UpdateAdmin(adminPoco, ref errors); //// Assert instructor object not null mockRepository.Verify(x => x.UpdateAdmin(adminPoco, ref errors), Times.Once()); }