Пример #1
0
        private void PopulateTestingData()
        {
            IDataAccess dao = new SqliteDataAccess();

            try
            {
                List <Client> clients = dao.GetAllClients();
                if (clients.Count > 0)
                {
                    return;
                }
                Client clienta = new Client()
                {
                    ClientCompanyName  = "Construction Company",
                    ClientContactEMail = "*****@*****.**",
                    ClientContactPhone = "(208) 555-5555",
                    ClientContactName  = "Bob Roberts",
                    Status             = "Active"
                };
                dao.Add(clienta);
                Client clientb = new Client()
                {
                    ClientCompanyName  = "Montey Company",
                    ClientContactEMail = "*****@*****.**",
                    ClientContactPhone = "(208) 555-5555",
                    ClientContactName  = "Jim James",
                    Status             = "Active"
                };
                dao.Add(clientb);
                Client clientc = new Client()
                {
                    ClientCompanyName  = "Wrecking Crew",
                    ClientContactEMail = "*****@*****.**",
                    ClientContactPhone = "(208) 555-5555",
                    ClientContactName  = "Hank Henries",
                    Status             = "Inactive"
                };
                dao.Add(clientc);
            } catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Пример #2
0
        public void TestSqliteDaAddUser()
        {
            SqliteDataAccess da = new SqliteDataAccess();

            Assert.IsFalse(String.IsNullOrEmpty(da.dbFile));
            Assert.IsTrue(File.Exists(da.dbFile));
            User user = new User()
            {
                ID         = "testId"
                , Name     = "Carpenter Bob"
                , Password = "******"
            };
            bool inserted = da.Add(user);

            Assert.IsTrue(inserted);
        }
Пример #3
0
        public void TestAddJob()
        {
            SqliteDataAccess da = new SqliteDataAccess();

            Assert.IsFalse(String.IsNullOrEmpty(da.dbFile));
            Assert.IsTrue(File.Exists(da.dbFile));
            clearAllJobs();
            Job job = new Job()
            {
                JobName        = "job1",
                JobDescription = "the first job"
            };
            bool inserted = da.Add(job);

            Assert.IsTrue(inserted);
        }
Пример #4
0
        public void TestSqliteDaDeleteUser()
        {
            SqliteDataAccess da = new SqliteDataAccess();

            Assert.IsFalse(String.IsNullOrEmpty(da.dbFile));
            Assert.IsTrue(File.Exists(da.dbFile));
            User user = new User()
            {
                ID       = "testId",
                Name     = "Carpenter Bob",
                Password = "******"
            };
            bool inserted = da.Add(user);

            Assert.IsTrue(inserted);

            Assert.AreEqual(1, da.getAllUsers().Count);
            da.Delete(user);
            Assert.AreEqual(0, da.getAllUsers().Count);
        }
Пример #5
0
        public void TestSqliteDaUpdateUser()
        {
            SqliteDataAccess da = new SqliteDataAccess();

            Assert.IsFalse(String.IsNullOrEmpty(da.dbFile));
            Assert.IsTrue(File.Exists(da.dbFile));
            User user = new User()
            {
                ID       = "testId",
                Name     = "Carpenter Bob",
                Password = "******"
            };
            bool inserted = da.Add(user);

            Assert.IsTrue(inserted);
            user.Password = "******";
            inserted      = da.Update(user);
            Assert.IsTrue(inserted);
            user = da.getUserById(user.ID);
            Assert.AreEqual("now I remember", user.Password);
        }
Пример #6
0
        public void TestGetAllJobsByClientID()
        {
            SqliteDataAccess da = new SqliteDataAccess();

            Assert.IsNotNull(da);
            clearAllJobs();
            TestAddJob();

            List <Job> jobs = da.GetAllJobsByClient(new Client {
                ID = 1L
            });

            Assert.IsTrue(jobs.Count == 0);
            Job job = new Job {
                ClientId = 1L, JobName = "client1job", JobDescription = "client1's job"
            };

            da.Add(job);
            jobs = da.GetAllJobsByClient(new Client {
                ID = 1L
            });
            Assert.IsTrue(jobs.Count == 1);
        }