Exemplo n.º 1
0
        public void GetDepartments_Should_Return_All_Departments()
        {
            DepartmentSqlDAO   dao         = new DepartmentSqlDAO(ConnectionString);
            IList <Department> departments = dao.GetDepartments();

            Assert.AreEqual(1, departments.Count);
        }
Exemplo n.º 2
0
        public void UpdateDepartmentShouldUpdate()
        {
            //Arrange
            DepartmentSqlDAO   dao   = new DepartmentSqlDAO(ConnectionString);
            IList <Department> depts = dao.GetDepartments();

            Department deptchange = depts[0];

            //Act
            deptchange.Name = "GranTurismo";
            dao.UpdateDepartment(deptchange);

            //Assert
            IList <Department> updateddept = dao.GetDepartments();
            Department         fromDB      = null;

            foreach (Department c in updateddept)
            {
                if (c.Id == deptchange.Id)
                {
                    fromDB = c;
                    break;
                }
            }
            Assert.AreEqual("GranTurismo", fromDB.Name);
        }
        public void UpdateDepartmentTest()
        {
            DepartmentSqlDAO access = new DepartmentSqlDAO(connectionString);
            Department       temp   = new Department();

            temp.Name = "YYYY";
            temp.Id   = 4;

            bool result = access.UpdateDepartment(temp);

            Assert.IsTrue(result);

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                conn.Open();

                string sql_select = "SELECT * FROM department WHERE name = 'YYYY';";

                SqlCommand cmd = new SqlCommand(sql_select, conn);

                SqlDataReader reader = cmd.ExecuteReader();

                int count = 0;

                while (reader.Read())
                {
                    count++;
                }

                Assert.AreEqual(1, count);
            }
        }
Exemplo n.º 4
0
        public void GetDepartmentTest()
        {
            DepartmentSqlDAO departmentSqlDAO = new DepartmentSqlDAO(connectionString);

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

            Assert.AreEqual(7, departments.Count);
        }
Exemplo n.º 5
0
        public void UpdateDepartmentTest()
        {
            DepartmentSqlDAO departmentSqlDAO = new DepartmentSqlDAO(connectionString);
            Department       department       = new Department();

            department.Id   = 1;
            department.Name = "Update";
            Assert.AreEqual("Update", department.Name);
        }
Exemplo n.º 6
0
        [TestMethod] // UpdateDepartment();
        public void TestUpdateDepartment()
        {
            DepartmentSqlDAO department       = new DepartmentSqlDAO(connectionString);
            Department       updateDepartment = new Department(1, "UpdateDepartment");
            bool             result           = department.UpdateDepartment(updateDepartment);


            Assert.IsTrue(result);
        }
Exemplo n.º 7
0
        public void CreateDepartmentTest()
        {
            DepartmentSqlDAO departmentSqlDAO = new DepartmentSqlDAO(connectionString);
            Department       department       = new Department();

            {
                department.Name = "Test 1";
            };
            Assert.AreEqual("Test 1", department.Name);
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            IProjectDAO    projectDAO    = new ProjectSqlDAO(@"Data Source =.\SQLEXPRESS; Initial Catalog = EmployeeDB; Integrated Security = True");
            IEmployeeDAO   employeeDAO   = new EmployeeSqlDAO(@"Data Source =.\SQLEXPRESS; Initial Catalog = EmployeeDB; Integrated Security = True");
            IDepartmentDAO departmentDAO = new DepartmentSqlDAO(@"Data Source =.\SQLEXPRESS; Initial Catalog = EmployeeDB; Integrated Security = True");

            ProjectCLI projectCLI = new ProjectCLI(employeeDAO, projectDAO, departmentDAO);

            projectCLI.RunCLI();
        }
Exemplo n.º 9
0
        public void GetDepartmentShouldReturnRightNumberofDepartments()
        {
            // Arrange
            DepartmentSqlDAO dao = new DepartmentSqlDAO(ConnectionString);

            //ACT
            IList <Department> deps = dao.GetDepartments();

            //ASERT
            Assert.AreEqual(GetRowCount("department"), deps.Count);
        }
Exemplo n.º 10
0
        public void Update_Department_Test()
        {
            DepartmentSqlDAO testClass = new DepartmentSqlDAO(ConnectionString);
            Department       testDept  = new Department();

            testDept.Name = "TechElevator";
            testDept.Id   = departmentID;
            bool isItWorking = testClass.UpdateDepartment(testDept);

            Assert.IsTrue(isItWorking);
        }
