public void TestEncodeACL()
        {
            AVACL acl1 = new AVACL();
              IDictionary<string, object> value1 = ParseEncoderTestClass.Instance.Encode(acl1) as IDictionary<string, object>;
              Assert.IsNotNull(value1);
              Assert.AreEqual(0, value1.Keys.Count);

              AVACL acl2 = new AVACL();
              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 AVUser and test SetReadAccess and SetWriteAccess
        }
Esempio n. 2
0
 /// <summary>
 /// Constructs a new AVRole with the given name.
 /// </summary>
 /// <param name="name">The name of the role to create.</param>
 /// <param name="acl">The ACL for this role. Roles must have an ACL.</param>
 public AVRole(string name, AVACL acl)
     : this()
 {
     Name = name;
       ACL = acl;
 }
Esempio n. 3
0
 /// <summary>
 /// Constructs a new AVRole with the given name.
 /// </summary>
 /// <param name="name">The name of the role to create.</param>
 /// <param name="acl">The ACL for this role. Roles must have an ACL.</param>
 public AVRole(string name, AVACL acl)
     : this()
 {
     Name = name;
     ACL  = acl;
 }
Esempio n. 4
0
        public void TestIndexGetterSetter()
        {
            AVObject obj = AVObject.Create("Corgi");
            obj["gogo"] = true;
            obj["list"] = new List<string>();
            obj["dict"] = new Dictionary<string, object>();
            obj["fakeACL"] = new AVACL();
            obj["obj"] = new AVObject("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<AVACL>(obj["fakeACL"]);

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

            Assert.Throws<KeyNotFoundException>(() => { var gogo = obj["missingItem"]; });
        }