private MutableDocument CreateDocument(string tag)
        {
            var doc = new MutableDocument();

            doc.SetString("tag", tag);

            doc.SetString("firstName", "Daniel");
            doc.SetString("lastName", "Tiger");

            var address = new MutableDictionaryObject();

            address.SetString("street", "1 Main street");
            address.SetString("city", "Mountain View");
            address.SetString("state", "CA");
            doc.SetDictionary("address", address);

            var phones = new MutableArrayObject();

            phones.AddString("650-123-0001")
            .AddString("650-123-0001");

            doc.SetArray("phones", phones);

            doc.SetDate("updated", DateTimeOffset.UtcNow);

            return(doc);
        }
Пример #2
0
        public void TestArrayFragmentSetArrayObject()
        {
            var doc = new MutableDocument("doc1");

            doc["array"].Value = new List <object>();
            var array = new MutableArrayObject();

            array.AddString("Jason").AddDouble(5.5).AddBoolean(true);

            doc["array"].Array.AddArray(array);

            SaveDocument(doc, d =>
            {
                d["array"][0][0].String.Should().Be("Jason", "because that is the value that was stored");
                d["array"][0][1].Double.Should().Be(5.5, "because that is the value that was stored");
                d["array"][0][2].Boolean.Should().Be(true, "because that is the value that was stored");
            });
        }