public void TestIndexGetterSetter()
        {
            ParseObject obj = ParseObject.Create("Corgi");

            obj["gogo"]    = true;
            obj["list"]    = new List <string>();
            obj["dict"]    = new Dictionary <string, object>();
            obj["fakeACL"] = new ParseAcl();
            obj["obj"]     = new ParseObject("Corgi");

            Assert.True(obj.ContainsKey("gogo"));
            Assert.IsInstanceOf <bool>(obj["gogo"]);

            Assert.True(obj.ContainsKey("list"));
            Assert.IsInstanceOf <IList <string> >(obj["list"]);

            Assert.True(obj.ContainsKey("dict"));
            Assert.IsInstanceOf <IDictionary <string, object> >(obj["dict"]);

            Assert.True(obj.ContainsKey("fakeACL"));
            Assert.IsInstanceOf <ParseAcl>(obj["fakeACL"]);

            Assert.True(obj.ContainsKey("obj"));
            Assert.IsInstanceOf <ParseObject>(obj["obj"]);

            Assert.Throws <KeyNotFoundException>(() => { var gogo = obj["missingItem"]; });
        }
Beispiel #2
0
        public void TestEncodeACL()
        {
            ParseAcl acl1 = new ParseAcl();
            IDictionary <string, object> value1 = ParseEncoderTestClass.Instance.Encode(acl1) as IDictionary <string, object>;

            Assert.IsNotNull(value1);
            Assert.AreEqual(0, value1.Keys.Count);

            ParseAcl acl2 = new ParseAcl();

            acl2.PublicReadAccess  = true;
            acl2.PublicWriteAccess = true;
            IDictionary <string, object> value2 = ParseEncoderTestClass.Instance.Encode(acl2) as IDictionary <string, object>;

            Assert.AreEqual(1, value2.Keys.Count);
            IDictionary <string, object> publicAccess = value2["*"] as IDictionary <string, object>;

            Assert.AreEqual(2, publicAccess.Keys.Count);
            Assert.IsTrue((bool)publicAccess["read"]);
            Assert.IsTrue((bool)publicAccess["write"]);

            // TODO (hallucinogen): mock ParseUser and test SetReadAccess and SetWriteAccess
        }