Exemplo n.º 1
0
        public void Can_handle_compressed_gump()
        {
            var testProxy = new InfusionTestProxy();

            testProxy.PacketReceivedFromServer(SendGumpMenuDialogPackets.Compressed);

            testProxy.Api.CurrentGump.Should().NotBeNull();
            testProxy.Api.CurrentGump.Commands.Should().Contain("{ ButtonTileArt 266 113 129 129 1 0 2 6571 0 0 0 }");
            testProxy.Api.CurrentGump.TextLines.Should().HaveCount(3);
            testProxy.Api.CurrentGump.TextLines[0].Should().Contain("Forja Pequena");
        }
Exemplo n.º 2
0
        public void Timeouts_when_waiting_for_target_and_TargetCursor_arrives_before_last_action()
        {
            var testProxy = new InfusionTestProxy();

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

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

            task.Wait(100).Should().BeFalse();
        }
Exemplo n.º 3
0
        public void WaitForItemDragged_reacts_on_rejecting_move_request_before_awaiting_starts_after_last_action()
        {
            var testProxy = new InfusionTestProxy();

            testProxy.Api.NotifyAction(DateTime.UtcNow.AddMilliseconds(-1));
            testProxy.ServerPacketHandler.HandlePacket(RejectMoveItemRequestPackets.CannotLiftTheItem);

            var task = Task.Run(() => testProxy.Api.WaitForItemDragged(0x12345678, TimeSpan.MaxValue));

            task.Wait(100).Should().BeTrue();
        }
Exemplo n.º 4
0
        public void Can_send_speech_request_without_keyword()
        {
            var testProxy = new InfusionTestProxy();

            testProxy.KeywordSource.Add(new Ultima.SpeechEntry(2, "*bank*", 1));
            testProxy.Api.Say("Cank");

            testProxy.PacketsSentToServer.Single().Payload.Should().BeEquivalentTo(new byte[] {
                0xAD, 0x00, 0x16, 0x00, 0x02, 0xB2, 0x00, 0x03, 0x45, 0x4E, 0x55, 0x00, 0x00, 0x43, 0x00, 0x61,
                0x00, 0x6E, 0x00, 0x6B, 0x00, 0x00,
            });
        }
Exemplo n.º 5
0
        public void Can_block_gump_for_client()
        {
            var testProxy = new InfusionTestProxy();

            var task = Task.Run(() => { testProxy.Api.WaitForGump(false); });

            testProxy.Api.WaitForGumpStartedEvent.AssertWaitOneSuccess();

            testProxy.PacketReceivedFromServer(SendGumpMenuDialogPackets.Explevel).Should().BeNull();

            task.AssertWaitFastSuccess();
        }
Exemplo n.º 6
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();
            });
        }
Exemplo n.º 7
0
        public void WaitForTarget_resets_WaitTargetObject()
        {
            var testProxy = new InfusionTestProxy();

            testProxy.Api.WaitTargetObject(0x40001234);

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

            testProxy.Api.WaitForTargetStartedEvent.AssertWaitOneSuccess();
            testProxy.ServerPacketHandler.HandlePacket(TargetCursorPackets.TargetCursor);

            task.AssertWaitFastSuccess();
        }
Exemplo n.º 8
0
        public void Can_drop_item_to_container_at_specific_location()
        {
            byte[] expectedPayload = new byte[]
            {
                0x08, 0x40, 0x07, 0xAF, 0xA8, 0x00, 0x8E, 0x00, 0x41, 0x00, 0x40, 0x07, 0x3D, 0x99
            };
            var testProxy = new InfusionTestProxy();

            testProxy.Api.DropItem(0x4007AFA8, 0x40073D99, new Location2D(0x8E, 0x41));

            testProxy.PacketsSentToServer.Should().HaveCount(1);
            testProxy.PacketsSentToServer.Single().Payload.Should().BeEquivalentTo(expectedPayload);
        }
Exemplo n.º 9
0
        public void Doesnt_block_gump_for_client_after_blocked_gump()
        {
            var testProxy = new InfusionTestProxy();

            var task = Task.Run(() => { testProxy.Api.WaitForGump(false); });

            testProxy.Api.WaitForGumpStartedEvent.WaitOne(100).Should().BeTrue();

            testProxy.PacketReceivedFromServer(SendGumpMenuDialogPackets.Explevel).Should().BeNull();
            testProxy.PacketReceivedFromServer(SendGumpMenuDialogPackets.Explevel).Should().NotBeNull();

            task.Wait(100).Should().BeTrue();
        }