Exemplo n.º 11
0
        public void GetDepartmentTest()
        {
            //Arrange

            DepartmentSqlDAO gettem = new DepartmentSqlDAO(ConnectionString);

            List <Department> departmentList = (List <Department>)gettem.GetDepartments();

            //Assert
            Assert.IsNotNull(departmentList);
            Assert.AreEqual(numberOfDepartments + 1, departmentList.Count);
        }
        public void GetDepartmentTest()
        {
            // Arrange

            DepartmentSqlDAO department = new DepartmentSqlDAO(ConnectionString);

            // Act

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

            // Assert
            Assert.AreEqual(1, departments.Count);
        }
Exemplo n.º 13
0
        public void Create_Dept_Test()
        {
            DepartmentSqlDAO testClass = new DepartmentSqlDAO(ConnectionString);

            Department createDepartTest = new Department();

            createDepartTest.Name = "TestCreate";
            int isItWorking            = testClass.CreateDepartment(createDepartTest);
            List <Department> deptList = (List <Department>)testClass.GetDepartments();

            Assert.AreEqual(1, isItWorking);
            Assert.AreEqual(numberOfDepartments + 2, deptList.Count);
        }
Exemplo n.º 14
0
        public void UpdateDepartmentTest()
        {
            Department updatedDept = new Department
            {
                Id   = departmentId,
                Name = "Updated Department"
            };
            DepartmentSqlDAO dal = new DepartmentSqlDAO(ConnectionString);

            bool result = dal.UpdateDepartment(updatedDept);

            Assert.IsTrue(result);
        }
        public void GetDepartments_ShouldReturnRightNumberOfDepartments()
        {
            //Arrange
            const int numberOfDeptsAddedForTests = 1;

            DepartmentSqlDAO dao = new DepartmentSqlDAO(ConnectionString);

            //Act
            IList <Department> departments = dao.GetDepartments();

            //Assert
            Assert.AreEqual(numberOfDeptsAddedForTests, departments.Count, "GetDepartments doesn't return correct number for one department");
        }
        public void UpdateDeptTest()
        {
            Department department = new Department();

            department.Name = "strategy";
            department.Id   = NewDeptId;

            DepartmentSqlDAO dept = new DepartmentSqlDAO(ConnectionString);

            bool isSuccessful = dept.UpdateDepartment(department);

            Assert.AreEqual(true, isSuccessful);
        }
Exemplo n.º 17
0
        public void CreateDepartment_Should_Return_New_Id()
        {
            Department department = new Department()
            {
                Name = "TEST DEPARTMENT NAME"
            };
            int initialRowCount  = GetRowCount("department");
            DepartmentSqlDAO dao = new DepartmentSqlDAO(ConnectionString);

            int newId = dao.CreateDepartment(department);

            Assert.AreEqual(DepartmentId + 1, newId);
            Assert.AreEqual(initialRowCount + 1, GetRowCount("department"));
        }
Exemplo n.º 18
0
        public void CreateDepartmentTest()
        {
            int        originalCount = GetCountOfDepartments();
            Department newDept       = new Department
            {
                Name = "New Test Department"
            };
            DepartmentSqlDAO dao = new DepartmentSqlDAO(ConnectionString);

            int result = dao.CreateDepartment(newDept);

            Assert.AreEqual(departmentId + 1, result);
            Assert.AreEqual(originalCount + 1, GetCountOfDepartments());
        }
Exemplo n.º 19
0
        [TestMethod] // CreateDepartment();
        public void TestCreateDepartment()
        {
            DepartmentSqlDAO department    = new DepartmentSqlDAO(connectionString);
            Department       newDepartment = new Department("NewDepartment");
            int result = department.CreateDepartment(newDepartment);

            bool success = false;

            if (result > 0)
            {
                success = true;
            }

            Assert.IsTrue(success);
        }
Exemplo n.º 20
0
        public void UpdateDepartment_Should_Return_True()
        {
            Department department = new Department()
            {
                Id   = DepartmentId,
                Name = "UPDATED DEPT NAME"
            };
            int initialRowCount  = GetRowCount("department");
            DepartmentSqlDAO dao = new DepartmentSqlDAO(ConnectionString);

            bool result = dao.UpdateDepartment(department);

            Assert.IsTrue(result);
            Assert.AreEqual(initialRowCount, GetRowCount("department"));
        }
