Example #1
0
        public void TestPersonObject()
        {
            var person = new PersonEntity();

            person.Load(new Hashtable {
                { "id", 2 }
            });

            var a = person.ToObject();
            var b = person.ToObject();

            var c = person.ToObject();

            c.FirstName = "George";

            var d = c;

            Assert.That(a.Equals(b));
            Assert.That(a.Equals((object)b));

            Assert.False(c.Equals(b));
            Assert.False(c.Equals((object)b));

            Assert.That(c.Equals(d));
            Assert.That(c.Equals((object)d));

            Assert.False(c.Equals((Person)null));
            Assert.False(c.Equals((object)null));
            Assert.False(c.Equals(new PersonEntity()));


            Assert.That(a.GetHashCode() == -1070491939);

            Assert.That(a.ToString() == "2,0123456789,Christian,Olsson, Table of Fish, 08-12-2011 10:08:41, True");
        }
Example #2
0
        /// <summary>
        /// Handle a request for a PersonState object by barcode.
        ///
        /// Takes a barcode number as parameter and constructs the
        /// proper Person entity. If the entity does not exists
        /// a PersonState object will still be passed back,
        /// but the Exist property of the object will return false.
        /// </summary>
        /// <param name="voterId">The barcode number to search for a person by.</param>
        /// <param name="clientName">The id of the client.</param>
        /// <returns>A PersonState object filled with information from the Person entity.</returns>
        public Person VoterIdToPersonRequestHandler(string clientName, int voterId)
        {
            var personEntity = new PersonEntity();

            personEntity.Load(new Hashtable {
                { "voter_id", voterId }
            });

            return(personEntity.ToObject());
        }
Example #3
0
        /// <summary>
        /// Handle a request for a PersonState object by CPR.
        ///
        /// Takes a CPR number as parameter and constructs the
        /// proper Person entity. If the entity does not exists
        /// a PersonState object will still be passed back,
        /// but the Exist property of the object will return false.
        /// </summary>
        /// <param name="cpr">The CPR number to search for a person by.</param>
        /// <param name="clientName">The id of the client.</param>
        /// <returns>A PersonState object filled with information from the Person entity.</returns>
        public Person CprToPersonRequestHandler(string clientName, string cpr)
        {
            Contract.Requires(cpr != null);

            var personEntity = new PersonEntity();

            personEntity.Load(new Hashtable {
                { "cpr", cpr }
            });

            return(personEntity.ToObject());
        }
Example #4
0
        public void TestUnregisterVoteRequestHandlerWitUnexistingPerson()
        {
            var personEntity = new PersonEntity();

            personEntity.Load(new Hashtable {
                { "id", 669 }
            });

            var person = personEntity.ToObject();

            Assert.That(!this.server.UnregisterVoteRequestHandler("test client", person));
        }
Example #5
0
        public void TestUnregisterVoteRequestHandlerWithExistingVotePerson()
        {
            var personEntity = new PersonEntity();

            personEntity.Load(new Hashtable {
                { "id", 2 }
            });

            var person = personEntity.ToObject();

            Assert.That(this.server.UnregisterVoteRequestHandler("test client", person));

            var logEntity = personEntity.GetMostRecentLog();

            logEntity.Delete();
        }