public void TestUser()
        {
            string   name        = "MrBigglesworth";
            string   p1          = "permission1";
            string   timeZone    = "PST";
            string   color       = "CornflowerBlue";
            DateTime currentTime = DateTime.UtcNow;
            User     user        = new User();
            BlobIO   blob        = user.Serialize();

            Assert.Equal(blob.Get <string>(0), null);

            user = new User
            {
                UserName    = name,
                Permissions = new PermissionSet(new HashSet <string> {
                    p1
                }),
                CreateDate    = currentTime,
                Timezone      = timeZone,
                FavoriteColor = color
            };
            blob = user.Serialize();
            Assert.Equal(blob.Get <string>(0), name);
            Assert.Equal(blob.Get <PermissionSet>(1).Permissions.Single(), p1);
            Assert.Equal(blob.GetDateTime(2)?.Ticks, currentTime.Ticks);
            Assert.Equal(blob.Get <string>(3), timeZone);
            Assert.Equal(blob.Get <string>(4), color);
        }
Esempio n. 2
0
        public void UserToBlob()
        {
            DateTime      now     = DateTime.Now;
            string        color   = "Yellow";
            int           perm1   = 1;
            int           perm66  = 66;
            int           perm101 = 101;
            PermissionSet ps      = new PermissionSet(new List <int> {
                perm1, perm66
            });
            string tz   = "PST";
            string name = "Name";

            User user = new User
            {
                CreationDate  = now,
                FavoriteColor = color,
                PermissionSet = ps,
                Timezone      = tz,
                Username      = name
            };

            BlobIO blob = user.ToBlobIO();

            DateTime?     creationDate  = blob.GetDateTime(0);
            string        favoriteColor = blob.GetString(1);
            PermissionSet permissionSet = blob.GetPermissionSet(2);
            string        timezone      = blob.GetString(3);
            string        username      = blob.GetString(4);

            Assert.Equal(now, creationDate);
            Assert.Equal(color, favoriteColor);
            Assert.Contains(perm1, permissionSet.Permissions);
            Assert.Contains(perm66, permissionSet.Permissions);
            Assert.DoesNotContain(perm101, permissionSet.Permissions);
            Assert.Equal(timezone, timezone);
            Assert.Equal(name, username);
        }