示例#1
0
        public void TestQueueWithEmptyList( )
        {
            Rhino.Mocks.MockRepository oMocks = new Rhino.Mocks.MockRepository( );

            Utility.IXmlFilePersister oXmlFilePersister = oMocks.StrictMock <Utility.IXmlFilePersister> ( );

            using (oMocks.Record( ))
            {
                Rhino.Mocks.Expect
                .Call(oXmlFilePersister.Load(""))
                .IgnoreArguments( )
                .Return(null);

                Rhino.Mocks.Expect
                .Call(() => oXmlFilePersister.Save("", null))
                .IgnoreArguments( );
            }

            using (oMocks.Playback( ))
            {
                Service.Waitlist svc = new Service.Waitlist(oXmlFilePersister);

                string sName  = Guid.NewGuid( ).ToString( );
                string sPhone = Guid.NewGuid( ).ToString( );

                Data.Person dPerson = svc.Queue(sName, sPhone);

                Assert.IsNotNull(dPerson);
                Assert.AreEqual(sName, dPerson.Name);
                Assert.AreEqual(sPhone, dPerson.Phone);
                Assert.AreNotEqual(Guid.Empty, dPerson.Id);
            }
        }
示例#2
0
        private void DoQueue( )
        {
            try
            {
                Service.Data.Person dPerson = m_svcWaitlist.Queue(Name, Phone);

                Persons.Add(dPerson);
                Name  = null;
                Phone = null;
            }
            catch (Service.Exception.QueueException qe)
            {
                switch (qe.ResponseCode)
                {
                case Service.Exception.QueueException.ResponseCodes.PersonExists:
                    QueueError = "This person already exists.";
                    break;

                case Service.Exception.QueueException.ResponseCodes.InvalidName:
                    QueueError = "The person name was invalid.";
                    break;

                case Service.Exception.QueueException.ResponseCodes.InvalidPhone:
                    QueueError = "The person phone number was invalid.";
                    break;

                default:
                    QueueError = "An unknown error occoured.";
                    break;
                }
            }
        }