コード例 #1
0
ファイル: AdminController.cs プロジェクト: fastily/cse136
        public List<Admin> GetAdminList()
        {
            var service = new AdminService(new AdminRepository(this.entities));
            var errors = new List<string>();

            return service.GetAdminList(ref errors);
        }
コード例 #2
0
 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);
 }
コード例 #3
0
        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);
        }
コード例 #4
0
        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";
        }
コード例 #5
0
ファイル: AdminServiceTest.cs プロジェクト: fastily/cse136
        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);
        }
コード例 #6
0
        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";
        }
コード例 #7
0
        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);
        }
コード例 #8
0
ファイル: AdminController.cs プロジェクト: fastily/cse136
        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";
        }
コード例 #9
0
ファイル: AdminController.cs プロジェクト: fastily/cse136
        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();
        }
コード例 #10
0
ファイル: AdminServiceTest.cs プロジェクト: fastily/cse136
        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);
        }
コード例 #11
0
ファイル: AdminServiceTest.cs プロジェクト: fastily/cse136
        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());
        }