示例#1
0
    public void ParameterGroupToJson()
    {
        Parameter p         = new Parameter("p", "test");
        Parameter container = new Parameter("c");

        container.AddParameter(p);
        string paramJson = Newtonsoft.Json.JsonConvert.SerializeObject(container.ToJson());

        Assert.That(paramJson, Is.EqualTo("{\"p\":\"test\"}"));
    }
示例#2
0
    public void ParameterAddParameter()
    {
        Assert.That(param1.ContainsKey("bad_key"), Is.False);

        Parameter param2 = new Parameter("bad_key", "hello world");

        param1.AddParameter(param2);

        Assert.That(param1.ContainsKey("bad_key"), Is.True);
        Assert.That(param1["bad_key"].ToString(), Is.EqualTo("hello world"));
    }
示例#3
0
    public void ParameterGroupWriteXml()
    {
        StringBuilder sb     = new StringBuilder();
        XmlWriter     writer = new XmlTextWriter(new StringWriter(sb));

        Parameter p         = new Parameter("p", "test");
        Parameter container = new Parameter("c");

        container.AddParameter(p);
        container.WriteXml(writer);

        Assert.That(sb.ToString(), Is.EqualTo("<Param name=\"c\"><Param name=\"p\" value=\"test\" /></Param>"));
    }
示例#4
0
    public void ParameterWithValueAndContents()
    {
        Parameter param2 = new Parameter("Alice");

        Assert.That(param2.ToString(), Is.Null);

        param2.SetValue("test");
        Assert.That(param2.ToString(), Is.EqualTo("test"));
        Assert.That(param2.ContainsKey("Bob"), Is.False);

        param2.AddParameter(new Parameter("Bob"));
        Assert.That(param2.ToString(), Is.EqualTo("test"));
        Assert.That(param2.ContainsKey("Bob"), Is.True);
        Assert.That(param2["Bob"].GetName(), Is.EqualTo("Bob"));
    }