8000 re #30 - added test for combat message · randomcoding/PSAI-MessageRelay@5cf9072 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5cf9072

Browse files
author
tim@5f1bb9e6-f381-11dc-ac94-59e6f598b727
committed
re #30 - added test for combat message
1 parent 9050f2e commit 5cf9072

File tree

1 file changed

+74
-27
lines changed

1 file changed

+74
-27
lines changed

tests/XmlGeneratorTests.cpp

Lines changed: 74 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ class XmlGeneratorTest: public testing::Test
9595
static csVector3 worldVelocity;
9696
static float ang_velocity;
9797

98+
// combat message
99+
static int combatEventType;
100+
static EID attacker;
101+
static EID target;
102+
static int targetLocation;
103+
static float damage;
104+
static int attackAnimation;
105+
static int defenseAnimation;
106+
98107
protected:
99108
// no set up yet
100109

@@ -358,6 +367,23 @@ class XmlGeneratorTest: public testing::Test
358367

359368
xml.append(getCloseTag(PsaiXmlConstants::TYPE_DR_MESSAGE));
360369
xml.append(getXmlStringMessageEnd());
370+
371+
return xml;
372+
}
373+
374+
String getExpectedXmlForCombatEventMessage()
375+
{
376+
String xml = getXmlStringStartForMessageType(PsaiXmlConstants::MSGTYPE_COMBATEVENT);
377+
xml.append(getOpenTag(PsaiXmlConstants::TYPE_COMBAT_MESSAGE));
378+
xml.append(getTextTag(PsaiXmlConstants::ELEMENT_COMBAT_ATTACKER_ID, attacker.Unbox()));
379+
xml.append(getTextTag(PsaiXmlConstants::ELEMENT_COMBAT_DAMAGE, damage));
380+
xml.append(getTextTag(PsaiXmlConstants::ELEMENT_COMBAT_TARGET_ID, target.Unbox()));
381+
xml.append(getTextTag(PsaiXmlConstants::ELEMENT_COMBAT_TARGET_LOCATION, targetLocation));
382+
xml.append(getTextTag(PsaiXmlConstants::ELEMENT_CLIENT_NUM, getStringUtils().convertToString(defaultClientNum)));
383+
xml.append(getCloseTag(PsaiXmlConstants::TYPE_COMBAT_MESSAGE));
384+
xml.append(getXmlStringMessageEnd());
385+
386+
return xml;
361387
}
362388
};
363389

@@ -416,6 +442,15 @@ csVector3 XmlGeneratorTest::velocity(45.0, 92.0, 0.0);
416442
csVector3 XmlGeneratorTest::worldVelocity(1.0, 1.0, 1.0);
417443
float XmlGeneratorTest::ang_velocity = 78.3;
418444

445+
// Combat message
446+
int XmlGeneratorTest::combatEventType = 10;
447+
EID XmlGeneratorTest::attacker(15);
448+
EID XmlGeneratorTest::target(20);
449+
int XmlGeneratorTest::targetLocation = 5;
450+
float XmlGeneratorTest::damage = 34.5;
451+
int XmlGeneratorTest::attackAnimation = 6;
452+
int XmlGeneratorTest::defenseAnimation = 7;
453+
419454
// Test Fixtures
420455
TEST_F(XmlGeneratorTest, testChatMessageToXml)
421456
{
@@ -544,133 +579,145 @@ TEST_F(XmlGeneratorTest, DISABLED_testDeadReckoningMessageToXml)
544579
ASSERT_STREQ(getExpectedXmlForDeadReckoningMessage().c_str(), msgXml.c_str());
545580
}
546581

547-
TEST_F(XmlGeneratorTest, testStatDeadReckoningMessageToXml)
582+
// DR messages all seem to have problems being created without the required setup. Is there a C++ mock library?
583+
TEST_F(XmlGeneratorTest, DISABLED_testStatDeadReckoningMessageToXml)
548584
{
549-
FAIL() << "Not Implemented Yet";
585+
FAIL() << "Not Implemented Yet" ;
550586
}
551587

552588
TEST_F(XmlGeneratorTest, testCombatEventMessageToXml)
553589
{
554-
FAIL() << "Not Implemented Yet";
590+
591+
psCombatEventMessage msg(defaultClientNum, combatEventType, attacker, target, targetLocation, damage, attackAnimation, defenseAnimation);
592+
msg.attack_anim = attackAnimation;
593+
msg.attacker_id = attacker;
594+
msg.damage = damage;
595+
msg.defense_anim = defenseAnimation;
596+
msg.target_id = target;
597+
msg.target_location = targetLocation;
598+
599+
String xmlString = getGenerator().toXml(msg);
600+
ASSERT_STREQ(getExpectedXmlForCombatEventMessage().c_str(), xmlString.c_str());
601+
555602
}
556603

557604
TEST_F(XmlGeneratorTest, testModeMessageToXml)
558605
{
559-
FAIL() << "Not Implemented Yet";
606+
FAIL() << "Not Implemented Yet" ;
560607
}
561608

562609
TEST_F(XmlGeneratorTest, testMoveLockMessageToXml)
563610
{
564-
FAIL() << "Not Implemented Yet";
611+
FAIL() << "Not Implemented Yet" ;
565612
}
566613

