Пример #1
0
        public void ArchivePersonTest()
        {
            var target = new PersonsDAO();

            var actual = target.CreatePerson("Test" + new Random().Next(), "Test" + new Random().Next(), "076/482.04.78", "*****@*****.**", department);

            target.ArchivePerson(actual);

            var person = target.GetPersonByID(actual);

            Assert.IsNotNull(person, "Person must not be null");
            Assert.AreEqual(true, person.Archived, "The person must be archived");
        }
Пример #2
0
        public void CreatePersonTest()
        {
            var target = new PersonsDAO();

            var name = "Test" + new Random().Next();
            var actual = target.CreatePerson("New", name, "076/482.04.78", "*****@*****.**", department);

            Assert.IsTrue(actual > 0, "The id must be greater than 0");

            var created = target.GetPersonByID(actual);

            Assert.AreEqual(name, created.Name, "Values must be the same");
            Assert.AreEqual("New", created.FirstName, "Values must be the same");
            Assert.AreEqual("076/482.04.78", created.Phone, "Values must be the same");
            Assert.AreEqual("*****@*****.**", created.Email, "Values must be the same");
            Assert.AreEqual(department, created.Department.Id, "Values must be the same");
            Assert.AreEqual(false, created.Archived, "Values must be the same");
        }
Пример #3
0
        public void SavePersonTest()
        {
            var target = new PersonsDAO(); // TODO: Initialize to an appropriate value

            var actual = target.CreatePerson("Test" + new Random().Next(), "Test" + new Random().Next(), "076/482.04.78", "*****@*****.**", department);

            var firstname = "Test" + new Random().Next();
            var name = "Test" + new Random().Next();
            var phone = "076/482.04.79";
            var email = "*****@*****.**";

            using(var connection = DBManager.GetInstance().GetNewConnection())
            {
                var transaction = connection.BeginTransaction(IsolationLevel.ReadUncommitted);

                target.SavePerson(actual, firstname, name, phone, email, department, transaction);

                transaction.Commit();
            }

            var result = target.GetPersonByID(actual);

            Assert.AreEqual(name, result.Name, "Values must be the same");
            Assert.AreEqual(firstname, result.FirstName, "Values must be the same");
            Assert.AreEqual(phone, result.Phone, "Values must be the same");
            Assert.AreEqual(email, result.Email, "Values must be the same");
        }