示例#1
0
    public void TestGetsIfThenElse()
    {
        XCRMParser parser = new XCRMParser();
        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement(
          "<if_then_else>"+
        "<if>"+
        "</if>"+
        "<then>"+
        "</then>"+
        "<else>"+
        "</else>"+
          "</if_then_else>"
        );

        System.Xml.XmlNode if_node = xmlelement.SelectSingleNode("./if");
        System.Xml.XmlNode then_node = xmlelement.SelectSingleNode("./then");
        System.Xml.XmlNode else_node = xmlelement.SelectSingleNode("./else");

        parser.crm = mockery.NewMock<IXCRMParser>();
        List<Roar.DomainObjects.Requirement> mock_if_requirement_list = new List<Roar.DomainObjects.Requirement>();
        List<Roar.DomainObjects.Modifier> mock_then_modifier_list = new List<Roar.DomainObjects.Modifier>();
        List<Roar.DomainObjects.Modifier> mock_else_modifier_list = new List<Roar.DomainObjects.Modifier>();
        Expect.AtLeastOnce.On(parser.crm).Method("ParseRequirementList").With(if_node).Will(Return.Value(mock_if_requirement_list));
        Expect.AtLeastOnce.On(parser.crm).Method("ParseModifierList").With(then_node).Will(Return.Value(mock_then_modifier_list));
        Expect.AtLeastOnce.On(parser.crm).Method("ParseModifierList").With(else_node).Will(Return.Value(mock_else_modifier_list));

        IfThenElse m = parser.ParseAModifier(xmlelement) as IfThenElse;
        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(m);
        Assert.AreSame(m.if_, mock_if_requirement_list);
        Assert.AreSame(m.then_, mock_then_modifier_list);
        Assert.AreSame(m.else_, mock_else_modifier_list);
    }
示例#2
0
    public void TestRandomChoice()
    {
        XCRMParser parser = new XCRMParser();

        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement(
            "<random_choice>" +
            "<choice weight=\"78\">" +
            "<modifier/>" +
            "<requirement/>" +
            "</choice>" +
            "<choice weight=\"12\">" +
            "<modifier/>" +
            "<requirement/>" +
            "</choice>" +
            "</random_choice>"
            );
        Assert.IsNotNull(xmlelement);

        List <Modifier> rc1_modifiers = new List <Modifier>();

        System.Xml.XmlNode rc1_modifier_node = xmlelement.SelectSingleNode("./choice[1]/modifier");
        Assert.IsNotNull(rc1_modifier_node);

        List <Requirement> rc1_requirements = new List <Requirement>();

        System.Xml.XmlNode rc1_requirement_node = xmlelement.SelectSingleNode("./choice[1]/requirement");
        Assert.IsNotNull(rc1_requirement_node);


        List <Modifier> rc2_modifiers = new List <Modifier>();

        System.Xml.XmlNode rc2_modifier_node = xmlelement.SelectSingleNode("./choice[2]/modifier");
        Assert.IsNotNull(rc2_modifier_node);


        List <Requirement> rc2_requirements = new List <Requirement>();

        System.Xml.XmlNode rc2_requirement_node = xmlelement.SelectSingleNode("./choice[2]/requirement");
        Assert.IsNotNull(rc2_requirement_node);


        parser.crm = mockery.NewMock <IXCRMParser>();

        Expect.Once.On(parser.crm).Method("ParseModifierList").With(rc1_modifier_node).Will(Return.Value(rc1_modifiers));
        Expect.Once.On(parser.crm).Method("ParseRequirementList").With(rc1_requirement_node).Will(Return.Value(rc1_requirements));
        Expect.Once.On(parser.crm).Method("ParseModifierList").With(rc2_modifier_node).Will(Return.Value(rc2_modifiers));
        Expect.Once.On(parser.crm).Method("ParseRequirementList").With(rc2_requirement_node).Will(Return.Value(rc2_requirements));

        RandomChoice m = parser.ParseAModifier(xmlelement) as RandomChoice;

        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(m);
        Assert.AreEqual(2, m.choices.Count);
        Assert.AreEqual(78, m.choices[0].weight);
        Assert.AreSame(rc1_modifiers, m.choices[0].modifiers);
        Assert.AreSame(rc1_requirements, m.choices[0].requirements);
        Assert.AreEqual(12, m.choices[1].weight);
        Assert.AreSame(rc2_modifiers, m.choices[1].modifiers);
        Assert.AreSame(rc2_requirements, m.choices[1].requirements);
    }
