示例#1
0
        public void TestExpiredAction()
        {
            WaitingActions waitingActions = new WaitingActions();
            bool expiredFlag = false;

            waitingActions.Expired = (action, requests, responses) => { expiredFlag = true; };

            waitingActions.Wait(new NetworkAction(), new List<IPacket>() {
                new Packet() {
                    Origin = PacketOrigin.Client,
                    Type = PacketType.Request,
                    RequestId = 1
                }
            }, DateTime.Now.AddSeconds(-1));

            waitingActions.Flush();

            Assert.IsTrue(expiredFlag);
            Assert.AreEqual(0, waitingActions.Waiting.Count);
        }
示例#2
0
        public void TestFailedDoneAction()
        {
            WaitingActions waitingActions = new WaitingActions();
            bool doneFlag = false;

            waitingActions.Done = (action, requests, responses) => { doneFlag = true; };

            waitingActions.Wait(new NetworkAction(), new List<IPacket>() {
                new Packet() {
                    Origin = PacketOrigin.Client,
                    Type = PacketType.Request,
                    RequestId = 1
                }
            });

            waitingActions.Mark(new Packet() {
                Origin = PacketOrigin.Client,
                Type = PacketType.Response,
                RequestId = 2
            });

            Assert.IsFalse(doneFlag);
        }