예제 #1
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);
        }
        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);
            }
        }
예제 #3
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);
        }
예제 #4
0
        public void CreateDepartmentTest()
        {
            Department testdept = new Department();

            testdept.Id = departmentID + 1;

            testdept.Name = "steve";

            Assert.IsTrue(test.CreateDepartment(testdept));
        }
        public void CreateDept()
        {
            DepartmentSqlDAL deptSqlDal = new DepartmentSqlDAL(connectionString);
            Department       dept       = new Department
            {
                Name = "Test Dept"
            };
            bool didWork = deptSqlDal.CreateDepartment(dept);

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

            Assert.IsTrue(isCreated);
        }
        public void CreateDepartmentTests()
        {
            DepartmentSqlDAL deptDal = new DepartmentSqlDAL(connectionString);
            Department       dept    = new Department();

            dept.Id   = 6;
            dept.Name = "Logistics";
            bool createWorked = deptDal.CreateDepartment(dept);

            Assert.AreEqual(true, createWorked);
        }
예제 #8
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);
        }
예제 #9
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.");
        }
예제 #10
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);
        }
예제 #11
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);
        }
예제 #12
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);
        }
        public void CreateDepartmentTest()
        {
            DepartmentSqlDAL departments = new DepartmentSqlDAL(connectionString);

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

            bool isTrue = departments.CreateDepartment(ABC);

            Assert.AreEqual(true, isTrue);
        }
예제 #14
0
        public void CreateDepartmentTest()
        {
            DepartmentSqlDAL departmentSqlDal = new DepartmentSqlDAL(connectionString);
            Department       d = new Department();

            d.Name = "heyo";

            bool result = false;

            result = departmentSqlDal.CreateDepartment(d);

            Assert.AreEqual(true, result);
        }
예제 #15
0
        public void Initialize()
        {
            // Initialize a new transaction scope. This automatically begins the transaction.
            tran = new TransactionScope();

            _departmentItem = new DepartmentSqlDAL(_connectionString);

            _department = new Department();

            _department.Name = "A Department";

            _department.Id = _departmentItem.CreateDepartment(_department);
        }
예제 #16
0
        public void TestCreateDepartment()
        {
            //Arrange
            DepartmentSqlDAL departmentDAL     = new DepartmentSqlDAL(connectionString);
            Department       updatedDepartment = new Department();

            updatedDepartment.Name = "UpdatedDepartmentName";

            //Act
            bool successChange            = departmentDAL.CreateDepartment(updatedDepartment);
            List <Department> departments = departmentDAL.GetDepartments();

            //Assert
            Assert.AreEqual(departmentCount + 1, departments.Count);
        }
        public void CreateDepartmentTest()
        {
            DepartmentSqlDAL departmentDAL = new DepartmentSqlDAL(connectionString);

            //Act
            Department newDepartment = new Department()
            {
                Name = "Xbox"
            };

            bool wasSuccessful = departmentDAL.CreateDepartment(newDepartment);

            //Assert
            Assert.AreEqual(true, wasSuccessful);
        }
예제 #18
0
        public void CreateDepartmentTest()
        {
            //Arrange
            int        originalCount = GetCountOfDepartments();
            Department newDept       = new Department
            {
                Name = "New Test Department"
            };
            DepartmentSqlDAL dal = new DepartmentSqlDAL(ConnectionString);
            //Act
            bool result = dal.CreateDepartment(newDept);

            //Assert
            Assert.IsTrue(result);
            Assert.AreEqual(originalCount + 1, GetCountOfDepartments());
        }
예제 #19
0
        public void DepartmentFailTest()
        {
            DepartmentSqlDAL deptTest02 = new DepartmentSqlDAL(connectionString);

            Department badDept02 = new Department();

            badDept02.Name = "12345678912345678912345678912345678912345";

            try
            {
                deptTest02.CreateDepartment(badDept02);
            }
            catch (SqlException)
            {
                throw;
            }
        }
예제 #20
0
        private void CreateDepartment()
        {
            string     departmentName = CLIHelper.GetString("Provide a name for the new department:");
            Department newDept        = new Department
            {
                Name = departmentName
            };
            DepartmentSqlDAL dal = new DepartmentSqlDAL(DatabaseConnection);

            bool result = dal.CreateDepartment(newDept);

            if (result)
            {
                Console.WriteLine("*** SUCCESS ***");
            }
            else
            {
                Console.WriteLine("*** DID NOT CREATE ***");
            }
        }