public void DepartmentTests()
        {
            // Open a SqlConnection object using the active transaction
            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                conn.Open();

                DepartmentSqlDAL   testDAL  = new DepartmentSqlDAL(connectionString);
                IList <Department> testList = new List <Department>();
                testList = testDAL.GetDepartments();
                int savecount = testList.Count;
                Assert.AreNotEqual(0, testList.Count, "There should be Initial Data");

                Department testDepartment = new Department();
                testDepartment.Name = "alkjfagjhasivs";
                departmentId        = testDAL.CreateDepartment(testDepartment);
                Assert.AreNotEqual(0, departmentId, "Deparment ID should be greater than 0");

                testDepartment = testDAL.GetADepartment(departmentId);
                Assert.AreEqual(departmentId, testDepartment.Id, "Department IDs should match");
                Assert.AreEqual("alkjfagjhasivs", testDepartment.Name, "Departname should be \"alkjfagjhasivs\"");

                testList = testDAL.GetDepartments();
                Assert.AreEqual(savecount + 1, testList.Count, "List should have 1 more element");

                testDepartment.Name = "zzhzhzhzhzhzhz";
                testDepartment.Id   = departmentId;
                bool status = testDAL.UpdateDepartment(testDepartment);
                Assert.AreEqual(true, status);
                testDepartment = testDAL.GetADepartment(departmentId);
                Assert.AreEqual("zzhzhzhzhzhzhz", testDepartment.Name);
            }
        }
示例#2
0
        public void Initialize()
        {
            _departmentItem = new DepartmentSqlDAL(_connectionString);

            _department = new Department();

            _department.Name = "Test Department";

            _department.Id = _departmentItem.CreateDepartment(_department);

            // Initialize a new transaction scope. This automatically begins the transaction.
            tran = new TransactionScope();

            _employeeItem = new EmployeeSqlDAL(_connectionString);

            _employee = new Employee();

            _employee.DepartmentId = _department.Id;
            _employee.FirstName    = "John";
            _employee.LastName     = "Smith";
            _employee.Gender       = "M";
            _employee.JobTitle     = "Developer";
            _employee.BirthDate    = new DateTime(1990, 01, 01);
            _employee.HireDate     = new DateTime(2000, 02, 03);

            _employee.EmployeeId = _employeeItem.CreateEmployee(_employee);
        }
示例#3
0
        public void GetAllDepartmentsTest()
        {
            DepartmentSqlDAL  testDept = new DepartmentSqlDAL(connectionString);
            List <Department> testList = testDept.GetDepartments();

            Assert.AreEqual(7, testList.Count);
        }
示例#4
0
        public void GetDepartmentsTest()
        {
            DepartmentSqlDAL   department = new DepartmentSqlDAL(connectionString);
            IList <Department> names      = department.GetDepartments();

            Assert.IsNotNull(names);
            Assert.AreEqual(departmentCount + 1, names.Count);
        }
示例#5
0
        public void GetDepartmentTest()
        {
            DepartmentSqlDAL departmentSqldal = new DepartmentSqlDAL(connectionString);

            List <Department> departments = departmentSqldal.GetDepartments();

            Assert.AreEqual(numberOfDepartments + 1, departments.Count);
        }
        public void GetDept()
        {
            DepartmentSqlDAL  deptSqlDal = new DepartmentSqlDAL(connectionString);
            List <Department> deptNames  = deptSqlDal.GetDepartments();

            Assert.IsNotNull(deptNames);
            Assert.AreEqual(numOfDept, deptNames.Count - 1);
        }
示例#7
0
        public void GetDepartmentsTest()
        {
            DepartmentSqlDAL  getDepartmentTest = new DepartmentSqlDAL(connectionString);
            List <Department> deptList          = getDepartmentTest.GetDepartments();

            Assert.IsNotNull(deptList);
            Assert.AreEqual(deptCount + 1, deptList.Count);
        }
        public void GetDepartmentTests()
        {
            DepartmentSqlDAL  deptDal = new DepartmentSqlDAL(connectionString);
            List <Department> dept    = deptDal.GetDepartments();

            Assert.AreEqual(5, dept.Count);
            Assert.AreEqual(deptId, dept[4].Id);
        }
