Пример #1
0
        public void UpdateDepartment_Test_Budget()
        {
            var obj = CreateTestDepartment(Repository);

            try
            {
                var differentBudget = 1;

                obj.Budget = differentBudget;

                obj = Repository.UpdateDepartment(obj);

                //confirm the object was updated.
                var updated = Repository.GetDepartment(obj.DepartmentID);

                Assert.IsNotNull(updated);
                Assert.AreEqual(differentBudget, updated.Budget);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                //Remove the test data.
                DepartmentTest.DeleteTestObject(obj, Repository);
            }
        }
Пример #2
0
        public void UpdateDepartment_Test_CreatedDate()
        {
            var obj = CreateTestDepartment(Repository);

            try
            {
                var differentDate = new DateTime(1999, 12, 31);

                obj.CreatedDate = differentDate;

                obj = Repository.UpdateDepartment(obj);

                //confirm the object was updated.
                var updated = Repository.GetDepartment(obj.DepartmentID);

                Assert.IsNotNull(updated);
                Assert.AreEqual(differentDate, updated.CreatedDate);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                //Remove the test data.
                DepartmentTest.DeleteTestObject(obj, Repository);
            }
        }
Пример #3
0
        public void UpdateDepartment_Test_Name()
        {
            var obj = CreateTestDepartment(Repository);

            try
            {
                var randomName = Guid.NewGuid().ToString();

                obj.Name = randomName;

                obj = Repository.UpdateDepartment(obj);

                //confirm the object was updated.
                var updated = Repository.GetDepartment(obj.DepartmentID);

                Assert.IsNotNull(updated);
                Assert.AreEqual(randomName, updated.Name);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                //Remove the test data.
                DepartmentTest.DeleteTestObject(obj, Repository);
            }
        }
Пример #4
0
        public void UpdateCourse_Test_Department()
        {
            var obj = CreateTestCourse(Repository);

            var originalDepartmentID = obj.DepartmentID;

            try
            {
                var newDepartment = DepartmentTest.CreateTestDepartment(Repository);

                obj.DepartmentID = newDepartment.DepartmentID;

                obj = Repository.UpdateCourse(obj);

                //confirm the object was updated.
                var updated = Repository.GetCourse(obj.CourseID);

                Assert.IsNotNull(updated);
                Assert.AreEqual(newDepartment.DepartmentID, updated.DepartmentID);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                //Remove the test data.
                CourseTest.DeleteTestObject(obj, Repository);

                var originalDepartment = Repository.GetDepartment(originalDepartmentID);
                DepartmentTest.DeleteTestObject(originalDepartment, Repository);
            }
        }
Пример #5
0
        public void AddDepartment_Test()
        {
            var obj = CreateTestDepartment(Repository);

            Assert.IsTrue(Repository.GetAllDepartments().Any(x => x.DepartmentID == obj.DepartmentID));

            DepartmentTest.DeleteTestObject(obj, Repository);
        }
Пример #6
0
        public void DeleteDepartment_Test()
        {
            var obj = CreateTestDepartment(Repository);

            var currentCount = Repository.GetAllDepartments().Count();

            DepartmentTest.DeleteTestObject(obj, Repository);

            Assert.IsTrue(Repository.GetAllDepartments().Count() < currentCount);
        }
Пример #7
0
        /// <summary>
        /// Deletes the test object.
        /// </summary>
        /// <param name="toDelete">The object to delete.</param>
        /// <param name="_repository">The repository.</param>
        public static void DeleteTestObject(CourseDTO toDelete, ISchoolData _repository)
        {
            _repository.DeleteCourse(toDelete.CourseID);

            var originalDepartment = _repository.GetDepartment(toDelete.DepartmentID);

            if (originalDepartment != null)
            {
                DepartmentTest.DeleteTestObject(originalDepartment, _repository);
            }
        }
Пример #8
0
        public void ReadDepartment_Test()
        {
            var obj = CreateTestDepartment(Repository);

            Assert.IsNotNull(obj.DepartmentID);
            Assert.IsNotNull(obj.Name);
            Assert.IsNotNull(obj.Budget);
            Assert.IsNotNull(obj.CreatedDate);

            Assert.IsTrue(obj.DepartmentID > 0);
            Assert.AreEqual(DateTime.Today, obj.CreatedDate);
            Assert.AreEqual(1000000, obj.Budget);

            var allDepartments = Repository.GetAllDepartments();

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

            DepartmentTest.DeleteTestObject(obj, Repository);
        }