示例#3
0
    public void TestNothing()
    {
        XCRMParser parser = new XCRMParser();

        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement("<nothing/>");
        Modifier m = parser.ParseAModifier(xmlelement);

        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(m as Nothing);
    }
示例#4
0
    public void TestGrantXP()
    {
        XCRMParser parser = new XCRMParser();

        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement("<grant_xp value=\"25\"/>");
        Modifier m = parser.ParseAModifier(xmlelement);

        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(m as GrantXp);
        Assert.AreEqual((m as GrantXp).value, 25);
    }
    public void TestFriends()
    {
        XCRMParser parser = new XCRMParser();
        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement("<friends_requirement required=\"5\" ok=\"false\" reason=\"Insufficient friends\"/>");

        Friends r = parser.ParseARequirement(xmlelement) as Friends;
        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(r);
        Assert.AreEqual(r.required, 5);
        Assert.AreEqual(r.ok, false);
        Assert.AreEqual(r .reason, "Insufficient friends");
    }
示例#6
0
    public void TestGrantItem()
    {
        XCRMParser parser = new XCRMParser();

        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement("<grant_item ikey=\"christmas_tree\"/>");

        Modifier m = parser.ParseAModifier(xmlelement);

        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(m as GrantItem);
        Assert.AreEqual((m as GrantItem).ikey, "christmas_tree");
    }
    public void TestItem()
    {
        XCRMParser parser = new XCRMParser();
        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement("<item_requirement ikey=\"christmas_tree\" number_required=\"56\" ok=\"false\" reason=\"required christmas_tree(56)\"/>");

        Roar.DomainObjects.Requirements.Item r = parser.ParseARequirement(xmlelement) as Roar.DomainObjects.Requirements.Item;
        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(r);
        Assert.AreEqual(r.ikey, "christmas_tree");
        Assert.AreEqual(r.number_required, 56);
        Assert.AreEqual(r.ok, false);
        Assert.AreEqual(r.reason, "required christmas_tree(56)");
    }
示例#8
0
    public void TestRemoveItems()
    {
        XCRMParser parser = new XCRMParser();

        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement("<remove_items ikey=\"christmas_tree\" count=\"15\"/>");

        Modifier m = parser.ParseAModifier(xmlelement);

        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(m as RemoveItems);
        Assert.AreEqual((m as RemoveItems).ikey, "christmas_tree");
        Assert.AreEqual((m as RemoveItems).count, 15);
    }
示例#9
0
    public void TestGrantXPRange()
    {
        XCRMParser parser = new XCRMParser();

        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement("<grant_xp_range min=\"33\" max=\"44\"/>");

        Modifier m = parser.ParseAModifier(xmlelement);

        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(m as GrantXpRange);
        Assert.AreEqual((m as GrantXpRange).min, 33);
        Assert.AreEqual((m as GrantXpRange).max, 44);
    }
示例#10
0
    public void TestFalse()
    {
        XCRMParser parser = new XCRMParser();
        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement(
          "<false_requirement ok=\"false\" reason=\"always fails\"/>"
        );

        Roar.DomainObjects.Requirements.False r = parser.ParseARequirement(xmlelement) as Roar.DomainObjects.Requirements.False;
        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(r);
        Assert.AreEqual(r.ok, false);
        Assert.AreEqual(r.reason, "always fails");
    }
示例#11
0
    public void TestGrantStat()
    {
        XCRMParser parser = new XCRMParser();

        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement("<grant_stat type=\"attribute\" ikey=\"_energy_regen_amount\" value=\"5\"/>");

        Modifier m = parser.ParseAModifier(xmlelement);

        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(m as GrantStat);
        Assert.AreEqual((m as GrantStat).ikey, "_energy_regen_amount");
        Assert.AreEqual((m as GrantStat).type, "attribute");
        Assert.AreEqual((m as GrantStat).value, 5);
    }