Exemplo n.º 21
0
        public void CreateDepartmentAddsADepartment()
        {
            // Arrange
            DepartmentSqlDAO department = new DepartmentSqlDAO(ConnectionString);

            Department newDepartment = new Department();

            newDepartment.Name = "GoBucks";

            // Act
            int result = department.CreateDepartment(newDepartment);


            // Assert
            Assert.AreEqual(1, result);
        }
        public void GetDepartmentsTest()
        {
            DepartmentSqlDAO   access = new DepartmentSqlDAO(connectionString);
            IList <Department> items  = access.GetDepartments();

            bool found = false;

            foreach (Department item in items)
            {
                if (item.Name == "ZZZZZ")
                {
                    found = true;
                    break;
                }
            }
            Assert.IsTrue(found);
        }
        public void UpdateDeparmtment_ShouldChangeDepartmentName()
        {
            //Arrange
            DepartmentSqlDAO dao           = new DepartmentSqlDAO(ConnectionString);
            Department       newDepartment = dao.GetDepartments()[0];

            newDepartment.Name = "TestName";


            //Act
            dao.UpdateDepartment(newDepartment);
            IList <Department> departments = dao.GetDepartments();

            //Assert
            //departments[0] is the only thing in the database during testing set by sql file
            Assert.AreEqual("TestName", departments[0].Name);
        }
Exemplo n.º 24
0
        public void CreateDepartmentShouldIncreaseCountBy1()
        {
            // Arrange
            DepartmentSqlDAO dao = new DepartmentSqlDAO(ConnectionString);
            int startingRowCount = GetRowCount("department");

            Department dept = new Department();

            dept.Name = "slickmahoney";

            //ACT
            dao.CreateDepartment(dept);
            int endingRowCount = GetRowCount("department");

            // Assert
            Assert.AreNotEqual(startingRowCount, endingRowCount);
        }
        public void AddDept_Should_IncreaseCountBy1()
        {
            // Arrange
            Department dept = new Department();

            dept.Name = "book binding";

            DepartmentSqlDAO deptsql = new DepartmentSqlDAO(ConnectionString);
            int startCount           = GetRowCount("department");

            // Act
            deptsql.CreateDepartment(dept);
            int endCount = GetRowCount("department");

            // Assert
            Assert.AreEqual(startCount + 1, endCount);
        }
Exemplo n.º 26
0
        public void TestGetDepartment()
        {
            DepartmentSqlDAO   department     = new DepartmentSqlDAO(connectionString);
            IList <Department> departmentList = department.GetDepartments();

            bool found = false;

            foreach (Department item in departmentList)
            {
                if (item.Name == "TestDepartment")
                {
                    found = true;
                    break;
                }
            }

            Assert.IsTrue(found);
        }
Exemplo n.º 27
0
        static void Main(string[] args)
        {
            // Get the connection string from the appsettings.json file
            IConfigurationBuilder builder = new ConfigurationBuilder()
                                            .SetBasePath(Directory.GetCurrentDirectory())
                                            .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

            IConfigurationRoot configuration = builder.Build();

            string connectionString = configuration.GetConnectionString("Project");

            IProjectDAO    projectDAO    = new ProjectSqlDAO(connectionString);
            IEmployeeDAO   employeeDAO   = new EmployeeSqlDAO(connectionString);
            IDepartmentDAO departmentDAO = new DepartmentSqlDAO(connectionString);

            ProjectCLI projectCLI = new ProjectCLI(employeeDAO, projectDAO, departmentDAO);

            projectCLI.RunCLI();
        }
        public void CreateDepartment_ShouldCreateNewDept(string newName)
        {
            //Arrange
            Department newDept = new Department();

            newDept.Name = newName;
            Department newDept2 = new Department();

            newDept2.Name = newName + '2';


            DepartmentSqlDAO dao = new DepartmentSqlDAO(ConnectionString);


            //Act
            int deptId  = dao.CreateDepartment(newDept);
            int deptId2 = dao.CreateDepartment(newDept2);

            //Assert
            Assert.AreEqual(3, dao.GetDepartments().Count, "Department ID not being returned correctly");
        }
Exemplo n.º 29
0
        public void GetDepartmentsTest()
        {
            DepartmentSqlDAO dao = new DepartmentSqlDAO(ConnectionString);

            IList <Department> result = dao.GetDepartments();

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count > 0);

            int counter = 0;

            foreach (Department dept in result)
            {
                if (dept.Id == departmentId)
                {
                    counter++;
                }
            }

            Assert.AreEqual(1, counter);
        }
 public void RunBeforeEachTest()
 {
     SetupDB();
     this.dao = new DepartmentSqlDAO(connectionString);
 }