コード例 #1
0
ファイル: Server.cs プロジェクト: dirtylion/smalltuba
        /// <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();
        }
コード例 #2
0
        public void TestRegisterVoteRequestHandlerWithExistingNonVotePerson()
        {
            var personEntity = new PersonEntity();
            personEntity.Load(new Hashtable { { "id", 1 } });

            var person = personEntity.ToObject();

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

            var logEntity = personEntity.GetMostRecentLog();
            logEntity.Delete();
        }
コード例 #3
0
ファイル: Server.cs プロジェクト: dirtylion/smalltuba
        /// <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();
        }
コード例 #4
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");
        }
コード例 #5
0
        public void TestRegisterVoteRequestHandlerWithExistingVotePerson()
        {
            var personEntity = new PersonEntity();
            personEntity.Load(new Hashtable { { "id", 2 } });

            var person = personEntity.ToObject();

            Assert.That(!this.server.RegisterVoteRequestHandler("test client", person));
        }