示例#12
0
    public void TestItem()
    {
        XCRMParser parser = new XCRMParser();

        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement("<item_requirement ikey=\"christmas_tree\" number_required=\"56\" ok=\"false\" reason=\"required christmas_tree(56)\"/>");

        Roar.DomainObjects.Requirements.Item r = parser.ParseARequirement(xmlelement) as Roar.DomainObjects.Requirements.Item;
        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(r);
        Assert.AreEqual(r.ikey, "christmas_tree");
        Assert.AreEqual(r.number_required, 56);
        Assert.AreEqual(r.ok, false);
        Assert.AreEqual(r.reason, "required christmas_tree(56)");
    }
示例#13
0
    public void TestTrue()
    {
        XCRMParser parser = new XCRMParser();

        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement(
            "<true_requirement ok=\"true\" />"
            );

        Roar.DomainObjects.Requirements.True r = parser.ParseARequirement(xmlelement) as Roar.DomainObjects.Requirements.True;
        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(r);
        Assert.AreEqual(r.ok, true);
        Assert.IsNull(r.reason);
    }
示例#14
0
    public void TestFalse()
    {
        XCRMParser parser = new XCRMParser();

        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement(
            "<false_requirement ok=\"false\" reason=\"always fails\"/>"
            );

        Roar.DomainObjects.Requirements.False r = parser.ParseARequirement(xmlelement) as Roar.DomainObjects.Requirements.False;
        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(r);
        Assert.AreEqual(r.ok, false);
        Assert.AreEqual(r.reason, "always fails");
    }
示例#15
0
    public void TestLevel()
    {
        XCRMParser parser = new XCRMParser();

        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement("<level_requirement level=\"3\" ok=\"false\" reason=\"requires level 3\"/>");

        Level r = parser.ParseARequirement(xmlelement) as Level;

        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(r);
        Assert.AreEqual(r.level, 3);
        Assert.AreEqual(r.ok, false);
        Assert.AreEqual(r.reason, "requires level 3");
    }
示例#16
0
    public void TestFriends()
    {
        XCRMParser parser = new XCRMParser();

        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement("<friends_requirement required=\"5\" ok=\"false\" reason=\"Insufficient friends\"/>");

        Friends r = parser.ParseARequirement(xmlelement) as Friends;

        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(r);
        Assert.AreEqual(r.required, 5);
        Assert.AreEqual(r.ok, false);
        Assert.AreEqual(r.reason, "Insufficient friends");
    }
示例#17
0
    public void TestItem()
    {
        XCRMParser parser = new XCRMParser();
        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement(
          "<item_cost ok=\"false\" reason=\"whatever\" ikey=\"Christmas tree\" number_required=\"4\"/>"
          );

        Roar.DomainObjects.Costs.Item c = parser.ParseACost(xmlelement) as Roar.DomainObjects.Costs.Item;
        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(c);
        Assert.AreEqual(c.ok, false);
        Assert.AreEqual(c.reason, "whatever");
        Assert.AreEqual(c.ikey, "Christmas tree");
        Assert.AreEqual(c.number_required, 4);
    }
示例#18
0
    public void TestItem()
    {
        XCRMParser parser = new XCRMParser();

        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement(
            "<item_cost ok=\"false\" reason=\"whatever\" ikey=\"Christmas tree\" number_required=\"4\"/>"
            );

        Roar.DomainObjects.Costs.Item c = parser.ParseACost(xmlelement) as Roar.DomainObjects.Costs.Item;
        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(c);
        Assert.AreEqual(c.ok, false);
        Assert.AreEqual(c.reason, "whatever");
        Assert.AreEqual(c.ikey, "Christmas tree");
        Assert.AreEqual(c.number_required, 4);
    }