Exemplo n.º 10
0
        public void Single_skill_change_raises_event()
        {
            var testProxy = new InfusionTestProxy();
            var journal   = testProxy.Api.CreateEventJournal();

            // initialize skill value, SkillChangedEvent requires it
            testProxy.PacketReceivedFromServer(new byte[] { 0x3A, 0x00, 0x0B, 0xFF, 0x00, 0x02, 0x02, 0xC9, 0x02, 0xC9, 0x00, });

            // now it can be changed and SkillChangedEvent can be raised
            testProxy.PacketReceivedFromServer(new byte[] { 0x3A, 0x00, 0x0B, 0xFF, 0x00, 0x02, 0x02, 0xCA, 0x02, 0xCA, 0x00, });

            journal.OfType <SkillChangedEvent>().Should().NotBeNullOrEmpty();
        }
Exemplo n.º 11
0
        WaitForItemDragged_wait_when_other_object_than_dragged_object_is_deleted_the_dragged_object_is_deleted()
        {
            var testProxy = new InfusionTestProxy();
            var task      = Task.Run(() => { testProxy.Api.WaitForItemDragged(0x78563412, TimeSpan.MaxValue); });

            testProxy.Api.WaitForItemDraggedStartedEvent.AssertWaitOneSuccess();
            testProxy.ServerPacketHandler.HandlePacket(new Packet(PacketDefinitions.DeleteObject.Id, new byte[]
            {
                0x1D, 0x12, 0x34, 0x56, 0x78
            }));

            task.Wait(100).Should().BeFalse();
        }
Exemplo n.º 12
0
        public void WaitForItemDragged_wait_until_the_dragged_object_is_deleted()
        {
            var testProxy = new InfusionTestProxy();
            var task      = Task.Run(() => testProxy.Api.WaitForItemDragged(0x12345678, TimeSpan.MaxValue));

            testProxy.Api.WaitForItemDraggedStartedEvent.AssertWaitOneSuccess();
            testProxy.ServerPacketHandler.HandlePacket(new Packet(PacketDefinitions.DeleteObject.Id, new byte[]
            {
                0x1D, 0x12, 0x34, 0x56, 0x78
            }));

            task.AssertWaitFastSuccess();
        }
Exemplo n.º 13
0
        public void WaitForTarget_resets_WaitTargetObject()
        {
            var testProxy = new InfusionTestProxy();

            testProxy.Api.WaitTargetObject(0x40001234);

            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();
        }
Exemplo n.º 14
0
        public void Can_wait_for_gump()
        {
            var  testProxy  = new InfusionTestProxy();
            Gump resultGump = null;

            var task = Task.Run(() => { resultGump = testProxy.Api.WaitForGump(); });

            testProxy.Api.WaitForGumpStartedEvent.AssertWaitOneSuccess();

            testProxy.PacketReceivedFromServer(SendGumpMenuDialogPackets.Explevel).Should().NotBeNull();

            task.AssertWaitFastSuccess();
            resultGump.Should().NotBeNull();
        }
Exemplo n.º 15
0
        public void WaitForItemDragged_reacts_on_deleted_object_before_awaiting_starts_after_last_action()
        {
            var testProxy = new InfusionTestProxy();

            testProxy.Api.NotifyAction(DateTime.UtcNow.AddMilliseconds(-1));
            testProxy.ServerPacketHandler.HandlePacket(new Packet(PacketDefinitions.DeleteObject.Id, new byte[]
            {
                0x1D, 0x12, 0x34, 0x56, 0x78
            }));

            var task = Task.Run(() => testProxy.Api.WaitForItemDragged(0x12345678, TimeSpan.MaxValue));

            task.AssertWaitFastSuccess();
        }
Exemplo n.º 16
0
        public void WaitForItemDragged_ignores_deleted_object_before_last_action()
        {
            var testProxy = new InfusionTestProxy();

            testProxy.ServerPacketHandler.HandlePacket(new Packet(PacketDefinitions.DeleteObject.Id, new byte[]
            {
                0x1D, 0x12, 0x34, 0x56, 0x78
            }));
            testProxy.Api.NotifyAction(DateTime.UtcNow.AddMilliseconds(-1));

            var task = Task.Run(() => testProxy.Api.WaitForItemDragged(0x12345678, TimeSpan.MaxValue));

            task.Wait(100).Should().BeFalse();
        }
Exemplo n.º 17
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();
            });
        }
