public void SubmitContactPerson()
        {
            // ---- Arrange ----
            // set up model
            DefTblContactPersons def = new DefTblContactPersons();

            CRM_web.Models.Model.Model m = CRM_web.Models.Model.Model.GetModel();
            TestCase.CleanUp();
            m.ExecuteActionQuery(String.Format("DELETE FROM {0} WHERE {1} = {2};", def.TblName, def.Cid.Name, TestContactPerson.cid));
            TestCase.PopulateTestData();
            m.Cid = TestContactPerson.cid;
            m.LoadCustomers();
            m.LoadContactPersons(TestCustomer.cid);
            //Thread.Sleep(1000);
            // set up controller and view model
            FrmContactPersonController controller = new FrmContactPersonController();
            ContactPersonViewModel     vm         = new ContactPersonViewModel();

            vm.Id          = TestContactPerson.id;
            vm.Cid         = TestContactPerson.cid;
            vm.Forename    = TestContactPerson.forename;
            vm.Surname     = TestContactPerson.surname;
            vm.Gender      = TestContactPerson.gender;
            vm.Email       = TestContactPerson.email;
            vm.Phone       = TestContactPerson.phone;
            vm.MainContact = TestContactPerson.mainContact;

            // ---- Act ----
            RedirectToRouteResult result = controller.Submit(vm) as RedirectToRouteResult;

            Thread.Sleep(1000);
            m.LoadContactPersons(TestCustomer.cid);
            Thread.Sleep(1000);

            // ---- Assert ----
            Assert.IsNotNull(result);
            // check new entries in database
            int lastEntry = 0;
            int max       = 0;

            for (int i = 0; i < m.ContactPersons.Count; i++)
            {
                if (int.Parse(m.ContactPersons[i][def.Id.Name].ToString()) > max)
                {
                    max       = int.Parse(m.ContactPersons[i][def.Id.Name].ToString());
                    lastEntry = i;
                }
            }
            Assert.AreEqual(m.ContactPersons[lastEntry][def.Cid.Name], TestContactPerson.cid);
            Assert.AreEqual(m.ContactPersons[lastEntry][def.Forename.Name], TestContactPerson.forename);
            Assert.AreEqual(m.ContactPersons[lastEntry][def.Surname.Name], TestContactPerson.surname);
            Assert.AreEqual(m.ContactPersons[lastEntry][def.Gender.Name], TestContactPerson.gender);
            Assert.AreEqual(m.ContactPersons[lastEntry][def.Email.Name], TestContactPerson.email);
            Assert.AreEqual(m.ContactPersons[lastEntry][def.Phone.Name], TestContactPerson.phone);
            Assert.AreEqual(m.ContactPersons[lastEntry][def.MainContact.Name], TestContactPerson.mainContact);

            // clean up model
            m.ExecuteActionQuery(String.Format("DELETE FROM {0} WHERE {1} = {2};", def.TblName, def.Cid.Name, TestContactPerson.cid));
            TestCase.CleanUp();
        }
Ejemplo n.º 2
0
        public void LoadNotesTest()
        {
            CRM_web.Models.Model.Model m = CRM_web.Models.Model.Model.GetModel();
            DataView dv = null;

            dv = m.Notes;
            Assert.IsTrue(dv != null);
        }
Ejemplo n.º 3
0
        public void LoadContactPersonsTest()
        {
            CRM_web.Models.Model.Model m = CRM_web.Models.Model.Model.GetModel();
            DataView dv = null;

            dv = m.ContactPersons;
            Assert.IsTrue(dv != null);
        }
Ejemplo n.º 4
0
        public void SubmitCustomer()
        {
            // ---- Arrange ----
            // set up model state
            CRM_web.Models.Model.Model m   = CRM_web.Models.Model.Model.GetModel();
            DefTblCustomers            def = new DefTblCustomers();

            TestCase.PopulateTestData();
            // set up controller and view model
            FrmCustomerController controller = new FrmCustomerController();
            CustomerViewModel     vm         = new CustomerViewModel();

            vm.Cid          = TestCustomer.cid;
            vm.Company      = TestCustomer.company;
            vm.Address      = TestCustomer.address;
            vm.Zip          = TestCustomer.zip;
            vm.City         = TestCustomer.city;
            vm.Country      = TestCustomer.country;
            vm.ContractId   = TestCustomer.contractId;
            vm.ContractDate = TestCustomer.contractDate;

            // ---- Act ----
            RedirectToRouteResult result = controller.Submit(vm) as RedirectToRouteResult;

            Thread.Sleep(1000);

            // ---- Assert ----
            DataRow dr = (from d in m.GetCustomer(TestCustomer.cid).Table.AsEnumerable()
                          select d).First();

            // check new entries
            Assert.AreEqual(TestCustomer.cid, dr[def.Cid.Name]);
            Assert.AreEqual(TestCustomer.company, dr[def.Company.Name]);
            Assert.AreEqual(TestCustomer.address, dr[def.Address.Name]);
            Assert.AreEqual(TestCustomer.zip, dr[def.Zip.Name]);
            Assert.AreEqual(TestCustomer.city, dr[def.City.Name]);
            Assert.AreEqual(TestCustomer.country, dr[def.Country.Name]);
            Assert.AreEqual(TestCustomer.contractId, dr[def.ContractId.Name]);
            Assert.AreEqual(TestCustomer.contractDate, dr[def.ContractDate.Name]);


            TestCase.CleanUp();
        }
Ejemplo n.º 5
0
        public void SubmitNote()
        {
            // ---- Arrange ----
            // set up model state
            CRM_web.Models.Model.Model m = CRM_web.Models.Model.Model.GetModel();
            DefTblNotes def = new DefTblNotes();

            m.ExecuteActionQuery(String.Format("DELETE FROM {0} WHERE {1} = {2};", def.TblName, def.Cid.Name, TestNote.cid));
            TestCase.PopulateTestData();
            m.Cid = TestNote.cid;
            m.LoadCustomers();
            m.LoadNotes(TestNote.cid);
            // set up controller and view model
            FrmNoteController controller = new FrmNoteController();
            NoteViewModel     vm         = new NoteViewModel();

            vm.Id         = TestNote.id;
            vm.Cid        = TestNote.cid;
            vm.CreatedBy  = TestNote.createdBy;
            vm.EntryDate  = TestNote.entryDate;
            vm.Memo       = TestNote.memo;
            vm.Category   = TestNote.category;
            vm.Attachment = TestNote.attachment;

            // ---- Act ----
            RedirectToRouteResult result = controller.Submit(vm) as RedirectToRouteResult;

            Thread.Sleep(1000);

            // ---- Assert ----
            Assert.AreEqual(TestNote.id, m.Notes[0][def.Id.Name]);
            Assert.AreEqual(TestNote.cid, m.Notes[0][def.Cid.Name]);
            Assert.AreEqual(TestNote.createdBy, m.Notes[0][def.CreatedBy.Name]);
            Assert.AreEqual(TestNote.entryDate, m.Notes[0][def.EntryDate.Name]);
            Assert.AreEqual(TestNote.memo, m.Notes[0][def.Memo.Name]);
            Assert.AreEqual(TestNote.category, m.Notes[0][def.Category.Name]);
            Assert.AreEqual(TestNote.attachment, m.Notes[0][def.Attachment.Name]);

            TestCase.CleanUp();
        }