示例#19
0
    public void TestStat()
    {
        XCRMParser parser = new XCRMParser();
        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement(
          "<stat_cost ok=\"false\" reason=\"whatever\" ikey=\"gamecoin\" type=\"currency\" value=\"15\"/>"
          );

        Stat c = parser.ParseACost(xmlelement) as Stat;
        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(c);
        Assert.AreEqual(c.ok, false);
        Assert.AreEqual(c.reason, "whatever");
        Assert.AreEqual(c.ikey, "gamecoin");
        Assert.AreEqual(c.type, "currency");
        Assert.AreEqual(c.value, 15);
    }
示例#20
0
    public void TestStat()
    {
        XCRMParser parser = new XCRMParser();

        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement(
            "<stat_cost ok=\"false\" reason=\"whatever\" ikey=\"gamecoin\" type=\"currency\" value=\"15\"/>"
            );

        Stat c = parser.ParseACost(xmlelement) as Stat;

        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(c);
        Assert.AreEqual(c.ok, false);
        Assert.AreEqual(c.reason, "whatever");
        Assert.AreEqual(c.ikey, "gamecoin");
        Assert.AreEqual(c.type, "currency");
        Assert.AreEqual(c.value, 15);
    }
示例#21
0
    public void TestStat()
    {
        XCRMParser parser = new XCRMParser();

        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement(
            "<stat_requirement ikey=\"gamecoins\" type=\"currency\" value=\"45\" ok=\"true\" />"
            );


        Roar.DomainObjects.Requirements.Stat r = parser.ParseARequirement(xmlelement) as Roar.DomainObjects.Requirements.Stat;
        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(r);
        Assert.AreEqual(r.ikey, "gamecoins");
        Assert.AreEqual(r.type, "currency");
        Assert.AreEqual(r.value, 45);
        Assert.AreEqual(r.ok, true);
        Assert.IsNull(r.reason);
    }
示例#22
0
    public void TestGrantStatRange()
    {
        XCRMParser parser = new XCRMParser();

        System.Xml.XmlElement xmlelement       = RoarExtensions.CreateXmlElement("<grant_stat_range type=\"currency\" ikey=\"premium_web\" min=\"3\" max=\"7\"/>");
        GrantStatRange        grant_stat_range = new GrantStatRange();

        grant_stat_range.type = "currency";
        grant_stat_range.ikey = "premium_web";
        grant_stat_range.min  = 3;
        grant_stat_range.max  = 7;


        Modifier m = parser.ParseAModifier(xmlelement);

        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(m as GrantStatRange);
        Assert.AreEqual((m as GrantStatRange).ikey, grant_stat_range.ikey);
        Assert.AreEqual((m as GrantStatRange).type, grant_stat_range.type);
        Assert.AreEqual((m as GrantStatRange).min, grant_stat_range.min);
        Assert.AreEqual((m as GrantStatRange).max, grant_stat_range.max);
    }
示例#23
0
    public void TestGetsIfThenElse()
    {
        XCRMParser parser = new XCRMParser();

        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement(
            "<if_then_else>" +
            "<if>" +
            "</if>" +
            "<then>" +
            "</then>" +
            "<else>" +
            "</else>" +
            "</if_then_else>"
            );

        System.Xml.XmlNode if_node   = xmlelement.SelectSingleNode("./if");
        System.Xml.XmlNode then_node = xmlelement.SelectSingleNode("./then");
        System.Xml.XmlNode else_node = xmlelement.SelectSingleNode("./else");

        parser.crm = mockery.NewMock <IXCRMParser>();
        List <Roar.DomainObjects.Requirement> mock_if_requirement_list = new List <Roar.DomainObjects.Requirement>();
        List <Roar.DomainObjects.Modifier>    mock_then_modifier_list  = new List <Roar.DomainObjects.Modifier>();
        List <Roar.DomainObjects.Modifier>    mock_else_modifier_list  = new List <Roar.DomainObjects.Modifier>();

        Expect.AtLeastOnce.On(parser.crm).Method("ParseRequirementList").With(if_node).Will(Return.Value(mock_if_requirement_list));
        Expect.AtLeastOnce.On(parser.crm).Method("ParseModifierList").With(then_node).Will(Return.Value(mock_then_modifier_list));
        Expect.AtLeastOnce.On(parser.crm).Method("ParseModifierList").With(else_node).Will(Return.Value(mock_else_modifier_list));

        IfThenElse m = parser.ParseAModifier(xmlelement) as IfThenElse;

        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(m);
        Assert.AreSame(m.if_, mock_if_requirement_list);
        Assert.AreSame(m.then_, mock_then_modifier_list);
        Assert.AreSame(m.else_, mock_else_modifier_list);
    }
