Beispiel #1
0
        public void TestImmutableKeys()
        {
            AVUser user = new AVUser();

            string[] immutableKeys = new string[] { "sessionToken", "isNew" };

            foreach (var key in immutableKeys)
            {
                Assert.Throws <InvalidOperationException>(() =>
                                                          user[key] = "1234567890"
                                                          );

                Assert.Throws <InvalidOperationException>(() =>
                                                          user.Add(key, "1234567890")
                                                          );

                Assert.Throws <InvalidOperationException>(() =>
                                                          user.AddRangeUniqueToList(key, new string[] { "1234567890" })
                                                          );

                Assert.Throws <InvalidOperationException>(() =>
                                                          user.Remove(key)
                                                          );

                Assert.Throws <InvalidOperationException>(() =>
                                                          user.RemoveAllFromList(key, new string[] { "1234567890" })
                                                          );
            }

            // Other special keys should be good
            user["username"] = "******";
            user["password"] = "******";
        }
Beispiel #2
0
        public void TestRemoveFields()
        {
            IObjectState state = new MutableObjectState
            {
                ServerData = new Dictionary <string, object>()
                {
                    { "username", "kevin" },
                    { "name", "andrew" }
                }
            };
            AVUser user = AVObjectExtensions.FromState <AVUser>(state, "_User");

            Assert.Throws <ArgumentException>(() => user.Remove("username"));
            Assert.DoesNotThrow(() => user.Remove("name"));
            Assert.False(user.ContainsKey("name"));
        }