Esempio n. 1
0
        public void TestArrayObject()
        {
            var now    = DateTimeOffset.UtcNow;
            var nowStr = now.ToString("o");
            var ao     = new MutableArrayObject();
            var blob   = new Blob("text/plain", Encoding.UTF8.GetBytes("Winter is coming"));
            var dict   = new MutableDictionaryObject(new Dictionary <string, object> {
                ["foo"] = "bar"
            });

            ao.AddFloat(1.1f);
            ao.AddBlob(blob);
            ao.AddDate(now);
            ao.AddDictionary(dict);

            var obj = new Object();
            var arr = new MutableArrayObject(new[] { 5, 4, 3, 2, 1 });

            ao.InsertValue(0, obj);
            ao.InsertInt(0, 42);
            ao.InsertLong(0, Int64.MaxValue);
            ao.InsertFloat(0, 3.14f);
            ao.InsertDouble(0, Math.PI);
            ao.InsertBoolean(0, true);
            ao.InsertBlob(0, blob);
            ao.InsertDate(0, now);
            ao.InsertArray(0, arr);
            ao.InsertDictionary(0, dict);
            ao.Should().Equal(dict, arr, nowStr, blob, true, Math.PI, 3.14f, Int64.MaxValue, 42, obj, 1.1f, blob,
                              nowStr,
                              dict);

            ao.SetLong(0, Int64.MaxValue);
            ao.SetFloat(1, 3.14f);
            ao.SetDouble(2, Math.PI);
            ao.SetBoolean(3, true);
            ao.SetBlob(4, blob);
            ao.SetArray(5, arr);
            ao.SetDictionary(6, dict);
            ao.SetDate(7, now);
            ao.Should().Equal(Int64.MaxValue, 3.14f, Math.PI, true, blob, arr, dict, nowStr, 42, obj, 1.1f, blob,
                              nowStr,
                              dict);
        }