示例#24
0
    public void TestLevel()
    {
        XCRMParser parser = new XCRMParser();
        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement("<level_requirement level=\"3\" ok=\"false\" reason=\"requires level 3\"/>");

        Level r = parser.ParseARequirement(xmlelement) as Level;
        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(r);
        Assert.AreEqual(r.level, 3);
        Assert.AreEqual(r.ok, false);
        Assert.AreEqual(r.reason, "requires level 3");
    }
示例#25
0
    public void TestGrantItem()
    {
        XCRMParser parser = new XCRMParser();
        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement("<grant_item ikey=\"christmas_tree\"/>");

        Modifier m = parser.ParseAModifier(xmlelement);
        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(m as GrantItem);
        Assert.AreEqual((m as GrantItem).ikey, "christmas_tree");
    }
示例#26
0
    public void TestGrantStatRange()
    {
        XCRMParser parser = new XCRMParser();
        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement("<grant_stat_range type=\"currency\" ikey=\"premium_web\" min=\"3\" max=\"7\"/>");
        GrantStatRange grant_stat_range = new GrantStatRange();
        grant_stat_range.type = "currency";
        grant_stat_range.ikey = "premium_web";
        grant_stat_range.min = 3;
        grant_stat_range.max = 7;

        Modifier m = parser.ParseAModifier(xmlelement);
        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(m as GrantStatRange);
        Assert.AreEqual((m as GrantStatRange).ikey, grant_stat_range.ikey);
        Assert.AreEqual((m as GrantStatRange).type, grant_stat_range.type);
        Assert.AreEqual((m as GrantStatRange).min, grant_stat_range.min);
        Assert.AreEqual((m as GrantStatRange).max, grant_stat_range.max);
    }
示例#27
0
    public void TestGrantStat()
    {
        XCRMParser parser = new XCRMParser();
        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement("<grant_stat type=\"attribute\" ikey=\"_energy_regen_amount\" value=\"5\"/>");

        Modifier m = parser.ParseAModifier(xmlelement);
        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(m as GrantStat);
        Assert.AreEqual((m as GrantStat).ikey, "_energy_regen_amount");
        Assert.AreEqual((m as GrantStat).type, "attribute");
        Assert.AreEqual((m as GrantStat).value, 5);
    }
示例#28
0
    public void TestGrantXPRange()
    {
        XCRMParser parser = new XCRMParser();
        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement("<grant_xp_range min=\"33\" max=\"44\"/>");

        Modifier m = parser.ParseAModifier(xmlelement);
        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(m as GrantXpRange);
        Assert.AreEqual((m as GrantXpRange).min, 33);
        Assert.AreEqual((m as GrantXpRange).max, 44);
    }
示例#29
0
 public void TestNothing()
 {
     XCRMParser parser = new XCRMParser();
     System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement("<nothing/>");
     Modifier m = parser.ParseAModifier(xmlelement);
     mockery.VerifyAllExpectationsHaveBeenMet();
     Assert.IsNotNull(m as Nothing);
 }
