Example #1
0
        public void PostPersonDuplicates()
        {
            //Generic setters provide additional validation

            Procedure procGood = ProcedureFactory.GetProcedure("open", "POST_PERSON");

            procGood.SetValue <string>("firstName", "a");
            procGood.SetValue <string>("lastName", "a");
            procGood.SetValue <string>("email", "*****@*****.**");
            procGood.ExecuteJson <Person>();

            Procedure procBad = ProcedureFactory.GetProcedure("open", "POST_PERSON");

            procBad.SetValue <string>("firstName", "a");
            procBad.SetValue <string>("lastName", "a");
            procBad.SetValue <string>("email", "*****@*****.**");
            procBad.ExecuteJson <Person>();

            Assert.AreEqual(procGood.GetValue <int>("RETURN_VALUE"), 200);
            Assert.AreEqual(procGood.GetValue <long>("SQL_ERROR_ID"), 0);
            Assert.AreEqual(procGood.GetValue <string>("MESSAGE_RESULT"), null);

            Assert.AreEqual(procBad.GetValue <int>("RETURN_VALUE"), 409);
            Assert.AreEqual(procBad.GetValue <long>("SQL_ERROR_ID"), 0);
            Assert.AreNotEqual(procBad.GetValue <string>("MESSAGE_RESULT"), null);
        }
Example #2
0
 private void CheckProcedureKey(string v)
 {
     if (!procedures.ContainsKey(v))
     {
         procedures.Add(v, procedureFactory.GetProcedure(v));
     }
 }
Example #3
0
        public void LoadFromObject1()
        {
            //Create the person
            Person person = new Person()
            {
                FirstName = "John", LastName = "Doe", Email = "*****@*****.**"
            };

            //Get the procedure
            Procedure proc = ProcedureFactory.GetProcedure("open", "POST_PERSON");

            //Load the parameters from the object
            proc.LoadFromObject <Person>(person);

            //Execute the result - procedures returns the newly created object
            Person result = proc.ExecuteJson <Person>();

            Assert.AreNotEqual(result.PersonId, person.PersonId);
            Assert.AreEqual(result.FirstName, person.FirstName);
            Assert.AreEqual(result.LastName, person.LastName);
            Assert.AreEqual(result.Email, person.Email);
            Assert.AreEqual(proc.ReturnValue <int>(), 200);
            Assert.AreEqual(proc.GetValue <long>("sqlErrorId"), 0);
            Assert.AreEqual(proc.GetValue <string>("messageResult"), null);
        }
Example #4
0
        public void ClearData()
        {
            Procedure procedure = ProcedureFactory.GetProcedure("open", "CLEAR_DATA");

            procedure.ExecuteNonQuery();
            Assert.AreEqual(procedure.ReturnValue <int>(), 200);
        }
Example #5
0
        public void GetPersonObjectJson2()
        {
            Procedure procedure = ProcedureFactory.GetProcedure("open", "PERSON_BY_ID");

            procedure.SetValue <int>("PERSON_ID", 1);
            string result = procedure.ExecuteReaderAsJson <Person>();

            Assert.AreNotEqual(result, null);
            Assert.AreEqual(procedure.GetValue <long>("SQL_ERROR_ID"), 0);
            Assert.AreEqual(procedure.GetValue <string>("MESSAGE_RESULT"), null);
        }
Example #6
0
        public void GetPersonObject()
        {
            Procedure procedure = ProcedureFactory.GetProcedure("open", "PERSON_BY_ID");

            procedure.SetValue <int>("PERSON_ID", 1);
            Person person = procedure.ExecuteReader <Person>();

            Assert.AreEqual(person.PersonId, 1);
            Assert.AreEqual(procedure.GetValue <long>("SQL_ERROR_ID"), 0);
            Assert.AreEqual(procedure.GetValue <string>("MESSAGE_RESULT"), null);
        }
Example #7
0
        public void LoadFromParameters2()
        {
            //Generic setters provide additional validation

            Procedure proc = ProcedureFactory.GetProcedure("open", "POST_PERSON");

            proc.SetValue <string>("firstName", "Mike");
            proc.SetValue <string>("lastName", "Quick");
            proc.SetValue <string>("email", "*****@*****.**");

            //returning json
            string result = proc.ExecuteJson();

            Assert.AreNotEqual(result, null);
            Assert.AreEqual(proc.ReturnValue <int>(), 200);
            Assert.AreEqual(proc.GetValue <long>("sqlErrorId"), 0);
            Assert.AreEqual(proc.GetValue <string>("messageResult"), null);
        }
Example #8
0
        public void LoadFromObject2()
        {
            Person person = new Person()
            {
                FirstName = "Jack", LastName = "Be", Email = "*****@*****.**"
            };
            Procedure proc = ProcedureFactory.GetProcedure("open", "POST_PERSON");

            proc.LoadFromObject <Person>(person);
            Person result = proc.ExecuteJson <Person>();

            Assert.AreNotEqual(result.PersonId, person.PersonId);
            Assert.AreEqual(result.FirstName, person.FirstName);
            Assert.AreEqual(result.LastName, person.LastName);
            Assert.AreEqual(result.Email, person.Email);
            Assert.AreEqual(proc.ReturnValue <int>(), 200);
            Assert.AreEqual(proc.GetValue <long>("sqlErrorId"), 0);
            Assert.AreEqual(proc.GetValue <string>("messageResult"), null);
        }
Example #9
0
        public void LoadFromParameters1()
        {
            Person person = new Person()
            {
                FirstName = "Bill", LastName = "Buzz", Email = "*****@*****.**"
            };
            Procedure proc = ProcedureFactory.GetProcedure("open", "POST_PERSON");

            proc["firstName"] = person.FirstName;
            proc["lastName"]  = person.LastName;
            proc["email"]     = person.Email;

            //returning person
            Person result = proc.ExecuteJson <Person>();

            Assert.AreNotEqual(result.PersonId, person.PersonId);
            Assert.AreEqual(result.FirstName, person.FirstName);
            Assert.AreEqual(result.LastName, person.LastName);
            Assert.AreEqual(result.Email, person.Email);
            Assert.AreEqual(proc.ReturnValue <int>(), 200);
            Assert.AreEqual(proc.GetValue <long>("sqlErrorId"), 0);
            Assert.AreEqual(proc.GetValue <string>("messageResult"), null);
        }