示例#9
0
        public void GetDepartmentsTest()
        {
            DepartmentSqlDAL departmentSqlDal = new DepartmentSqlDAL(connectionString);

            List <Department> d = departmentSqlDal.GetDepartments();

            Assert.IsNotNull(d);
            Assert.AreEqual(5, d.Count);
        }
        public void GetDepartmentsTest()
        {
            DepartmentSqlDAL departments = new DepartmentSqlDAL(connectionString);

            List <Department> department = departments.GetDepartments();

            Assert.IsNotNull(department);
            Assert.AreEqual(4, department.Count());
        }
示例#11
0
        public void GetDepartmentsTest()
        {
            DepartmentSqlDAL departmentSqlDAL = new DepartmentSqlDAL(connectionString);

            IList <Department> departments = departmentSqlDAL.GetDepartments();

            Assert.IsNotNull(departments, "GetDepartments failed, the list was null.");
            Assert.AreEqual(numberOfDepartments + 1, departments.Count, "GetDepartments failed, an incorrect number of departments has been returned.");
        }
示例#12
0
        public void DepartmentListTest()
        {
            DepartmentSqlDAL departmentDal = new DepartmentSqlDAL(connectionString);

            List <Department> getDepartment = departmentDal.GetDepartments();

            Assert.IsNotNull(getDepartment);
            Assert.IsTrue(getDepartment.Count > 0);
            Assert.AreEqual(4, getDepartment.Count);
        }
示例#13
0
        public void CreateDepartmentTest()
        {
            DepartmentSqlDAL departmentDAL = new DepartmentSqlDAL(connectionString);
            Department       department    = new Department();

            department.Name = "Brand New Dept";
            int otherID = departmentDAL.CreateDepartment(department);

            Assert.AreEqual(id + 1, otherID);
        }
        public void CreateDept()
        {
            DepartmentSqlDAL deptSqlDal = new DepartmentSqlDAL(connectionString);
            Department       dept       = new Department
            {
                Name = "Test Dept"
            };
            bool didWork = deptSqlDal.CreateDepartment(dept);

            Assert.AreEqual(true, didWork);
        }
示例#15
0
        public void CreateDepartmentTest()
        {
            DepartmentSqlDAL testDept = new DepartmentSqlDAL(connectionString);
            Department       newDept  = new Department
            {
                Name = "MyTestDept"
            };
            bool isCreated = testDept.CreateDepartment(newDept);

            Assert.IsTrue(isCreated);
        }
示例#16
0
        public void CreateDepartmentTest()
        {
            DepartmentSqlDAL departmentDAL = new DepartmentSqlDAL(connectionString);

            Department departmentTestObj = new Department();

            departmentTestObj.Name = "AnyName";
            bool createdDepartment = departmentDAL.CreateDepartment(departmentTestObj);

            Assert.AreEqual(true, createdDepartment);
        }
示例#17
0
        public void TestGetAllDepartments()
        {
            //Arrange
            DepartmentSqlDAL departmentDAL = new DepartmentSqlDAL(connectionString);

            //Act
            List <Department> departments = departmentDAL.GetDepartments();

            //Assert
            Assert.AreEqual(departmentCount, departments.Count);
        }
示例#18
0
        public void UpdateDepartmentTest()
        {
            DepartmentSqlDAL departmentSqlDAL = new DepartmentSqlDAL(connectionString);
            Department       department       = new Department();

            department.Name = "TestDepartment";
            department.Id   = id;
            bool result = departmentSqlDAL.UpdateDepartment(department);

            Assert.AreEqual(true, result);
        }
        public void UpdateDepartmentTests()
        {
            DepartmentSqlDAL deptDal = new DepartmentSqlDAL(connectionString);
            Department       dept    = new Department();

            dept.Id   = 4;
            dept.Name = "Logistics";
            bool updateWorked = deptDal.UpdateDepartment(dept);

            Assert.AreEqual(true, updateWorked);
        }