示例#30
0
    public void TestRandomChoice()
    {
        XCRMParser parser = new XCRMParser();
        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement(
        "<random_choice>" +
            "<choice weight=\"78\">"+
                "<modifier/>"+
                "<requirement/>"+
            "</choice>"+
            "<choice weight=\"12\">"+
                "<modifier/>"+
                "<requirement/>"+
            "</choice>"+
        "</random_choice>"
        );
        Assert.IsNotNull(xmlelement);

        List<Modifier> rc1_modifiers = new List<Modifier>();
        System.Xml.XmlNode rc1_modifier_node = xmlelement.SelectSingleNode("./choice[1]/modifier");
        Assert.IsNotNull(rc1_modifier_node);

        List<Requirement> rc1_requirements = new List<Requirement>();
        System.Xml.XmlNode rc1_requirement_node = xmlelement.SelectSingleNode("./choice[1]/requirement");
        Assert.IsNotNull(rc1_requirement_node);

        List<Modifier> rc2_modifiers = new List<Modifier>();
        System.Xml.XmlNode rc2_modifier_node = xmlelement.SelectSingleNode("./choice[2]/modifier");
        Assert.IsNotNull(rc2_modifier_node);

        List<Requirement> rc2_requirements = new List<Requirement>();
        System.Xml.XmlNode rc2_requirement_node = xmlelement.SelectSingleNode("./choice[2]/requirement");
        Assert.IsNotNull(rc2_requirement_node);

        parser.crm = mockery.NewMock<IXCRMParser>();

        Expect.Once.On(parser.crm).Method("ParseModifierList").With(rc1_modifier_node).Will(Return.Value(rc1_modifiers));
        Expect.Once.On(parser.crm).Method("ParseRequirementList").With(rc1_requirement_node).Will(Return.Value(rc1_requirements));
        Expect.Once.On(parser.crm).Method("ParseModifierList").With(rc2_modifier_node).Will(Return.Value(rc2_modifiers));
        Expect.Once.On(parser.crm).Method("ParseRequirementList").With(rc2_requirement_node).Will(Return.Value(rc2_requirements));

        RandomChoice m = parser.ParseAModifier(xmlelement) as RandomChoice;
        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(m);
        Assert.AreEqual(2,m.choices.Count);
        Assert.AreEqual(78, m.choices[0].weight);
        Assert.AreSame(rc1_modifiers, m.choices[0].modifiers);
        Assert.AreSame(rc1_requirements, m.choices[0].requirements);
        Assert.AreEqual(12, m.choices[1].weight);
        Assert.AreSame(rc2_modifiers, m.choices[1].modifiers);
        Assert.AreSame(rc2_requirements, m.choices[1].requirements);
    }
示例#31
0
    public void TestRemoveItems()
    {
        XCRMParser parser = new XCRMParser();
        System.Xml.XmlElement xmlelement= RoarExtensions.CreateXmlElement("<remove_items ikey=\"christmas_tree\" count=\"15\"/>");

        Modifier m = parser.ParseAModifier(xmlelement);
        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(m as RemoveItems);
        Assert.AreEqual((m as RemoveItems).ikey, "christmas_tree");
        Assert.AreEqual((m as RemoveItems).count, 15);
    }
示例#32
0
    public void TestStat()
    {
        XCRMParser parser = new XCRMParser();
        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement(
          "<stat_requirement ikey=\"gamecoins\" type=\"currency\" value=\"45\" ok=\"true\" />"
        );

        Roar.DomainObjects.Requirements.Stat r = parser.ParseARequirement(xmlelement) as Roar.DomainObjects.Requirements.Stat;
        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(r);
        Assert.AreEqual(r.ikey, "gamecoins");
        Assert.AreEqual(r.type, "currency");
        Assert.AreEqual(r.value, 45);
        Assert.AreEqual(r.ok, true);
        Assert.IsNull(r.reason);
    }
示例#33
0
 public void TestGrantXP()
 {
     XCRMParser parser = new XCRMParser();
     System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement("<grant_xp value=\"25\"/>");
     Modifier m = parser.ParseAModifier(xmlelement);
     mockery.VerifyAllExpectationsHaveBeenMet();
     Assert.IsNotNull(m as GrantXp);
     Assert.AreEqual((m as GrantXp).value, 25);
 }
示例#34
0
    public void TestTrue()
    {
        XCRMParser parser = new XCRMParser();
        System.Xml.XmlElement xmlelement = RoarExtensions.CreateXmlElement(
          "<true_requirement ok=\"true\" />"
        );

        Roar.DomainObjects.Requirements.True r = parser.ParseARequirement(xmlelement) as Roar.DomainObjects.Requirements.True;
        mockery.VerifyAllExpectationsHaveBeenMet();
        Assert.IsNotNull(r);
        Assert.AreEqual(r.ok, true);
        Assert.IsNull(r.reason);
    }