Exemplo n.º 18
0
        public void ObjectInfo_takes_out_item_from_previous_container()
        {
            var testProxy = new InfusionTestProxy();

            var containerId = (ObjectId)0x400B2683;

            testProxy.ServerApi.ObjectInfo(containerId, 0x2009, 1, new Location3D(0x123, 0x321, -1), (Color)0x1020);
            var id = testProxy.ServerApi.AddNewItemToContainer(0x1BFB, 1, new Location2D(1, 2), containerId, (Color)0x0593);

            testProxy.ServerApi.ObjectInfo(id, 0x1BFB, 1, new Location3D(0x123, 0x321, -1), (Color)0x0593);

            var testedItem = testProxy.Api.Items[id];

            testedItem.Should().NotBeNull();
            testedItem.ContainerId.Should().BeNull();
        }
Exemplo n.º 19
0
        public void Single_skill_0_change_raises_event()
        {
            var testProxy = new InfusionTestProxy();
            var journal   = testProxy.Api.CreateEventJournal();

            // initialize skill value, SkillChangedEvent requires it
            testProxy.PacketReceivedFromServer(new byte[] { 0x3A, 0x00, 0x0B, 0xFF, 0x00, 0x02, 0x02, 0xC9, 0x02, 0xC9, 0x00, });

            testProxy.Api.UseSkill(Skill.AnimalLore);

            // Sphere 0.99gz seems to send skill 0 sometimes, instead of actual skill or the skill mapping is not completely correct
            // in Infusion, not sure...
            testProxy.PacketReceivedFromServer(new byte[] { 0x3A, 0x00, 0x0B, 0xFF, 0x00, 0x00, 0x02, 0xCA, 0x02, 0xCA, 0x00, });

            journal.OfType <SkillChangedEvent>().Should().NotBeEmpty();
            journal.OfType <SkillChangedEvent>().First().Skill.Should().Be(Skill.AnimalLore);
        }
Exemplo n.º 20
0
        public void Sets_layer_when_item_worn()
        {
            var wornPacket = new Packet(0x2E, new byte[]
            {
                0x2E,                   // packet id
                0x40, 0x04, 0xF1, 0x9C, // item id
                0x0F, 0x51, 0x00,
                0x02,                   // layer
                0x00, 0x06, 0x39, 0x0E, 0x07, 0x63,
            });
            var testProxy = new InfusionTestProxy();

            testProxy.PacketReceivedFromServer(wornPacket);

            testProxy.Api.Items[0x4004F19C].Layer.HasValue.Should().BeTrue();
            testProxy.Api.Items[0x4004F19C].Layer.Should().Be(Layer.TwoHandedWeapon);
        }
Exemplo n.º 21
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();
            });
        }
Exemplo n.º 22
0
        public void Doesnt_cancel_hidden_gump_on_game_client()
        {
            var testProxy = new InfusionTestProxy();

            var task = Task.Run(() =>
            {
                testProxy.Api.WaitForGump(false); // next gump is hidden
                testProxy.Api.GumpResponse().Cancel();
            });

            testProxy.Api.WaitForGumpStartedEvent.AssertWaitOneSuccess();

            testProxy.PacketReceivedFromServer(SendGumpMenuDialogPackets.Explevel);
            task.AssertWaitFastSuccess();

            testProxy.PacketsSentToClient.Should()
            .NotContain(packet => packet.Id == PacketDefinitions.GeneralInformationPacket.Id);
        }
Exemplo n.º 23
0
        public void Can_publish_event_after_receiving_gump()
        {
            var  testProxy  = new InfusionTestProxy();
            var  journal    = testProxy.Api.CreateEventJournal();
            Gump resultGump = null;

            var task = Task.Run(() =>
            {
                journal.When <Events.GumpReceivedEvent>(e => resultGump = e.Gump)
                .WaitAny();
            });

            journal.AwaitingStarted.AssertWaitOneSuccess();
            testProxy.PacketReceivedFromServer(SendGumpMenuDialogPackets.Explevel);
            task.AssertWaitFastSuccess();

            resultGump.Should().NotBeNull();
        }
Exemplo n.º 24
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();
            });
        }
Exemplo n.º 25
0
        public void Amount_is_corpse_type()
        {
            var payload = new byte[]
            {
                0x1A, 0x00, 0x11, 0xC0, 0x0B, 0x7E, 0x06,
                0x20, 0x06, // corpse type
                0x00, 0x05, // amount, has to be interpreted as corpse type
                0x8A, 0x3B, 0x0C, 0x20, 0x03, 0x01,
            };

            var testProxy = new InfusionTestProxy();

            testProxy.PacketReceivedFromServer(payload);

            var corpse = testProxy.Api.Corpses.Single();

            corpse.CorpseType.Should().Be((ModelId)0x0005);
        }