示例#20
0
        public void GetDepartmentsTest()
        {
            DepartmentSqlDAL departmentDAL = new DepartmentSqlDAL(connectionString);

            List <Department> departments = departmentDAL.GetDepartments();

            entries++;

            Assert.IsNotNull(departments);
            Assert.AreEqual(entries, departments.Count);
        }
        public void GetDepartmentsTest()
        {
            //Arrange
            DepartmentSqlDAL departmentDAL = new DepartmentSqlDAL(connectionString);

            //Act
            List <Department> departments = departmentDAL.GetDepartments();

            //Assert
            Assert.AreEqual(7, departments.Count, "Insert: 5 initial departments. 1 Insert in the Initialize");
        }
示例#22
0
        public void UpdateDepartmentTest()
        {
            DepartmentSqlDAL updateDeptTest = new DepartmentSqlDAL(connectionString);
            Department       testUpdateDept = new Department();

            testUpdateDept.Name = "TestDepartment3";
            testUpdateDept.Id   = departmentCode;
            bool didWork = updateDeptTest.UpdateDepartment(testUpdateDept);

            Assert.IsTrue(didWork);
        }
示例#23
0
        public void CreateDepartmentsTest()
        {
            DepartmentSqlDAL departmentDAL = new DepartmentSqlDAL(connectionString);
            Department       department    = new Department
            {
                Name = "Eric's Place",
            };

            int ericID = departmentDAL.CreateDepartment(department);

            Assert.AreEqual(maxID + 1, department.Id);
        }
示例#24
0
        public void UpdateDepartmentTest()
        {
            DepartmentSqlDAL departmentSqlDal = new DepartmentSqlDAL(connectionString);
            Department       d = new Department();

            d.Id   = 1;
            d.Name = "noname";

            bool result = departmentSqlDal.CreateDepartment(d);

            Assert.AreEqual(true, result);
        }
示例#25
0
        public void CreateDepartmentTest()
        {
            DepartmentSqlDAL departmentSqlDAL = new DepartmentSqlDAL(connectionString);
            Department       department       = new Department
            {
                Name = "A New Department"
            };

            int didItWork = departmentSqlDAL.CreateDepartment(department);

            Assert.AreNotEqual(0, didItWork, "CreateDepartment failed, it returned 0.");
        }
示例#26
0
        public void CreateDeptartmentTest()
        {
            DepartmentSqlDAL createDeptTest = new DepartmentSqlDAL(connectionString);
            Department       testCreateDept = new Department();

            testCreateDept.Name = "TestDeptCreate";
            bool didWork = createDeptTest.CreateDepartment(testCreateDept);
            List <Department> deptList = createDeptTest.GetDepartments();

            Assert.IsTrue(didWork);
            Assert.AreEqual(deptCount + 2, deptList.Count);
        }
示例#27
0
        public void UpdateDepartmentsTest()
        {
            DepartmentSqlDAL departmentDAL = new DepartmentSqlDAL(connectionString);
            Department       department    = new Department
            {
                Name = "Kyle's Place",
                Id   = 1
            };

            bool departmentID = departmentDAL.UpdateDepartment(department);

            Assert.IsTrue(departmentID);
        }
        public void GetDepartmentsTest()
        {
            //Arrange
            DepartmentSqlDAL dal = new DepartmentSqlDAL(ConnectionString);

            //Act
            List <Department> result = dal.GetDepartments();

            //Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count > 0);
            Assert.AreEqual(1, result.Where(d => d.Id == departmentId).Count());
        }
示例#29
0
        public void UpdateDepartmentTest()
        {
            DepartmentSqlDAL departmentSqlDAL = new DepartmentSqlDAL(connectionString);
            Department       department       = new Department
            {
                Name = "The Next Department",
                Id   = 2
            };

            bool didItWork = departmentSqlDAL.UpdateDepartment(department);

            Assert.IsTrue(didItWork);
        }
        public void CreateDepartmentTest()
        {
            DepartmentSqlDAL departments = new DepartmentSqlDAL(connectionString);

            Department ABC = new Department()
            {
                Name = "ABC"
            };

            bool isTrue = departments.CreateDepartment(ABC);

            Assert.AreEqual(true, isTrue);
        }