567614
TEST_F(XmlGeneratorTest, testNewSectorMessageToXml)
568615
{
569-
FAIL() << "Not Implemented Yet";
616+
FAIL() << "Not Implemented Yet" ;
570617
}
571618

572619
TEST_F(XmlGeneratorTest, testEffectMessageToXml)
573620
{
574-
FAIL() << "Not Implemented Yet";
621+
FAIL() << "Not Implemented Yet" ;
575622
}
576623

577624
TEST_F(XmlGeneratorTest, testStopEffectMessageToXml)
578625
{
579-
FAIL() << "Not Implemented Yet";
626+
FAIL() << "Not Implemented Yet" ;
580627
}
581628

582629
TEST_F(XmlGeneratorTest, testSpellCastMessageToXml)
583630
{
584-
FAIL() << "Not Implemented Yet";
631+
FAIL() << "Not Implemented Yet" ;
585632
}
586633

587634
TEST_F(XmlGeneratorTest, testSpellCancelMessageToXml)
588635
{
589-
FAIL() << "Not Implemented Yet";
636+
FAIL() << "Not Implemented Yet" ;
590637
}
591638

592639
TEST_F(XmlGeneratorTest, testStatsMessageToXml)
593640
{
594-
FAIL() << "Not Implemented Yet";
641+
FAIL() << "Not Implemented Yet" ;
595642
}
596643

597644
TEST_F(XmlGeneratorTest, testSystemMessageToXml)
598645
{
599-
FAIL() << "Not Implemented Yet";
646+
FAIL() << "Not Implemented Yet" ;
600647
}
601648

602649
TEST_F(XmlGeneratorTest, testWeatherMessageToXml)
603650
{
604-
FAIL() << "Not Implemented Yet";
651+
FAIL() << "Not Implemented Yet" ;
605652
}
606653

607654
TEST_F(XmlGeneratorTest, testCharacterDetailMessageToXml)
608655
{
609-
FAIL() << "Not Implemented Yet";
656+
FAIL() << "Not Implemented Yet" ;
610657
}
611658

612659
TEST_F(XmlGeneratorTest, testGuiInventoryMessageToXml)
613660
{
614-
FAIL() << "Not Implemented Yet";
661+
FAIL() << "Not Implemented Yet" ;
615662
}
616663

617664
TEST_F(XmlGeneratorTest, testGuiActiveMagicMessageToXml)
618665
{
619-
FAIL() << "Not Implemented Yet";
666+
FAIL() << "Not Implemented Yet" ;
620667
}
621668

622669
TEST_F(XmlGeneratorTest, testGuiInteractMessageToXml)
623670
{
624-
FAIL() << "Not Implemented Yet";
671+
FAIL() << "Not Implemented Yet" ;
625672
}
626673

627674
TEST_F(XmlGeneratorTest, testGuiMerchantMessageToXml)
628675
{
629-
FAIL() << "Not Implemented Yet";
676+
FAIL() << "Not Implemented Yet" ;
630677
}
631678

632679
TEST_F(XmlGeneratorTest, testGuiSkillMessageToXml)
633680
{
634-
FAIL() << "Not Implemented Yet";
681+
FAIL() << "Not Implemented Yet" ;
635682
}
636683

637684
TEST_F(XmlGeneratorTest, testGuiTargetUpdateMessageToXml)
638685
{
639-
FAIL() << "Not Implemented Yet";
686+
FAIL() << "Not Implemented Yet" ;
640687
}
641688

642689
TEST_F(XmlGeneratorTest, testLootMessageToXml)
643690
{
644-
FAIL() << "Not Implemented Yet";
691+
FAIL() << "Not Implemented Yet" ;
645692
}
646693

647694
TEST_F(XmlGeneratorTest, testQuestListMessageToXml)
648695
{
649-
FAIL() << "Not Implemented Yet";
696+
FAIL() << "Not Implemented Yet" ;
650697
}
651698

652699
TEST_F(XmlGeneratorTest, testQuestRewardMessageToXml)
653700
{
654-
FAIL() << "Not Implemented Yet";
701+
FAIL() << "Not Implemented Yet" ;
655702
}
656703

657704
TEST_F(XmlGeneratorTest, testUpdateObjectNameMessageToXml)
658705
{
659-
FAIL() << "Not Implemented Yet";
706+
FAIL() << "Not Implemented Yet" ;
660707
}
661708

662709
TEST_F(XmlGeneratorTest, testViewItemDescriptionMessageToXml)
663710
{
664-
FAIL() << "Not Implemented Yet";
711+
FAIL() << "Not Implemented Yet" ;
665712
}
666713

667714
TEST_F(XmlGeneratorTest, testViewItemUpdateMessageToXml)
668715
{
669-
FAIL() << "Not Implemented Yet";
716+
FAIL() << "Not Implemented Yet" ;
670717
}
671718

672719
TEST_F(XmlGeneratorTest, testEquipmentMessageToXml)
673720
{
674-
FAIL() << "Not Implemented Yet";
721+
FAIL() << "Not Implemented Yet" ;
675722
}
676723

0 commit comments

Comments
 (0)
0