Exemplo n.º 26
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();
            });
        }
Exemplo n.º 27
0
        public void Info_returns_info_about_mobile_selected_on_client()
        {
            var testProxy = new InfusionTestProxy();

            var task = Task.Run(() =>
            {
                var result = testProxy.Api.Info();
                result.HasValue.Should().BeTrue();
                result.Value.Id.Should().Be((ObjectId)0x00045B2A);
            });

            testProxy.Api.AskForTargetStartedEvent.AssertWaitOneSuccess();
            testProxy.PacketReceivedFromClient(new Packet(0x6C, new byte[]
            {
                0x6C, 0x00, 0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x04, 0x5B, 0x2A, 0x06, 0x05, 0x04, 0xC6, 0xFF,
                0x00, 0x01, 0x90,
            }));

            task.AssertWaitFastSuccess();
        }
Exemplo n.º 28
0
        public void Resets_layer_when_added_to_container()
        {
            var wornPacket = new Packet(0x2E, new byte[]
            {
                0x2E, 0x40, 0x04, 0xF1, 0x9C, 0x0F, 0x51, 0x00, 0x02, 0x00, 0x06, 0x39, 0x0E, 0x07, 0x63,
            });
            var testProxy = new InfusionTestProxy();

            testProxy.PacketReceivedFromServer(wornPacket);

            var addToContainerPacket = new Packet(0x25, new byte[]
            {
                0x25, 0x40, 0x04, 0xF1, 0x9C, 0x13, 0xF8, 0x00, 0x00, 0x01, 0x00, 0x36, 0x00, 0x7F, 0x40, 0x05,
                0x67, 0x56, 0x00, 0xED,
            });

            testProxy.PacketReceivedFromServer(addToContainerPacket);

            testProxy.Api.Items[0x4004F19C].Layer.HasValue.Should().BeFalse();
        }
Exemplo n.º 29
0
        public void AskForLocation_returns_location_selected_on_client()
        {
            var testProxy = new InfusionTestProxy();

            var task = Task.Run(() =>
            {
                var result = testProxy.Api.AskForLocation();
                result.HasValue.Should().BeTrue();
                result.Value.Location.Should().Be(new Location3D(0x09EC, 0x0CF9, 0));
            });

            testProxy.Api.AskForTargetStartedEvent.WaitOne(100).Should().BeTrue();
            testProxy.PacketReceivedFromClient(new Packet(0x6C, new byte[]
            {
                0x6C, 0x01, 0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0xEC, 0x0C, 0xF9, 0x00,
                0x00, 0x00, 0x00,
            }));

            task.Wait(100).Should().BeTrue();
        }
Exemplo n.º 30
0
        public void Can_translate_cliloc_message_with_arguments()
        {
            var proxy = new InfusionTestProxy();

            proxy.ClilocSource.Add(0x001005BD, "~1_PREFIX~~2_NAME~~3_SUFFIX~");

            proxy.PacketReceivedFromServer(new byte[]
            {
                0xC1, 0x00, 0x60, 0x02, 0x70, 0x72, 0x62, 0x01, 0x90, 0x06, 0x00, 0x35, 0x00, 0x03, 0x00, 0x10,
                0x05, 0xBD, 0x4B, 0x75, 0x72, 0x74, 0x20, 0x50, 0x6F, 0x6E, 0x64, 0x20, 0x74, 0x68, 0x65, 0x20,
                0x4D, 0x69, 0x6E, 0x65, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x20, 0x00, 0x09, 0x00, 0x4B, 0x00, 0x75, 0x00, 0x72, 0x00, 0x74, 0x00, 0x20, 0x00, 0x50, 0x00,
                0x6F, 0x00, 0x6E, 0x00, 0x64, 0x00, 0x20, 0x00, 0x74, 0x00, 0x68, 0x00, 0x65, 0x00, 0x20, 0x00,
                0x4D, 0x00, 0x69, 0x00, 0x6E, 0x00, 0x65, 0x00, 0x72, 0x00, 0x09, 0x00, 0x20, 0x00, 0x00, 0x00,
            });

            var message = proxy.Api.Journal.First().Message;

            message.Should().Be(" Kurt Pond the Miner ");
        }