Esempio n. 1
0
        public void OffsetDefaultTest()
        {
            var mediatorContext = new MediatorContext();

            var now          = DateTime.Now;
            var protocolTime = mediatorContext.CalcNowProtocolTime();

            Assert.AreEqual(0, (protocolTime - now).TotalSeconds, 1.0);
        }
Esempio n. 2
0
        public void OffsetMinusTest()
        {
            var mediatorContext = new MediatorContext();

            SetOffset(mediatorContext, DateTime.Now.AddSeconds(-5));

            var now          = DateTime.Now;
            var protocolTime = mediatorContext.CalcNowProtocolTime();

            Assert.AreEqual(-5, (protocolTime - now).TotalSeconds, 1.0);
        }
        public void SendUserquake_Valid()
        {
            Packet packet = null;

            peerContextMock.Setup(x => x.SendAll(It.IsAny <Packet>())).Callback <Packet>((e) =>
            {
                packet = e;
            });

            Assert.IsTrue(mediatorContext.SendUserquake());

            Assert.IsNotNull(packet);

            Verifier.VerifyResult result = Verifier.VerifyUserquake(packet.Data[5], packet.Data[1], packet.Data[0], packet.Data[2], packet.Data[3], packet.Data[4], mediatorContext.CalcNowProtocolTime());
            Assert.IsFalse(result.isExpired);
            Assert.IsTrue(result.isValidSignature);
            Assert.AreEqual("901", packet.Data[5].Split(',')[1]);
        }