Пример #1
0
        public void Can_set_future_autotargets()
        {
            ConcurrencyTester.Run(() =>
            {
                var testProxy = new InfusionTestProxy();
                var targetSet = new AutoResetEvent(false);

                var task = Task.Run(() =>
                {
                    testProxy.Api.WaitTargetObject(0x12345678, 0x87654321);
                    targetSet.Set();
                });

                targetSet.WaitOne();

                testProxy.PacketReceivedFromServer(new Packet(0x6C, new byte[]
                {
                    0x6C, 0x01, 0x00, 0x00, 0x00, 0x25, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                    0x00, 0x00, 0x00
                }));

                testProxy.PacketReceivedFromServer(new Packet(0x6C, new byte[]
                {
                    0x6C, 0x01, 0x00, 0x00, 0x00, 0x25, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                    0x00, 0x00, 0x00
                }));

                task.Wait(100).Should().BeTrue();

                testProxy.PacketsSentToServer.Count(x => x.Id == 0x6C).Should().Be(2);
            });
        }
Пример #2
0
        public void Can_wait_for_target_When_no_last_action()
        {
            ConcurrencyTester.Run(() =>
            {
                var testProxy = new InfusionTestProxy();
                var task      = Task.Run(() => testProxy.Api.WaitForTarget(TimeSpan.MaxValue));
                testProxy.Api.WaitForTargetStartedEvent.WaitOne(100).Should().BeTrue();
                testProxy.ServerPacketHandler.HandlePacket(TargetCursorPackets.TargetCursor);

                task.Wait(100).Should().BeTrue();
            });
        }
Пример #3
0
        public void Can_wait_for_target_after_last_action_When_TargetCursor_arrives_before_waiting_starts()
        {
            ConcurrencyTester.Run(() =>
            {
                var testProxy = new InfusionTestProxy();

                testProxy.Api.NotifyAction(DateTime.UtcNow.AddMilliseconds(-1));
                testProxy.ServerPacketHandler.HandlePacket(TargetCursorPackets.TargetCursor);

                bool waitResult = false;
                var task        = Task.Run(() => waitResult = testProxy.Api.WaitForTarget(TimeSpan.MaxValue));

                task.Wait(100).Should().BeTrue();
                waitResult.Should().BeTrue();
            });
        }
Пример #4
0
        public void Can_terminate_before_target_because_fail_message_received()
        {
            ConcurrencyTester.Run(() =>
            {
                var testProxy = new InfusionTestProxy();

                testProxy.Api.NotifyAction(DateTime.UtcNow.AddMilliseconds(-1));

                testProxy.ServerPacketHandler.HandlePacket(SpeechPackets.FailureMessageFromServer);

                bool waitResult      = true;
                var task             = Task.Run(
                    () => waitResult = testProxy.Api.WaitForTarget(TimeSpan.MaxValue, "failure message"));
                task.Wait(100).Should().BeTrue();

                waitResult.Should().BeFalse();
            });
        }
Пример #5
0
        public void Cancels_AskForMobile_When_server_requests_target()
        {
            ConcurrencyTester.Run(() =>
            {
                var testProxy = new InfusionTestProxy();

                var task = Task.Run(() => { testProxy.Api.AskForMobile().Should().BeNull(); });

                testProxy.Api.AskForTargetStartedEvent.WaitOne(100).Should().BeTrue();
                testProxy.PacketReceivedFromServer(new Packet(0x6C, new byte[]
                {
                    0x6C, 0x01, 0x00, 0x00, 0x00, 0x25, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                    0x00, 0x00, 0x00
                }));

                task.Wait(100).Should().BeTrue();
            });
        }
Пример #6
0
        public void Cancels_AfkForItem_When_server_requests_target()
        {
            ConcurrencyTester.Run(() =>
            {
                var testProxy = new InfusionTestProxy();

                var task = Task.Run(() => { testProxy.Api.AskForItem().Should().BeNull(); });

                testProxy.Api.AskForTargetStartedEvent.AssertWaitOneSuccess();
                testProxy.PacketReceivedFromServer(new Packet(0x6C, new byte[]
                {
                    0x6C, 0x01, 0x00, 0x00, 0x00, 0x25, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                    0x00, 0x00, 0x00
                }));

                task.AssertWaitFastSuccess();
            });
        }