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);
            }
        }
Beispiel #2
0
        public void DepartmentTest()
        {
            DepartmentSqlDAL  deptTest01 = new DepartmentSqlDAL(connectionString);
            List <Department> happyList  = deptTest01.GetDepartments();

            Department goodDept02 = new Department();

            goodDept02.Id   = 1;
            goodDept02.Name = "yeah";
            deptTest01.UpdateDepartment(goodDept02);

            Assert.AreEqual(departmentCount + 3, happyList.Count);
            Assert.AreEqual("yeah", deptTest01.GetDepartments(1).Name);
        }
Beispiel #3
0
        public void GetDepartmentsTest()
        {
            List <Department> departments = test.GetDepartments();

            Assert.AreEqual(8, departments.Count);
            Assert.AreEqual(departmentID, departments[departments.Count - 1].Id);
        }
Beispiel #4
0
        public void GetAllDepartmentsTest()
        {
            DepartmentSqlDAL  testDept = new DepartmentSqlDAL(connectionString);
            List <Department> testList = testDept.GetDepartments();

            Assert.AreEqual(7, testList.Count);
        }
        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);
        }
Beispiel #7
0
        public void GetDepartmentTest()
        {
            DepartmentSqlDAL departmentSqldal = new DepartmentSqlDAL(connectionString);

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

            Assert.AreEqual(numberOfDepartments + 1, departments.Count);
        }
Beispiel #8
0
        public void GetDepartmentsTest()
        {
            DepartmentSqlDAL   department = new DepartmentSqlDAL(connectionString);
            IList <Department> names      = department.GetDepartments();

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

            Assert.IsNotNull(deptNames);
            Assert.AreEqual(numOfDept, deptNames.Count - 1);
        }
Beispiel #10
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.");
        }
Beispiel #11
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());
        }
Beispiel #13
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);
        }
        public void TestGetAllDepartments()
        {
            //Arrange
            DepartmentSqlDAL departmentDAL = new DepartmentSqlDAL(connectionString);

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

            //Assert
            Assert.AreEqual(departmentCount, departments.Count);
        }
Beispiel #15
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");
        }
        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 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());
        }
        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 UpdateDepartment()
        {
            DepartmentSqlDAL departments = new DepartmentSqlDAL(connectionString);

            Department ABCD = new Department()
            {
                Name = "ABCD",
                Id   = 2
            };

            bool isTrue = departments.UpdateDepartment(ABCD);
            List <Department> updatedDepartments = departments.GetDepartments();

            Assert.AreEqual("ABCD", updatedDepartments[0].Name);
            Assert.AreEqual(true, isTrue);
        }
Beispiel #21
0
        private void GetAllDepartments()
        {
            DepartmentSqlDAL  dal         = new DepartmentSqlDAL(DatabaseConnection);
            List <Department> departments = dal.GetDepartments();

            if (departments.Count > 0)
            {
                departments.ForEach(dept =>
                {
                    Console.WriteLine(dept);
                });
            }
            else
            {
                Console.WriteLine("**** NO RESULTS ****");
            }
        }
        private void GetAllDepartments()
        {
            DepartmentSqlDAL   dal         = new DepartmentSqlDAL(DatabaseConnection);
            IList <Department> departments = dal.GetDepartments();

            if (departments.Count > 0)
            {
                foreach (Department dept in departments)
                {
                    Console.WriteLine(dept.Id.ToString().PadRight(10) + dept.Name.PadRight(40));
                }
            }
            else
            {
                Console.WriteLine("**** NO RESULTS ****");
            }
        }
Beispiel #23
0
        public void GetDepartmentsTest()
        {
            DepartmentSqlDAL departmentDAL = new DepartmentSqlDAL(connectionString);

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

            Assert.IsNotNull(departments);
            bool areEqual = false;

            foreach (Department id in departments)
            {
                if (id.Name == "TestDepartment")
                {
                    areEqual = true;
                }
            }
            Assert.AreEqual(true, areEqual);
        }
Beispiel #24
0
        public void UpdateDepartmentTest()
        {
            DepartmentSqlDAL departmentSqldal = new DepartmentSqlDAL(connectionString);

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

            //int testDepartmentID = 0;
            Department testDepartment = new Department();

            foreach (Department thisDepartment in departments)
            {
                if (thisDepartment.Name == "Test Department")
                {
                    testDepartment = thisDepartment;
                }
            }

            testDepartment.Name = "Altered Name";

            bool didUpdate = departmentSqldal.UpdateDepartment(testDepartment);

            Assert.AreEqual(true, didUpdate);
        }